Add posibility to just poweroff the host

This commit is contained in:
Jeremy Gardais 2020-07-15 17:50:18 +02:00
parent ecab3bea7e
commit 70bdbc8a89
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 11 additions and 3 deletions

View File

@ -15,6 +15,7 @@ readonly WIN_GRUB="2"
## By default, the host should reboot at the end of the script ## By default, the host should reboot at the end of the script
REBOOT=0 REBOOT=0
HALT=1
# }}} # }}}
@ -26,6 +27,7 @@ main() { # {{{
printf '%b' "Reboot to windaube partition\\n" printf '%b' "Reboot to windaube partition\\n"
sudo grub-reboot "${WIN_GRUB}" sudo grub-reboot "${WIN_GRUB}"
[ "${REBOOT}" -eq "0" ] && sudo systemctl reboot [ "${REBOOT}" -eq "0" ] && sudo systemctl reboot
[ "${HALT}" -eq "0" ] && sudo systemctl poweroff
fi fi
# Otherwise check the default grub file # Otherwise check the default grub file
@ -34,6 +36,7 @@ main() { # {{{
printf '%b' "Reboot to windaube partition\\n" printf '%b' "Reboot to windaube partition\\n"
sudo grub-reboot "${WIN_GRUB}" sudo grub-reboot "${WIN_GRUB}"
[ "${REBOOT}" -eq "0" ] && sudo systemctl reboot [ "${REBOOT}" -eq "0" ] && sudo systemctl reboot
[ "${HALT}" -eq "0" ] && sudo systemctl poweroff
else else
printf '%b' "GRUB_DEFAULT is not set in 'saved' mode\\n" printf '%b' "GRUB_DEFAULT is not set in 'saved' mode\\n"
@ -59,6 +62,11 @@ if [ ! "${NBARGS}" -eq "0" ]; then
case "${1}" in case "${1}" in
--reboot ) ## A reboot was requested (default behaviour) --reboot ) ## A reboot was requested (default behaviour)
REBOOT=0 REBOOT=0
HALT=1
;;
--halt|--poweroff ) ## A poweroff was requested
REBOOT=1
HALT=0
;; ;;
-- ) ## End of options list -- ) ## End of options list
## End the while loop ## End the while loop