From 4079a0cb4c5b2e5807f4b25f0bb98924c5d15da0 Mon Sep 17 00:00:00 2001 From: guochao Date: Tue, 7 Nov 2023 09:59:08 +0800 Subject: [PATCH] improvement by using systemctl kexec if possible --- nixos-kexec-profile.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nixos-kexec-profile.sh b/nixos-kexec-profile.sh index b54db2f..31dedd0 100644 --- a/nixos-kexec-profile.sh +++ b/nixos-kexec-profile.sh @@ -78,6 +78,9 @@ while [[ $# -gt 0 ]]; do -b|--boot) BOOT=y ;; + -*|--*) + fail "unrecognized option" + ;; *) if set-target "$opt"; then : @@ -137,5 +140,10 @@ fi run kexec -l --initrd=$INITRD --command-line="$CMDLINE" $KERNEL if [ $BOOT == y ]; then - run kexec -e + sync + if type systemctl &> /dev/null; then + systemctl kexec + else + run kexec -e + fi fi