autologin
This commit is contained in:
parent
dd0f7b96f8
commit
4076b7e632
@ -1,48 +1,48 @@
|
|||||||
{
|
{
|
||||||
"name": "Jellystat",
|
"name": "Jellystat",
|
||||||
"slug": "jellystat",
|
"slug": "jellystat",
|
||||||
"categories": [
|
"categories": [
|
||||||
9
|
9
|
||||||
],
|
],
|
||||||
"date_created": "2025-12-08",
|
"date_created": "2025-12-08",
|
||||||
"type": "addon",
|
"type": "addon",
|
||||||
"updateable": true,
|
"updateable": true,
|
||||||
"privileged": false,
|
"privileged": false,
|
||||||
"interface_port": 3000,
|
"interface_port": 3000,
|
||||||
"documentation": "https://github.com/CyferShepard/Jellystat",
|
"documentation": "https://github.com/CyferShepard/Jellystat",
|
||||||
"website": "https://github.com/CyferShepard/Jellystat",
|
"website": "https://github.com/CyferShepard/Jellystat",
|
||||||
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/jellystat.webp",
|
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/jellystat.webp",
|
||||||
"config_path": "/opt/jellystat/.env",
|
"config_path": "/opt/jellystat/.env",
|
||||||
"description": "A free and open source statistics app for Jellyfin",
|
"description": "A free and open source statistics app for Jellyfin",
|
||||||
"install_methods": [
|
"install_methods": [
|
||||||
{
|
{
|
||||||
"type": "default",
|
"type": "default",
|
||||||
"script": "tools/addon/jellystat.sh",
|
"script": "tools/addon/jellystat.sh",
|
||||||
"resources": {
|
"resources": {
|
||||||
"cpu": null,
|
"cpu": null,
|
||||||
"ram": null,
|
"ram": null,
|
||||||
"hdd": null,
|
"hdd": null,
|
||||||
"os": null,
|
"os": null,
|
||||||
"version": null
|
"version": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default_credentials": {
|
"default_credentials": {
|
||||||
"username": null,
|
"username": null,
|
||||||
"password": null
|
"password": null
|
||||||
},
|
|
||||||
"notes": [
|
|
||||||
{
|
|
||||||
"text": "Requires Node.js 20+ and PostgreSQL (auto-installed if missing)",
|
|
||||||
"type": "info"
|
|
||||||
},
|
},
|
||||||
{
|
"notes": [
|
||||||
"text": "Default PostgreSQL credentials: jellystat / jellystat",
|
{
|
||||||
"type": "info"
|
"text": "Requires Node.js 20+ and PostgreSQL (auto-installed if missing)",
|
||||||
},
|
"type": "info"
|
||||||
{
|
},
|
||||||
"text": "Update with: update_jellystat",
|
{
|
||||||
"type": "info"
|
"text": "Default PostgreSQL credentials: jellystat / jellystat",
|
||||||
}
|
"type": "info"
|
||||||
]
|
},
|
||||||
|
{
|
||||||
|
"text": "Update with: update_jellystat",
|
||||||
|
"type": "info"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,86 +40,86 @@
|
|||||||
# - Returns description string for given exit code
|
# - Returns description string for given exit code
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
explain_exit_code() {
|
explain_exit_code() {
|
||||||
local code="$1"
|
local code="$1"
|
||||||
case "$code" in
|
case "$code" in
|
||||||
# --- Generic / Shell ---
|
# --- Generic / Shell ---
|
||||||
1) echo "General error / Operation not permitted" ;;
|
1) echo "General error / Operation not permitted" ;;
|
||||||
2) echo "Misuse of shell builtins (e.g. syntax error)" ;;
|
2) echo "Misuse of shell builtins (e.g. syntax error)" ;;
|
||||||
126) echo "Command invoked cannot execute (permission problem?)" ;;
|
126) echo "Command invoked cannot execute (permission problem?)" ;;
|
||||||
127) echo "Command not found" ;;
|
127) echo "Command not found" ;;
|
||||||
128) echo "Invalid argument to exit" ;;
|
128) echo "Invalid argument to exit" ;;
|
||||||
130) echo "Terminated by Ctrl+C (SIGINT)" ;;
|
130) echo "Terminated by Ctrl+C (SIGINT)" ;;
|
||||||
137) echo "Killed (SIGKILL / Out of memory?)" ;;
|
137) echo "Killed (SIGKILL / Out of memory?)" ;;
|
||||||
139) echo "Segmentation fault (core dumped)" ;;
|
139) echo "Segmentation fault (core dumped)" ;;
|
||||||
143) echo "Terminated (SIGTERM)" ;;
|
143) echo "Terminated (SIGTERM)" ;;
|
||||||
|
|
||||||
# --- Package manager / APT / DPKG ---
|
# --- Package manager / APT / DPKG ---
|
||||||
100) echo "APT: Package manager error (broken packages / dependency problems)" ;;
|
100) echo "APT: Package manager error (broken packages / dependency problems)" ;;
|
||||||
101) echo "APT: Configuration error (bad sources.list, malformed config)" ;;
|
101) echo "APT: Configuration error (bad sources.list, malformed config)" ;;
|
||||||
255) echo "DPKG: Fatal internal error" ;;
|
255) echo "DPKG: Fatal internal error" ;;
|
||||||
|
|
||||||
# --- Node.js / npm / pnpm / yarn ---
|
# --- Node.js / npm / pnpm / yarn ---
|
||||||
243) echo "Node.js: Out of memory (JavaScript heap out of memory)" ;;
|
243) echo "Node.js: Out of memory (JavaScript heap out of memory)" ;;
|
||||||
245) echo "Node.js: Invalid command-line option" ;;
|
245) echo "Node.js: Invalid command-line option" ;;
|
||||||
246) echo "Node.js: Internal JavaScript Parse Error" ;;
|
246) echo "Node.js: Internal JavaScript Parse Error" ;;
|
||||||
247) echo "Node.js: Fatal internal error" ;;
|
247) echo "Node.js: Fatal internal error" ;;
|
||||||
248) echo "Node.js: Invalid C++ addon / N-API failure" ;;
|
248) echo "Node.js: Invalid C++ addon / N-API failure" ;;
|
||||||
249) echo "Node.js: Inspector error" ;;
|
249) echo "Node.js: Inspector error" ;;
|
||||||
254) echo "npm/pnpm/yarn: Unknown fatal error" ;;
|
254) echo "npm/pnpm/yarn: Unknown fatal error" ;;
|
||||||
|
|
||||||
# --- Python / pip / uv ---
|
# --- Python / pip / uv ---
|
||||||
210) echo "Python: Virtualenv / uv environment missing or broken" ;;
|
210) echo "Python: Virtualenv / uv environment missing or broken" ;;
|
||||||
211) echo "Python: Dependency resolution failed" ;;
|
211) echo "Python: Dependency resolution failed" ;;
|
||||||
212) echo "Python: Installation aborted (permissions or EXTERNALLY-MANAGED)" ;;
|
212) echo "Python: Installation aborted (permissions or EXTERNALLY-MANAGED)" ;;
|
||||||
|
|
||||||
# --- PostgreSQL ---
|
# --- PostgreSQL ---
|
||||||
231) echo "PostgreSQL: Connection failed (server not running / wrong socket)" ;;
|
231) echo "PostgreSQL: Connection failed (server not running / wrong socket)" ;;
|
||||||
232) echo "PostgreSQL: Authentication failed (bad user/password)" ;;
|
232) echo "PostgreSQL: Authentication failed (bad user/password)" ;;
|
||||||
233) echo "PostgreSQL: Database does not exist" ;;
|
233) echo "PostgreSQL: Database does not exist" ;;
|
||||||
234) echo "PostgreSQL: Fatal error in query / syntax" ;;
|
234) echo "PostgreSQL: Fatal error in query / syntax" ;;
|
||||||
|
|
||||||
# --- MySQL / MariaDB ---
|
# --- MySQL / MariaDB ---
|
||||||
241) echo "MySQL/MariaDB: Connection failed (server not running / wrong socket)" ;;
|
241) echo "MySQL/MariaDB: Connection failed (server not running / wrong socket)" ;;
|
||||||
242) echo "MySQL/MariaDB: Authentication failed (bad user/password)" ;;
|
242) echo "MySQL/MariaDB: Authentication failed (bad user/password)" ;;
|
||||||
243) echo "MySQL/MariaDB: Database does not exist" ;;
|
243) echo "MySQL/MariaDB: Database does not exist" ;;
|
||||||
244) echo "MySQL/MariaDB: Fatal error in query / syntax" ;;
|
244) echo "MySQL/MariaDB: Fatal error in query / syntax" ;;
|
||||||
|
|
||||||
# --- MongoDB ---
|
# --- MongoDB ---
|
||||||
251) echo "MongoDB: Connection failed (server not running)" ;;
|
251) echo "MongoDB: Connection failed (server not running)" ;;
|
||||||
252) echo "MongoDB: Authentication failed (bad user/password)" ;;
|
252) echo "MongoDB: Authentication failed (bad user/password)" ;;
|
||||||
253) echo "MongoDB: Database not found" ;;
|
253) echo "MongoDB: Database not found" ;;
|
||||||
254) echo "MongoDB: Fatal query error" ;;
|
254) echo "MongoDB: Fatal query error" ;;
|
||||||
|
|
||||||
# --- Proxmox Custom Codes ---
|
# --- Proxmox Custom Codes ---
|
||||||
200) echo "Proxmox: Failed to create lock file" ;;
|
200) echo "Proxmox: Failed to create lock file" ;;
|
||||||
203) echo "Proxmox: Missing CTID variable" ;;
|
203) echo "Proxmox: Missing CTID variable" ;;
|
||||||
204) echo "Proxmox: Missing PCT_OSTYPE variable" ;;
|
204) echo "Proxmox: Missing PCT_OSTYPE variable" ;;
|
||||||
205) echo "Proxmox: Invalid CTID (<100)" ;;
|
205) echo "Proxmox: Invalid CTID (<100)" ;;
|
||||||
206) echo "Proxmox: CTID already in use" ;;
|
206) echo "Proxmox: CTID already in use" ;;
|
||||||
207) echo "Proxmox: Password contains unescaped special characters" ;;
|
207) echo "Proxmox: Password contains unescaped special characters" ;;
|
||||||
208) echo "Proxmox: Invalid configuration (DNS/MAC/Network format)" ;;
|
208) echo "Proxmox: Invalid configuration (DNS/MAC/Network format)" ;;
|
||||||
209) echo "Proxmox: Container creation failed" ;;
|
209) echo "Proxmox: Container creation failed" ;;
|
||||||
210) echo "Proxmox: Cluster not quorate" ;;
|
210) echo "Proxmox: Cluster not quorate" ;;
|
||||||
211) echo "Proxmox: Timeout waiting for template lock" ;;
|
211) echo "Proxmox: Timeout waiting for template lock" ;;
|
||||||
212) echo "Proxmox: Storage type 'iscsidirect' does not support containers (VMs only)" ;;
|
212) echo "Proxmox: Storage type 'iscsidirect' does not support containers (VMs only)" ;;
|
||||||
213) echo "Proxmox: Storage type does not support 'rootdir' content" ;;
|
213) echo "Proxmox: Storage type does not support 'rootdir' content" ;;
|
||||||
214) echo "Proxmox: Not enough storage space" ;;
|
214) echo "Proxmox: Not enough storage space" ;;
|
||||||
215) echo "Proxmox: Container created but not listed (ghost state)" ;;
|
215) echo "Proxmox: Container created but not listed (ghost state)" ;;
|
||||||
216) echo "Proxmox: RootFS entry missing in config" ;;
|
216) echo "Proxmox: RootFS entry missing in config" ;;
|
||||||
217) echo "Proxmox: Storage not accessible" ;;
|
217) echo "Proxmox: Storage not accessible" ;;
|
||||||
219) echo "Proxmox: CephFS does not support containers - use RBD" ;;
|
219) echo "Proxmox: CephFS does not support containers - use RBD" ;;
|
||||||
224) echo "Proxmox: PBS storage is for backups only" ;;
|
224) echo "Proxmox: PBS storage is for backups only" ;;
|
||||||
218) echo "Proxmox: Template file corrupted or incomplete" ;;
|
218) echo "Proxmox: Template file corrupted or incomplete" ;;
|
||||||
220) echo "Proxmox: Unable to resolve template path" ;;
|
220) echo "Proxmox: Unable to resolve template path" ;;
|
||||||
221) echo "Proxmox: Template file not readable" ;;
|
221) echo "Proxmox: Template file not readable" ;;
|
||||||
222) echo "Proxmox: Template download failed" ;;
|
222) echo "Proxmox: Template download failed" ;;
|
||||||
223) echo "Proxmox: Template not available after download" ;;
|
223) echo "Proxmox: Template not available after download" ;;
|
||||||
225) echo "Proxmox: No template available for OS/Version" ;;
|
225) echo "Proxmox: No template available for OS/Version" ;;
|
||||||
231) echo "Proxmox: LXC stack upgrade failed" ;;
|
231) echo "Proxmox: LXC stack upgrade failed" ;;
|
||||||
|
|
||||||
# --- Default ---
|
# --- Default ---
|
||||||
*) echo "Unknown error" ;;
|
*) echo "Unknown error" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@ -143,105 +143,105 @@ explain_exit_code() {
|
|||||||
# * Exits with original exit code
|
# * Exits with original exit code
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
error_handler() {
|
error_handler() {
|
||||||
local exit_code=${1:-$?}
|
local exit_code=${1:-$?}
|
||||||
local command=${2:-${BASH_COMMAND:-unknown}}
|
local command=${2:-${BASH_COMMAND:-unknown}}
|
||||||
local line_number=${BASH_LINENO[0]:-unknown}
|
local line_number=${BASH_LINENO[0]:-unknown}
|
||||||
|
|
||||||
command="${command//\$STD/}"
|
command="${command//\$STD/}"
|
||||||
|
|
||||||
if [[ "$exit_code" -eq 0 ]]; then
|
if [[ "$exit_code" -eq 0 ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local explanation
|
local explanation
|
||||||
explanation="$(explain_exit_code "$exit_code")"
|
explanation="$(explain_exit_code "$exit_code")"
|
||||||
|
|
||||||
printf "\e[?25h"
|
printf "\e[?25h"
|
||||||
|
|
||||||
# Use msg_error if available, fallback to echo
|
# Use msg_error if available, fallback to echo
|
||||||
if declare -f msg_error >/dev/null 2>&1; then
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
msg_error "in line ${line_number}: exit code ${exit_code} (${explanation}): while executing command ${command}"
|
msg_error "in line ${line_number}: exit code ${exit_code} (${explanation}): while executing command ${command}"
|
||||||
|
else
|
||||||
|
echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YWB}${command}${CL}\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${DEBUG_LOGFILE:-}" ]]; then
|
||||||
|
{
|
||||||
|
echo "------ ERROR ------"
|
||||||
|
echo "Timestamp : $(date '+%Y-%m-%d %H:%M:%S')"
|
||||||
|
echo "Exit Code : $exit_code ($explanation)"
|
||||||
|
echo "Line : $line_number"
|
||||||
|
echo "Command : $command"
|
||||||
|
echo "-------------------"
|
||||||
|
} >>"$DEBUG_LOGFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get active log file (BUILD_LOG or INSTALL_LOG)
|
||||||
|
local active_log=""
|
||||||
|
if declare -f get_active_logfile >/dev/null 2>&1; then
|
||||||
|
active_log="$(get_active_logfile)"
|
||||||
|
elif [[ -n "${SILENT_LOGFILE:-}" ]]; then
|
||||||
|
active_log="$SILENT_LOGFILE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$active_log" && -s "$active_log" ]]; then
|
||||||
|
echo "--- Last 20 lines of silent log ---"
|
||||||
|
tail -n 20 "$active_log"
|
||||||
|
echo "-----------------------------------"
|
||||||
|
|
||||||
|
# Detect context: Container (INSTALL_LOG set + /root exists) vs Host (BUILD_LOG)
|
||||||
|
if [[ -n "${INSTALL_LOG:-}" && -d /root ]]; then
|
||||||
|
# CONTAINER CONTEXT: Copy log and create flag file for host
|
||||||
|
local container_log="/root/.install-${SESSION_ID:-error}.log"
|
||||||
|
cp "$active_log" "$container_log" 2>/dev/null || true
|
||||||
|
|
||||||
|
# Create error flag file with exit code for host detection
|
||||||
|
echo "$exit_code" >"/root/.install-${SESSION_ID:-error}.failed" 2>/dev/null || true
|
||||||
|
|
||||||
|
if declare -f msg_custom >/dev/null 2>&1; then
|
||||||
|
msg_custom "📋" "${YW}" "Log saved to: ${container_log}"
|
||||||
|
else
|
||||||
|
echo -e "${YW}Log saved to:${CL} ${BL}${container_log}${CL}"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo -e "\n${RD}[ERROR]${CL} in line ${RD}${line_number}${CL}: exit code ${RD}${exit_code}${CL} (${explanation}): while executing command ${YWB}${command}${CL}\n"
|
# HOST CONTEXT: Show local log path and offer container cleanup
|
||||||
fi
|
if declare -f msg_custom >/dev/null 2>&1; then
|
||||||
|
msg_custom "📋" "${YW}" "Full log: ${active_log}"
|
||||||
|
else
|
||||||
|
echo -e "${YW}Full log:${CL} ${BL}${active_log}${CL}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -n "${DEBUG_LOGFILE:-}" ]]; then
|
# Offer to remove container if it exists (build errors after container creation)
|
||||||
{
|
if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null && pct status "$CTID" &>/dev/null; then
|
||||||
echo "------ ERROR ------"
|
# Report failure to API before container cleanup
|
||||||
echo "Timestamp : $(date '+%Y-%m-%d %H:%M:%S')"
|
if declare -f post_update_to_api &>/dev/null; then
|
||||||
echo "Exit Code : $exit_code ($explanation)"
|
post_update_to_api "failed" "$exit_code"
|
||||||
echo "Line : $line_number"
|
|
||||||
echo "Command : $command"
|
|
||||||
echo "-------------------"
|
|
||||||
} >>"$DEBUG_LOGFILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Get active log file (BUILD_LOG or INSTALL_LOG)
|
|
||||||
local active_log=""
|
|
||||||
if declare -f get_active_logfile >/dev/null 2>&1; then
|
|
||||||
active_log="$(get_active_logfile)"
|
|
||||||
elif [[ -n "${SILENT_LOGFILE:-}" ]]; then
|
|
||||||
active_log="$SILENT_LOGFILE"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "$active_log" && -s "$active_log" ]]; then
|
|
||||||
echo "--- Last 20 lines of silent log ---"
|
|
||||||
tail -n 20 "$active_log"
|
|
||||||
echo "-----------------------------------"
|
|
||||||
|
|
||||||
# Detect context: Container (INSTALL_LOG set + /root exists) vs Host (BUILD_LOG)
|
|
||||||
if [[ -n "${INSTALL_LOG:-}" && -d /root ]]; then
|
|
||||||
# CONTAINER CONTEXT: Copy log and create flag file for host
|
|
||||||
local container_log="/root/.install-${SESSION_ID:-error}.log"
|
|
||||||
cp "$active_log" "$container_log" 2>/dev/null || true
|
|
||||||
|
|
||||||
# Create error flag file with exit code for host detection
|
|
||||||
echo "$exit_code" >"/root/.install-${SESSION_ID:-error}.failed" 2>/dev/null || true
|
|
||||||
|
|
||||||
if declare -f msg_custom >/dev/null 2>&1; then
|
|
||||||
msg_custom "📋" "${YW}" "Log saved to: ${container_log}"
|
|
||||||
else
|
|
||||||
echo -e "${YW}Log saved to:${CL} ${BL}${container_log}${CL}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# HOST CONTEXT: Show local log path and offer container cleanup
|
|
||||||
if declare -f msg_custom >/dev/null 2>&1; then
|
|
||||||
msg_custom "📋" "${YW}" "Full log: ${active_log}"
|
|
||||||
else
|
|
||||||
echo -e "${YW}Full log:${CL} ${BL}${active_log}${CL}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Offer to remove container if it exists (build errors after container creation)
|
|
||||||
if [[ -n "${CTID:-}" ]] && command -v pct &>/dev/null && pct status "$CTID" &>/dev/null; then
|
|
||||||
# Report failure to API before container cleanup
|
|
||||||
if declare -f post_update_to_api &>/dev/null; then
|
|
||||||
post_update_to_api "failed" "$exit_code"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
echo -en "${YW}Remove broken container ${CTID}? (Y/n) [auto-remove in 60s]: ${CL}"
|
|
||||||
|
|
||||||
if read -t 60 -r response; then
|
|
||||||
if [[ -z "$response" || "$response" =~ ^[Yy]$ ]]; then
|
|
||||||
echo -e "\n${YW}Removing container ${CTID}${CL}"
|
|
||||||
pct stop "$CTID" &>/dev/null || true
|
|
||||||
pct destroy "$CTID" &>/dev/null || true
|
|
||||||
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
|
||||||
elif [[ "$response" =~ ^[Nn]$ ]]; then
|
|
||||||
echo -e "\n${YW}Container ${CTID} kept for debugging${CL}"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
# Timeout - auto-remove
|
|
||||||
echo -e "\n${YW}No response - auto-removing container${CL}"
|
|
||||||
pct stop "$CTID" &>/dev/null || true
|
|
||||||
pct destroy "$CTID" &>/dev/null || true
|
|
||||||
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
exit "$exit_code"
|
echo ""
|
||||||
|
echo -en "${YW}Remove broken container ${CTID}? (Y/n) [auto-remove in 60s]: ${CL}"
|
||||||
|
|
||||||
|
if read -t 60 -r response; then
|
||||||
|
if [[ -z "$response" || "$response" =~ ^[Yy]$ ]]; then
|
||||||
|
echo -e "\n${YW}Removing container ${CTID}${CL}"
|
||||||
|
pct stop "$CTID" &>/dev/null || true
|
||||||
|
pct destroy "$CTID" &>/dev/null || true
|
||||||
|
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
||||||
|
elif [[ "$response" =~ ^[Nn]$ ]]; then
|
||||||
|
echo -e "\n${YW}Container ${CTID} kept for debugging${CL}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Timeout - auto-remove
|
||||||
|
echo -e "\n${YW}No response - auto-removing container${CL}"
|
||||||
|
pct stop "$CTID" &>/dev/null || true
|
||||||
|
pct destroy "$CTID" &>/dev/null || true
|
||||||
|
echo -e "${GN}✔${CL} Container ${CTID} removed"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit "$exit_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@ -257,9 +257,9 @@ error_handler() {
|
|||||||
# - Always runs on script termination (success or failure)
|
# - Always runs on script termination (success or failure)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
on_exit() {
|
on_exit() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
[[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile"
|
[[ -n "${lockfile:-}" && -e "$lockfile" ]] && rm -f "$lockfile"
|
||||||
exit "$exit_code"
|
exit "$exit_code"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -270,12 +270,12 @@ on_exit() {
|
|||||||
# - Exits with code 130 (128 + SIGINT=2)
|
# - Exits with code 130 (128 + SIGINT=2)
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
on_interrupt() {
|
on_interrupt() {
|
||||||
if declare -f msg_error >/dev/null 2>&1; then
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
msg_error "Interrupted by user (SIGINT)"
|
msg_error "Interrupted by user (SIGINT)"
|
||||||
else
|
else
|
||||||
echo -e "\n${RD}Interrupted by user (SIGINT)${CL}"
|
echo -e "\n${RD}Interrupted by user (SIGINT)${CL}"
|
||||||
fi
|
fi
|
||||||
exit 130
|
exit 130
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
@ -287,12 +287,12 @@ on_interrupt() {
|
|||||||
# - Triggered by external process termination
|
# - Triggered by external process termination
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
on_terminate() {
|
on_terminate() {
|
||||||
if declare -f msg_error >/dev/null 2>&1; then
|
if declare -f msg_error >/dev/null 2>&1; then
|
||||||
msg_error "Terminated by signal (SIGTERM)"
|
msg_error "Terminated by signal (SIGTERM)"
|
||||||
else
|
else
|
||||||
echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}"
|
echo -e "\n${RD}Terminated by signal (SIGTERM)${CL}"
|
||||||
fi
|
fi
|
||||||
exit 143
|
exit 143
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
@ -315,13 +315,13 @@ on_terminate() {
|
|||||||
# - Call this function early in every script
|
# - Call this function early in every script
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
catch_errors() {
|
catch_errors() {
|
||||||
set -Ee -o pipefail
|
set -Ee -o pipefail
|
||||||
if [ "${STRICT_UNSET:-0}" = "1" ]; then
|
if [ "${STRICT_UNSET:-0}" = "1" ]; then
|
||||||
set -u
|
set -u
|
||||||
fi
|
fi
|
||||||
|
|
||||||
trap 'error_handler' ERR
|
trap 'error_handler' ERR
|
||||||
trap on_exit EXIT
|
trap on_exit EXIT
|
||||||
trap on_interrupt INT
|
trap on_interrupt INT
|
||||||
trap on_terminate TERM
|
trap on_terminate TERM
|
||||||
}
|
}
|
||||||
|
|||||||
@ -882,6 +882,11 @@ ExecStart=
|
|||||||
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 $TERM
|
ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 $TERM
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Reload systemd and restart getty services to apply auto-login
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl restart console-getty.service &>/dev/null || true
|
||||||
|
systemctl restart container-getty@1.service &>/dev/null || true
|
||||||
;;
|
;;
|
||||||
|
|
||||||
openrc)
|
openrc)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user