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