From 20d6b2809fa7219241d14cdcd0842bb098081613 Mon Sep 17 00:00:00 2001 From: Carlos Sousa Date: Mon, 3 Feb 2025 13:30:40 +0100 Subject: [PATCH] add update and shutdown fedora script --- bashScripts/update_and_shutdown_fedora.sh | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bashScripts/update_and_shutdown_fedora.sh diff --git a/bashScripts/update_and_shutdown_fedora.sh b/bashScripts/update_and_shutdown_fedora.sh new file mode 100644 index 00000000..cf8e3983 --- /dev/null +++ b/bashScripts/update_and_shutdown_fedora.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +SHUTDOWN_TIMEOUT=10 + +# make sure we have permissions +# +if [ "$EUID" -ne 0 ]; then + echo "######" + echo "This script must be run with sudo." + echo "Attempting to rerun with sudo..." + echo "######" + + # Re-run the script with sudo + exec sudo "$0" "$@" + + # If we reach here, sudo failed to execute + echo "Failed to access sudo. Exiting." + exit 1 +fi + +echo "" +echo "sudo permissions available. Starting" +echo "" + +sudo dnf check -y +sudo dnf check-update -y +sudo dnf update -y +sudo flatpak update -y +sudo flatpak repair +sudo flatpak uninstall --unused -y +sudo dnf autoremove -y +sudo dnf clean all -y + + +echo "" +echo "Press any key withing $SHUTDOWN_TIMEOUT seconds to cancel shutdown." +echo "" + +if read -t $SHUTDOWN_TIMEOUT -n 1; then + echo "Shutdown Canceled" +else + echo "Shutting down" + sudo shutdown now +fi