diff --git a/build/ublue-os-just/10-update.just b/build/ublue-os-just/10-update.just index 83099601..441dd33a 100644 --- a/build/ublue-os-just/10-update.just +++ b/build/ublue-os-just/10-update.just @@ -1,16 +1,69 @@ # vim: set ft=make : # Update system, flatpaks, and containers all at once -update: +update VERB_LEVEL="full": #!/usr/bin/env bash if systemctl is-enabled ublue-update.timer | grep -q enabled; then echo "Starting the ublue-update service" sudo systemctl start ublue-update.service else - rpm-ostree update - flatpak update -y - distrobox upgrade -a + if [ {{ VERB_LEVEL }} = "help" ]; then + echo "Usage: just update " + echo " : Specify the verbosity level - 'full', 'minimal', or 'prompt'" + echo " Use 'full' to show full output of each command." + echo " Use 'minimal' to show minimal output and indicate success or failure." + echo " Use 'prompt' to prompt the user before running each command." + exit 0 + fi + + # Function to run commands with appropriate verbosity and approval check + update_command() { + command=$1 + case "{{ VERB_LEVEL }}" in + full) + echo "Running $command..." + $command + echo "Completed $command" + ;; + minimal) + echo "Running $command..." + $command > /dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "Completed $command" + else + echo "Failed to complete $command" + exit 1 + fi + ;; + prompt) + printf "Do you want to run %s? [Y/n]: " "$command" + read user_input + user_input=${user_input:-Y} # Default to Y if Enter is pressed + if [ "$user_input" = "Y" ] || [ "$user_input" = "y" ]; then + echo "Running $command..." + $command + echo "Completed $command" + else + echo "Skipped $command" + fi + ;; + *) + echo "Invalid level: {{ VERB_LEVEL }}. Please use 'full', 'minimal', 'prompt' or 'help' for usage." + exit 1 + ;; + esac + } + + # Run rpm-ostree update + update_command "rpm-ostree update" + + # Run flatpak update + update_command "flatpak update -y" + + # Run distrobox upgrade + update_command "distrobox upgrade -a" + fi # Update device firmware