Add noexec /tmp detection — fall back to /usr/local/src for staging
Lint Scripts / powershell-lint (push) Failing after 13m25s
Lint Scripts / shellcheck (push) Failing after 17m44s

Scripts auto-detect noexec /tmp by attempting to execute a test script.
If /tmp is noexec, staging directory falls back to /usr/local/src.
Supports mixed fleets with both noexec and standard /tmp mounts.

Updated: deploy-exporter (1.1), install-node-exporter (1.2),
install-prometheus-stack (3.2), update-prometheus-stack (1.02),
install-snort (1.02), install-ntfy-server (1.1), install-bot-monitor (1.2)
This commit is contained in:
2026-05-26 16:16:33 +02:00
parent 166e07085a
commit d0d51be49a
7 changed files with 127 additions and 42 deletions
+15 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash
################################################################################
# Script Name: deploy-exporter.sh
# Version: 1.0
# Version: 1.1
# Description: Deployment tool for Prometheus exporters from mylinux.work.
# Downloads, installs, configures cron jobs, validates output,
# and manages lifecycle (install, update, remove, status) for
@@ -38,6 +38,18 @@ INSTALL_DIR="/usr/local/bin"
CRON_DIR="/etc/cron.d"
TEXTFILE_DIR="/var/lib/node_exporter"
# Detect noexec /tmp — fall back to /usr/local/src for staging
STAGE_DIR="/tmp"
_exec_test=$(mktemp /tmp/.exec_test.XXXXXX 2>/dev/null)
if [[ -n "$_exec_test" ]]; then
printf '#!/bin/sh\nexit 0\n' > "$_exec_test"
chmod +x "$_exec_test"
"$_exec_test" 2>/dev/null || STAGE_DIR="/usr/local/src"
rm -f "$_exec_test"
else
STAGE_DIR="/usr/local/src"
fi
# ============================================================================
# AVAILABLE EXPORTERS
# ============================================================================
@@ -328,7 +340,7 @@ install_one() {
log "Installing ${name}..."
temp_file=$(mktemp "/tmp/${name}.XXXXXX")
temp_file=$(mktemp "${STAGE_DIR}/${name}.XXXXXX")
if ! download "$url" "$temp_file"; then
rm -f "$temp_file"
err "Failed to download ${url}"
@@ -503,7 +515,7 @@ cmd_update() {
local url="${BASE_URL}/${name}.sh"
local temp_file
temp_file=$(mktemp "/tmp/${name}.XXXXXX")
temp_file=$(mktemp "${STAGE_DIR}/${name}.XXXXXX")
if ! download "$url" "$temp_file"; then
rm -f "$temp_file"