Add noexec /tmp detection — fall back to /usr/local/src for staging
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:
+15
-3
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user