feat: add Postiz app, fix silent() for || fallbacks

This commit is contained in:
MickLesk
2026-02-22 17:46:38 +01:00
parent 286b148911
commit 155c0a00e4
6 changed files with 332 additions and 52 deletions

View File

@@ -480,21 +480,20 @@ log_section() {
# silent()
#
# - Executes command with output redirected to active log file
# - On error: displays last 10 lines of log and exits with original exit code
# - On error: returns the exit code (does NOT exit) so || fallbacks work
# - When no || fallback is present, set -e / ERR trap (error_handler) will
# catch the non-zero return and handle error reporting + script termination
# - Temporarily disables error trap to capture exit code correctly
# - Sources explain_exit_code() for detailed error messages
# ------------------------------------------------------------------------------
silent() {
local cmd="$*"
local caller_line="${BASH_LINENO[0]:-unknown}"
local logfile="$(get_active_logfile)"
# Dryrun mode: Show command without executing
if [[ "${DEV_MODE_DRYRUN:-false}" == "true" ]]; then
if declare -f msg_custom >/dev/null 2>&1; then
msg_custom "🔍" "${BL}" "[DRYRUN] $cmd"
msg_custom "🔍" "${BL}" "[DRYRUN] $*"
else
echo "[DRYRUN] $cmd" >&2
echo "[DRYRUN] $*" >&2
fi
return 0
fi
@@ -508,33 +507,7 @@ silent() {
set -Eeuo pipefail
trap 'error_handler' ERR
if [[ $rc -ne 0 ]]; then
# Source explain_exit_code if needed
if ! declare -f explain_exit_code >/dev/null 2>&1; then
source <(curl -fsSL "$COMMUNITY_SCRIPTS_URL/misc/error_handler.func")
fi
local explanation
explanation="$(explain_exit_code "$rc")"
printf "\e[?25h"
msg_error "in line ${caller_line}: exit code ${rc} (${explanation})"
msg_custom "→" "${YWB}" "${cmd}"
if [[ -s "$logfile" ]]; then
local log_lines=$(wc -l <"$logfile")
echo "--- Last 10 lines of silent log ---"
tail -n 10 "$logfile"
echo "-----------------------------------"
# Show how to view full log if there are more lines
if [[ $log_lines -gt 10 ]]; then
msg_custom "📋" "${YW}" "View full log (${log_lines} lines): ${logfile}"
fi
fi
exit "$rc"
fi
return "$rc"
}
# ------------------------------------------------------------------------------