Add winboot script
This commit is contained in:
		
							parent
							
								
									867ee936d2
								
							
						
					
					
						commit
						631ff1687f
					
				
							
								
								
									
										13
									
								
								README.md
								
								
								
								
							
							
						
						
									
										13
									
								
								README.md
								
								
								
								
							|  | @ -18,6 +18,7 @@ Some useful scripts (for me) that can be added to $PATH :) | |||
| * veille.sh: Kill every sensitive process and files then lock the screen. | ||||
| * vimmanpager: Tiny script can be used as PAGER, it will call VIM! | ||||
| * weblink: Tiny Python script that run a small webserver to share files. | ||||
| * winboot : Reboot the system to a windaube partition. | ||||
| * wol: Send WakeOnLan/magic packets to remote host. | ||||
| * zenity_generator: Script to generate zenity window. | ||||
| * zfSnap.sh: Take snapshot of a ZFS pool. | ||||
|  | @ -143,3 +144,15 @@ weblink --pass=die /tmp/kitty.file | |||
| HTTP server running at http://localhost:8888/die | ||||
| ``` | ||||
| 
 | ||||
| ## Winboot | ||||
| Tiny script to reboot the system to a windaube partition. | ||||
| 
 | ||||
| Be sure to set the correct value to **WIN_GRUB** variable which must be the number of the windoze partition in Grub. Be careful, the grub's entries start at 0. | ||||
| 
 | ||||
| * The script will also modify the grub configuration : | ||||
|   * Set Grub in "saved" mode. | ||||
| * Then for the reboot : | ||||
|   * Choose the grub entry for the next reboot. | ||||
| 	* Reboot the system with ``systemctl``. | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,18 @@ | |||
| #!/bin/sh | ||||
| 
 | ||||
| GRUB_DEFAULT_PATH='/etc/default/grub' | ||||
| WIN_GRUB="2" | ||||
| 
 | ||||
| if grep -q -E -- "^GRUB_DEFAULT=saved" "${GRUB_DEFAULT_PATH}" | ||||
| then | ||||
| 	printf '%b' "Reboot to windaube partition\n" | ||||
| 	sudo grub-reboot "${WIN_GRUB}" | ||||
| 	sudo systemctl reboot | ||||
| else | ||||
| 	printf '%b' "GRUB_DEFAULT is not set in 'saved' mode\n" | ||||
| 	sudo sed -i 's/\(^GRUB_DEFAULT.*\)/#\1\nGRUB_DEFAULT=saved/' "${GRUB_DEFAULT_PATH}" | ||||
| 	sudo update-grub | ||||
| 	printf '%b' "Please launch this script once again.\n" | ||||
| fi | ||||
| 
 | ||||
| exit 0 | ||||
		Loading…
	
		Reference in New Issue