Software/Sovran_SystemsOS_Light_Updater/Updater Source Files/Update_Sovran_SystemsOS_Light.sh

156 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
LOGIN () {
mkdir -p /home/free/Documents/Updater_App_Logs
time_stamp=$(date +%Y-%m-%d-%T)
ssh root@localhost flatpak update -y &> /home/free/Documents/Updater_App_Logs/{$time_stamp}-Updater_Login_Log.txt
}
HUNGRY () {
pushd /home/free/Documents/Updater_App_Logs
file=$(ls -Art | tail -n 1)
if grep -w "Permission denied" $file ; then
zenity --error \
--width=500 \
--title="Sovran_SystemsOS_Light_Updater" \
--text="Authentication Canceled. Exiting..."
exit 1
fi
popd
}
FLAKE () {
time_stamp=$(date +%Y-%m-%d-%T)
ssh root@localhost "cd /etc/nixos && nix flake update &> /home/free/Documents/Updater_App_Logs/{$time_stamp}-Updater_Flake_Log.txt"
}
PANCAKE-FLAKE () {
pushd /home/free/Documents/Updater_App_Logs
file=$(ls -Art | tail -n 1)
if grep -w "nix: error" $file ; then
zenity --error \
--width=1300 \
--title="Sovran_SystemsOS_Light_Updater" \
--text="Could not complete the Flake update. Check the Updater_Flake_Log.txt in your Documents under Updater_App_Logs folder for more details."
exit 1
fi
popd
}
YOGURT-FLAKE () {
pushd /home/free/Documents/Updater_App_Logs
file=$(ls -Art | tail -n 1)
if ! grep -w "updating" $file ; then
zenity --info \
--ellipsize \
--no-wrap \
--width=600 \
--title="Sovran_SystemsOS_Light_Updater" \
--text="There are no updates at this time. Your Sovran Book Pro is up to date!"
exit 1
fi
popd
}
SPICE () {
time_stamp=$(date +%Y-%m-%d-%T)
xterm -T "Sovran_SystemsOS_Light_Updater" -fa 'Noto Mono' -fs 15 -fg white -bg black -e bash -c "ssh root@localhost 'cd /etc/nixos && nixos-rebuild switch --impure 2>&1 | tee /home/free/Documents/Updater_App_Logs/{$time_stamp}-Updater_Log.txt'"
}
TACO () {
pushd /home/free/Documents/Updater_App_Logs
file=$(ls -Art | tail -n 1)
if grep -w "error:" $file ; then
zenity --error \
--width=1300 \
--title="Sovran_SystemsOS_Light_Updater" \
--text="Could not complete the Sovran_SystemsOS_Light Update. Check the Updater_Log.txt in your Documents under Updater_App_Logs folder for more details."
else
zenity --info \
--ellipsize \
--no-wrap \
--width=550 \
--title="Sovran_SystemsOS_Light_Updater" \
--text="Yay complete! Please reboot when you are ready."
fi
popd
}
###########
curl "https://git.sovransystems.com/Sovran_Systems/Software/raw/branch/main/Sovran_SystemsOS_Light_Updater/Updater%20Source%20Files/Intro.md" |
zenity --text-info \
--width=1100 \
--height=830 \
--title="Sovran_SystemsOS_Light_Updater"
if [[ $? -eq 1 ]]; then
exit 1
else
LOGIN | zenity --progress --no-cancel --auto-close --width=500 --pulsate --text="Updating Flatpaks now..." --title="Sovran_SystemsOS_Light_Updater"
HUNGRY
FLAKE | zenity --progress --no-cancel --auto-close --width=500 --pulsate --text="Updating Flake now..." --title="Sovran_SystemsOS_Light_Updater"
PANCAKE-FLAKE
YOGURT-FLAKE
SPICE | zenity --progress --no-cancel --auto-close --width=1050 --pulsate --text="Updating entire system now. In rare cases, it could take up to 1 hour. Go have some herbal tea and relax while the update is in progress." --title="Sovran_SystemsOS_Light_Updater"
TACO
fi
find /home/free/Documents/Updater_App_Logs -name "*.txt" -type f -mtime +3 -delete
exit 0