Feat: Fügt ein Update-Skript hinzu
This commit is contained in:
parent
12e6cc7e32
commit
b91331307c
47
Maintenance/Update.sh
Executable file
47
Maintenance/Update.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# === IMPORTS ===
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$SCRIPT_DIR/../Utility/NetworkCheck.sh"
|
||||
source "$SCRIPT_DIR/../Utility/Log.sh"
|
||||
|
||||
# === ROOT-PRÜFUNG ===
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "Dieses Skript muss als root ausgeführt werden! Bitte starte es mit sudo."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# === Skript-Funktionen ===
|
||||
cleanup() {
|
||||
log "Update-Skript abgebrochen"
|
||||
exit 1
|
||||
}
|
||||
|
||||
update_packages() {
|
||||
log "Führe 'apt update' aus"
|
||||
apt update |& while IFS= read -r line; do log "$line"; done
|
||||
log "Befehl abgeschlossen"
|
||||
|
||||
log "Führe 'apt upgrade' aus"
|
||||
apt upgrade -y |& while IFS= read -r line; do log "$line"; done
|
||||
log "Befehl abgeschlossen"
|
||||
}
|
||||
|
||||
update_flatpak() {
|
||||
log "Führe 'flatpak update' für alle Nutzer aus"
|
||||
for user in $(getent passwd | awk -F: '$3 >= 1000 && $7 !~ /(\/sbin\/nologin|\/bin\/false|\/usr\/sbin\/nologin)/ { print $1 }'); do
|
||||
sudo -u "$user" flatpak update -y |& while IFS= read -r line; do log "$line"; done
|
||||
log "Befehl 'sudo -u $user flatpak update' abgeschlossen"
|
||||
done
|
||||
}
|
||||
|
||||
# === Hauptskript ===
|
||||
|
||||
trap cleanup SIGINT
|
||||
|
||||
wait_for_internet_connection
|
||||
|
||||
update_packages
|
||||
update_flatpak
|
||||
|
||||
log "Update-Skript beendet"
|
||||
Loading…
x
Reference in New Issue
Block a user