diff --git a/winboot b/winboot index e7da479..5e4d6b5 100755 --- a/winboot +++ b/winboot @@ -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" @@ -57,14 +60,19 @@ if [ ! "${NBARGS}" -eq "0" ]; then while printf -- '%s' "${1}" | grep -q -E -- "^-+"; do case "${1}" in - --reboot ) ## A reboot was requested (default behaviour) + --reboot ) ## A reboot was requested (default behaviour) REBOOT=0 + HALT=1 ;; - -- ) ## End of options list + --halt|--poweroff ) ## A poweroff was requested + REBOOT=1 + HALT=0 + ;; + -- ) ## End of options list ## End the while loop break ;; - * ) ## unknow option + * ) ## unknow option printf '%b\n' "${RED}Invalid option: ${1}${RESET}" printf '%b\n' "---" usage