33# --- Docker Tool Suite ---
44# =========================
55
6- SCRIPT_VERSION=v1.5.4.7
6+ SCRIPT_VERSION=v1.5.4.8
77
88# --- Strict Mode & Globals ---
99set -euo pipefail
@@ -632,7 +632,7 @@ initial_setup() {
632632 _prompt_input " Volume Backup Location" " $backup_path_def " BACKUP_LOCATION " path"
633633 _prompt_input " Volume Restore Location" " $restore_path_def " RESTORE_LOCATION " path"
634634 _prompt_input " Log Directory Path" " $log_dir_def " LOG_DIR " path"
635- _prompt_input " Log file retention period ( days, 0 to disable) " " $log_retention_def " LOG_RETENTION_DAYS " int" 0 3650
635+ _prompt_input " Log file retention period in days. Set to 0 to disable automatic pruning. " " $log_retention_def " LOG_RETENTION_DAYS " int" 0 3650
636636
637637 local log_sub_update_def=" apps-update-logs"
638638 local log_sub_unused_def=" unused-images-update-logs"
@@ -2336,45 +2336,35 @@ prune_old_logs() {
23362336}
23372337
23382338_log_viewer_select_and_view () {
2339- local less_prompt=" (Scroll with arrow keys, press 'q' to return)"
23402339 while true ; do
2341- clear
23422340 mapfile -t log_files < <( find " $LOG_DIR " -name " *.log" -type f | sort -r)
2343-
2341+
23442342 if [ ${# log_files[@]} -eq 0 ]; then
23452343 echo -e " ${C_YELLOW} No log files found to view.${C_RESET} " ; sleep 2; return
23462344 fi
23472345
2348- clear
2349- echo " =============================================="
2350- echo -e " ${C_GREEN}${T_BOLD} Docker Tool Suite ${SCRIPT_VERSION}${C_RESET} "
2351- echo " =============================================="
2352- echo -e " ${C_CYAN} --- Log Viewer ---"
2353- echo -e " ${C_RESET} ----------------------------------------------\n"
2354- echo -e " ${C_YELLOW} Select a log file to view:${C_RESET} "
2355-
2356- local -a display_options=()
2346+ local -a options=()
23572347 for file in " ${log_files[@]} " ; do
2358- display_options+=(" ${C_GREEN} $( realpath --relative-to=" $LOG_DIR " " $file " ) ${C_RESET} " )
2359- done
2360- display_options+=(" ${C_GRAY} Return to Log Manager${C_RESET} " )
2361-
2362- PS3=$' \n ' " ${C_YELLOW} Enter your choice: ${C_RESET} "
2363- select choice in " ${display_options[@]} " ; do
2364- if [[ " $choice " == " ${C_GRAY} Return to Log Manager${C_RESET} " ]]; then
2365- return
2366- elif [[ -n " $choice " ]]; then
2367- local idx=$(( REPLY - 1 ))
2368- echo -e " ${C_RESET} ----------------------------------------------"
2369- echo -e " \n${C_CYAN} Opening log ${display_options[$idx]} "
2370- echo -e " ${C_RESET} ----------------------------------------------\n"
2371- echo -e " ${C_GREEN} --- Log START ---${C_RESET} "
2372- less -RX --prompt=" $less_prompt " " ${log_files[$idx]} "
2373- break
2374- else
2375- echo -e " ${C_RED} Invalid option. Please try again.${C_RESET} " ; sleep 1; break
2376- fi
2348+ options+=(" $( realpath --relative-to=" $LOG_DIR " " $file " ) " )
23772349 done
2350+
2351+ print_standard_menu " Log Viewer" options " RQ"
2352+ read -erp " ${C_YELLOW} Please select a log to view: ${C_RESET} " choice
2353+
2354+ # Handle Menu Selection
2355+ if [[ " $choice " =~ ^[0-9]+$ ]] && [ " $choice " -ge 1 ] && [ " $choice " -le " ${# log_files[@]} " ]; then
2356+ local idx=$(( choice- 1 ))
2357+ clear
2358+ echo -e " ${C_GREEN} --- Viewing Log: ${C_CYAN} $( basename " ${log_files[$idx]} " ) ${C_GREEN} ---${C_RESET} "
2359+ echo -e " ${C_GRAY} (Press 'q' to return)${C_RESET} \n"
2360+ less -RX " ${log_files[$idx]} "
2361+ elif [[ " ${choice,,} " == " r" ]]; then
2362+ return
2363+ elif [[ " ${choice,,} " == " q" ]]; then
2364+ exit 0
2365+ else
2366+ echo -e " \n${C_RED} Invalid option! Please try again.${C_RESET} " ; sleep 1
2367+ fi
23782368 done
23792369}
23802370
@@ -2392,29 +2382,31 @@ log_remover_main() {
23922382
23932383 local -a files_to_delete=()
23942384 for i in " ${! log_files[@]} " ; do if ${selected_status[$i]} ; then files_to_delete+=(" ${log_files[$i]} " ); fi ; done
2385+
23952386 if [ ${# files_to_delete[@]} -eq 0 ]; then echo -e " \n${C_YELLOW} No logs selected.${C_RESET} " ; sleep 1; return ; fi
23962387
2397- echo -e " \n${C_RED} You are about to permanently delete ${# files_to_delete[@]} log file(s).${C_RESET} "
2398- read -rp " ${C_YELLOW} Are you sure? [${C_RESET} Y ${C_YELLOW} /${C_RESET } N${C_YELLOW} ]: ${C_RESET} " confirm
2388+ echo -e " \n${C_RED} Permanently deleting ${# files_to_delete[@]} log file(s).${C_RESET} "
2389+ read -rp " ${C_YELLOW} Are you sure? [${C_GREEN} y ${C_YELLOW} /${C_RED } N${C_YELLOW} ]: ${C_RESET} " confirm
23992390 if [[ ! " ${confirm,,} " =~ ^(y| Y| yes| YES)$ ]]; then echo -e " ${C_RED} Deletion canceled.${C_RESET} " ; sleep 1; return ; fi
24002391
24012392 echo " "
24022393 for file in " ${files_to_delete[@]} " ; do
24032394 if rm " $file " ; then
2404- log " Deleted log file: $file " " -> Deleted ${C_CYAN} $( basename " $file " ) ${C_RESET} "
2395+ echo -e " -> ${C_GREEN} Deleted ${C_CYAN} $( basename " $file " ) ${C_RESET} "
2396+ log " Deleted log file: $file "
24052397 else
2406- log " ERROR: Failed to delete log file: $file " " -> ${C_RED} Failed to delete $( basename " $file " ) ${C_RESET} "
2398+ echo -e " -> ${C_RED} Failed to delete $( basename " $file " ) ${C_RESET} "
2399+ log " ERROR: Failed to delete log file: $file "
24072400 fi
24082401 done
2409- echo -e " \n${C_GREEN} Deletion complete.${C_RESET} "
2402+ echo -e " \n${C_GREEN}${TICKMARK} Operation complete.${C_RESET} " ; sleep 1
24102403}
24112404
24122405log_manager_configure_retention () {
24132406 clear
2414- echo -e " ${C_YELLOW} --- Configure Log Retention ---${C_RESET} \n"
2415- # Added Limits: Min 0, Max 3650 (10 years)
2416- _update_config_value " LOG_RETENTION_DAYS" " Log file retention period (days, 0 to disable)" " ${LOG_RETENTION_DAYS:- 30} " " 30" " int" " 0" " 3650"
2417- echo -e " \n${C_GREEN} Retention policy updated.${C_RESET} "
2407+ echo -e " ${C_GREEN} --- Configure Log Retention ---${C_RESET} \n"
2408+ _update_config_value " LOG_RETENTION_DAYS" " Log file retention period in days. Set to 0 to disable automatic pruning." " ${LOG_RETENTION_DAYS:- 30} " " 30" " int" " 0" " 3650"
2409+ echo -e " \n${C_GREEN}${TICKMARK} Retention policy updated.${C_RESET} " ; sleep 1
24182410}
24192411
24202412log_manager_menu () {
@@ -2987,7 +2979,8 @@ _update_config_value() {
29872979
29882980 if [[ -n " $default_value " ]]; then
29892981 if [[ " $current_value " != " $default_value " ]]; then
2990- echo -e " ${C_GRAY} Default: ${default_value} (Type '${C_RESET} reset${C_GRAY} ' to restore)${C_RESET} "
2982+ echo -e " ${C_YELLOW} Current: ${C_CYAN}${current_value} ${C_YELLOW} days.${C_RESET} "
2983+ echo -e " ${C_GRAY} Type '${C_CYAN} reset${C_GRAY} ' to restore default value: ${C_CYAN}${default_value} ${C_GRAY} days. ${C_RESET} \n"
29912984 fi
29922985 fi
29932986
0 commit comments