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:
@@ -9,7 +9,7 @@ set -euo pipefail
|
||||
#### Author: Phil Connor ####
|
||||
#### Contact: contact@mylinux.work ####
|
||||
#### License: MIT ####
|
||||
#### Version: 1.1 ####
|
||||
#### Version: 1.2 ####
|
||||
#### ####
|
||||
#### Usage: ./install-node-exporter.sh [OPTIONS] ####
|
||||
#############################################################
|
||||
@@ -208,7 +208,20 @@ create_service_user() {
|
||||
download_and_install() {
|
||||
local version="$1"
|
||||
|
||||
TMPDIR=$(mktemp -d /tmp/node-exporter-install-XXXXXX)
|
||||
# Detect noexec /tmp — fall back to /usr/local/src
|
||||
local stage_dir="/tmp"
|
||||
local _exec_test
|
||||
_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
|
||||
|
||||
TMPDIR=$(mktemp -d "${stage_dir}/node-exporter-install-XXXXXX")
|
||||
local tarball="node_exporter-${version}.linux-${ARCH}.tar.gz"
|
||||
local url="https://github.com/prometheus/node_exporter/releases/download/v${version}/${tarball}"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user