Set a main function
This commit is contained in:
		
							parent
							
								
									8376bd355e
								
							
						
					
					
						commit
						16e1324b2a
					
				
							
								
								
									
										24
									
								
								winboot
								
								
								
								
							
							
						
						
									
										24
									
								
								winboot
								
								
								
								
							|  | @ -1,8 +1,20 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| GRUB_DEFAULT_PATH='/etc/default/grub' | ||||
| GRUB_DEFAULT_DIR='/etc/default/grub.d' | ||||
| WIN_GRUB="2" | ||||
| # This script set a specific grub entry (winLOOSE…) for the next boot. | ||||
| # Then reboot the host | ||||
| 
 | ||||
| # Vars {{{ | ||||
| readonly PROGNAME=$(basename "${0}") | ||||
| readonly PROGDIR=$(readlink -m $(dirname "${0}")) | ||||
| readonly ARGS="${*}" | ||||
| readonly NBARGS="${#}" | ||||
| 
 | ||||
| readonly GRUB_DEFAULT_PATH='/etc/default/grub' | ||||
| readonly GRUB_DEFAULT_DIR='/etc/default/grub.d' | ||||
| readonly WIN_GRUB="2" | ||||
| # }}} | ||||
| 
 | ||||
| main() {                                                        # {{{ | ||||
| 
 | ||||
| 	# First check in Grub default dir if saved mode is set | ||||
| 	if grep -q -E -R -- "^GRUB_DEFAULT=saved" "${GRUB_DEFAULT_DIR}" | ||||
|  | @ -25,7 +37,11 @@ else | |||
| 		GRUB_DEFAULT_ENTRY=$(grep -E -- "#GRUB_DEFAULT=" "${GRUB_DEFAULT_PATH}" | cut -d"=" -f2) | ||||
| 		sudo grub-set-default "${GRUB_DEFAULT_ENTRY}" | ||||
| 		sudo update-grub | ||||
| 	printf '%b' "Please launch this script once again.\\n" | ||||
| 		printf '%b' "Please launch this script (${PROGDIR}/${PROGNAME} ${ARGS}) once again.\\n" | ||||
| 	fi | ||||
| } | ||||
| # }}} | ||||
| 
 | ||||
| main | ||||
| 
 | ||||
| exit 0 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue