Add logging, dialog UI, README updates and initial release
This commit is contained in:
parent
15d3f0b2d6
commit
ab945b1caf
4 changed files with 339 additions and 118 deletions
117
log/update-manager.sh
Normal file
117
log/update-manager.sh
Normal file
|
|
@ -0,0 +1,117 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
UPDATE_MANAGER_SCRIPT="/opt/update-manager/update-manager.sh"
|
||||
|
||||
get_log_file() {
|
||||
local primary="/opt/update-manager/log/update-manager.log"
|
||||
local fallback="$HOME/update-manager/log/update-manager.log"
|
||||
|
||||
if [[ -f "$primary" ]]; then
|
||||
echo "$primary"
|
||||
else
|
||||
echo "$fallback"
|
||||
fi
|
||||
}
|
||||
|
||||
run_check() {
|
||||
echo
|
||||
bash "$UPDATE_MANAGER_SCRIPT" check
|
||||
echo
|
||||
read -rp "Press Enter to continue..."
|
||||
}
|
||||
|
||||
view_log() {
|
||||
local log_file
|
||||
log_file="$(get_log_file)"
|
||||
|
||||
echo
|
||||
if [[ -f "$log_file" ]]; then
|
||||
less "$log_file"
|
||||
else
|
||||
echo "Log file not found: $log_file"
|
||||
echo
|
||||
read -rp "Press Enter to continue..."
|
||||
fi
|
||||
}
|
||||
|
||||
follow_log() {
|
||||
local log_file
|
||||
log_file="$(get_log_file)"
|
||||
|
||||
echo
|
||||
if [[ -f "$log_file" ]]; then
|
||||
echo "Following log: $log_file"
|
||||
echo "Press Ctrl+C to stop."
|
||||
echo
|
||||
tail -f "$log_file"
|
||||
else
|
||||
echo "Log file not found: $log_file"
|
||||
fi
|
||||
|
||||
echo
|
||||
read -rp "Press Enter to continue..."
|
||||
}
|
||||
|
||||
show_log_location() {
|
||||
local log_file
|
||||
log_file="$(get_log_file)"
|
||||
|
||||
echo
|
||||
echo "Log file location:"
|
||||
echo "$log_file"
|
||||
echo
|
||||
read -rp "Press Enter to continue..."
|
||||
}
|
||||
|
||||
show_menu() {
|
||||
clear
|
||||
echo "=================================="
|
||||
echo " Update Manager UI"
|
||||
echo "=================================="
|
||||
echo
|
||||
echo "1) Run update check"
|
||||
echo "2) View full log"
|
||||
echo "3) Follow log live"
|
||||
echo "4) Show log location"
|
||||
echo "0) Exit"
|
||||
echo
|
||||
}
|
||||
|
||||
main() {
|
||||
if [[ ! -f "$UPDATE_MANAGER_SCRIPT" ]]; then
|
||||
echo "Update manager script not found: $UPDATE_MANAGER_SCRIPT"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while true; do
|
||||
show_menu
|
||||
read -rp "Choose an option: " choice
|
||||
|
||||
case "$choice" in
|
||||
1)
|
||||
run_check
|
||||
;;
|
||||
2)
|
||||
view_log
|
||||
;;
|
||||
3)
|
||||
follow_log
|
||||
;;
|
||||
4)
|
||||
show_log_location
|
||||
;;
|
||||
0)
|
||||
echo
|
||||
echo "Bye."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo
|
||||
echo "Invalid choice."
|
||||
read -rp "Press Enter to continue..."
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue