mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-06-01 13:34:45 +00:00
+27
-10
@@ -252,16 +252,15 @@ header_info
|
|||||||
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# LOGGING SETUP
|
# LOGGING SETUP
|
||||||
# All output is tee'd (ANSI colours stripped) to a timestamped log file under
|
# A timestamped log file is written to
|
||||||
# /usr/local/community-scripts/update_apps/
|
# /usr/local/community-scripts/update_apps/ — the summary report is appended
|
||||||
|
# at the end of the run. Real-time output goes only to the terminal to avoid
|
||||||
|
# buffering issues with interactive spinners.
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
LOG_DIR="/usr/local/community-scripts/update_apps"
|
LOG_DIR="/usr/local/community-scripts/update_apps"
|
||||||
mkdir -p "$LOG_DIR"
|
mkdir -p "$LOG_DIR"
|
||||||
LOG_FILE="${LOG_DIR}/$(date '+%Y%m%d_%H%M%S').log"
|
LOG_FILE="${LOG_DIR}/$(date '+%Y%m%d_%H%M%S').log"
|
||||||
# Redirect stdout+stderr through an ANSI-stripping sed into tee so the
|
echo "Update started: $(date '+%Y-%m-%d %H:%M:%S')" >"$LOG_FILE"
|
||||||
# terminal keeps colours while the log file stays plain text.
|
|
||||||
exec > >(sed 's/\x1B\[[0-9;:]*[mKHfJ]//g' | tee -a "$LOG_FILE") 2>&1
|
|
||||||
echo "Update started: $(date '+%Y-%m-%d %H:%M:%S') — log: $LOG_FILE"
|
|
||||||
|
|
||||||
# Skip confirmation if var_skip_confirm is set to yes
|
# Skip confirmation if var_skip_confirm is set to yes
|
||||||
if [[ "$var_skip_confirm" != "yes" ]]; then
|
if [[ "$var_skip_confirm" != "yes" ]]; then
|
||||||
@@ -579,10 +578,14 @@ echo -e "${GN}The process is complete, and the containers have been successfully
|
|||||||
# SUMMARY REPORT
|
# SUMMARY REPORT
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
if [ "${#UPDATE_RESULTS[@]}" -gt 0 ]; then
|
if [ "${#UPDATE_RESULTS[@]}" -gt 0 ]; then
|
||||||
|
SEPARATOR="━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||||
|
HEADER=$(printf " %-8s %-22s %-10s %s" "CTID" "Service" "Status" "Details")
|
||||||
|
|
||||||
|
# terminal output (with colours)
|
||||||
echo ""
|
echo ""
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "$SEPARATOR"
|
||||||
printf " %-8s %-22s %-10s %s\n" "CTID" "Service" "Status" "Details"
|
echo "$HEADER"
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "$SEPARATOR"
|
||||||
for entry in "${UPDATE_RESULTS[@]}"; do
|
for entry in "${UPDATE_RESULTS[@]}"; do
|
||||||
IFS='|' read -r _ctid _svc _status _details <<<"$entry"
|
IFS='|' read -r _ctid _svc _status _details <<<"$entry"
|
||||||
case "$_status" in
|
case "$_status" in
|
||||||
@@ -593,10 +596,24 @@ if [ "${#UPDATE_RESULTS[@]}" -gt 0 ]; then
|
|||||||
esac
|
esac
|
||||||
printf " %-8s %-22s ${_color}%-10s${CL} %s\n" "$_ctid" "$_svc" "$_status" "$_details"
|
printf " %-8s %-22s ${_color}%-10s${CL} %s\n" "$_ctid" "$_svc" "$_status" "$_details"
|
||||||
done
|
done
|
||||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
echo "$SEPARATOR"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Full log: $LOG_FILE"
|
echo "Full log: $LOG_FILE"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
|
# append plain-text summary to log file
|
||||||
|
{
|
||||||
|
echo ""
|
||||||
|
echo "Update finished: $(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
|
echo "$SEPARATOR"
|
||||||
|
echo "$HEADER"
|
||||||
|
echo "$SEPARATOR"
|
||||||
|
for entry in "${UPDATE_RESULTS[@]}"; do
|
||||||
|
IFS='|' read -r _ctid _svc _status _details <<<"$entry"
|
||||||
|
printf " %-8s %-22s %-10s %s\n" "$_ctid" "$_svc" "$_status" "$_details"
|
||||||
|
done
|
||||||
|
echo "$SEPARATOR"
|
||||||
|
} >>"$LOG_FILE"
|
||||||
fi
|
fi
|
||||||
if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then
|
if [ "${#containers_needing_reboot[@]}" -gt 0 ]; then
|
||||||
echo -e "${RD}The following containers require a reboot:${CL}"
|
echo -e "${RD}The following containers require a reboot:${CL}"
|
||||||
|
|||||||
Reference in New Issue
Block a user