Add posibility to just poweroff the host
This commit is contained in:
		
							parent
							
								
									ecab3bea7e
								
							
						
					
					
						commit
						70bdbc8a89
					
				
							
								
								
									
										14
									
								
								winboot
								
								
								
								
							
							
						
						
									
										14
									
								
								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 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue