armbian-next: docker: archive logfiles again; warn & greet testers when archiving many old logfiles

This commit is contained in:
Ricardo Pardini 2023-01-21 02:45:24 +01:00
parent dcaadac152
commit a6182bbd89
No known key found for this signature in database
GPG Key ID: 3D38CA12A66C5D02
2 changed files with 12 additions and 3 deletions

View File

@ -25,7 +25,6 @@ function cli_docker_run() {
ARMBIAN_CLI_RELAUNCH_PARAMS+=(["SET_OWNER_TO_UID"]="${EUID}") # fix the owner of files to our UID
ARMBIAN_CLI_RELAUNCH_PARAMS+=(["ARMBIAN_BUILD_UUID"]="${ARMBIAN_BUILD_UUID}") # pass down our uuid to the docker instance
ARMBIAN_CLI_RELAUNCH_PARAMS+=(["SKIP_LOG_ARCHIVE"]="yes") # launched docker instance will not cleanup logs.
declare -g SKIP_LOG_ARCHIVE=yes # Don't archive logs in the parent instance either.
declare -g ARMBIAN_CLI_RELAUNCH_ARGS=()
produce_relaunch_parameters # produces ARMBIAN_CLI_RELAUNCH_ARGS
@ -49,6 +48,7 @@ function cli_docker_run() {
# Set globals to avoid:
# 1) showing the controlling host's log; we only want to show a ref to the Docker logfile, unless it didn't produce one.
# If it did produce one, it's "link" is already shown above.
if [[ $docker_produced_logs -gt 0 ]]; then
declare -g show_message_after_export="skip" # handled by export_ansi_logs()
fi

View File

@ -22,9 +22,18 @@ function trap_handler_cleanup_logging() {
# Before writing new logfile, compress and move existing ones to archive folder.
# - Unless running under CI.
# - Also not if signalled via SKIP_LOG_ARCHIVE=yes
if [[ "${CI:-false}" != "true" && "${SKIP_LOG_ARCHIVE:-no}" != "yes" ]]; then
declare -a existing_log_files_array
mapfile -t existing_log_files_array < <(find "${target_path}" -maxdepth 1 -type f -name "armbian-*.*")
declare -a existing_log_files_array # array of existing log files: dash and dot in filename required.
mapfile -t existing_log_files_array < <(find "${target_path}" -maxdepth 1 -type f -name "*-*.*")
# if more than 7 log files, warn user...
if [[ "${#existing_log_files_array[@]}" -gt 7 ]]; then
# Hey, I fixed Docker archiving, so this should not happen again... heh.
display_alert "Archiving" "${#existing_log_files_array[@]} old log files - be patient & thanks for testing armbian-next! 👍" "wrn"
wait_for_disk_sync # for dramatic effect
fi
declare one_old_logfile old_logfile_fn target_archive_path="${target_path}"/archive
for one_old_logfile in "${existing_log_files_array[@]}"; do
old_logfile_fn="$(basename "${one_old_logfile}")"