Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(just): verbose and quiet update messages #167

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 57 additions & 4 deletions build/ublue-os-just/10-update.just
Original file line number Diff line number Diff line change
@@ -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 <level>"
echo " <level>: 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
Expand Down