Migrationsscript für /boot/firmware erster Aufschlag.
This commit is contained in:
		
							
								
								
									
										66
									
								
								boot-mountpoint/migrate-mountpoint.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										66
									
								
								boot-mountpoint/migrate-mountpoint.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,66 @@ | |||||||
|  | #!/usr/bin/bash | ||||||
|  |  | ||||||
|  | # Output colors | ||||||
|  | RED='\033[0;31m' | ||||||
|  | GREEN='\033[0;32m' | ||||||
|  | YELLOW='\033[1;33m' | ||||||
|  | NC='\033[0m' # No Color | ||||||
|  |  | ||||||
|  | # Logging-Funktion | ||||||
|  | log() { | ||||||
|  |     echo -e "${GREEN}[INFO]${NC} $1" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | warn() { | ||||||
|  |     echo -e "${YELLOW}[WARN]${NC} $1" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | error() { | ||||||
|  |     echo -e "${RED}[ERROR]${NC} $1" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | # Check for root privileges | ||||||
|  | if [ "$EUID" -ne 0 ]; then | ||||||
|  |   echo "This script must be run as root" | ||||||
|  |   exit 1 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | # Create /boot/firmware dir if it doesn't exist | ||||||
|  | if [ ! -d /boot/firmware ]; then mkdir -p /boot/firmware; fi | ||||||
|  |  | ||||||
|  | # Enable extended globbing for pattern matching | ||||||
|  | shopt -s extglob | ||||||
|  |  | ||||||
|  | # Copy all files from /boot to /boot/firmware and remove the originals | ||||||
|  | log "Moving files to /boot/firmware..." | ||||||
|  | rsync -av --remove-source-files /boot/ /boot/firmware/ | ||||||
|  |  | ||||||
|  | # Update the mount point for /boot in fstab to /boot/firmware | ||||||
|  | log "Updating fstab..." | ||||||
|  | cp -a /etc/fstab /etc/fstab.bak # create backup | ||||||
|  | sed -i 's|^\([^#].*\)[[:space:]]/boot[[:space:]]|\1 /boot/firmware |' /etc/fstab | ||||||
|  |  | ||||||
|  | # Sync cache and reboot the system to apply changes | ||||||
|  | sync | ||||||
|  | # prompt for reboot | ||||||
|  | echo "" | ||||||
|  | while true; do | ||||||
|  |     read -p "Möchtest du das System jetzt neustarten, um die Änderungen zu testen? (J/N): " choice | ||||||
|  |     case $choice in | ||||||
|  |         [Jj]* )  | ||||||
|  |             warn "System will be rebooted in 3 seconds" | ||||||
|  |             sleep 2 | ||||||
|  |             reboot | ||||||
|  |             ;; | ||||||
|  |         [Nn]* )  | ||||||
|  |             log "Neustart übersprungen." | ||||||
|  |             log "Bitte starte das System manuell neu, um die Änderungen zu testen." | ||||||
|  |             break | ||||||
|  |             ;; | ||||||
|  |         * )  | ||||||
|  |             warn "Bitte antworte mit J (Ja) oder N (Nein)." | ||||||
|  |             ;; | ||||||
|  |     esac | ||||||
|  | done | ||||||
|  |  | ||||||
|  | exit 0 | ||||||
		Reference in New Issue
	
	Block a user