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
+19 -7
View File
@@ -7,7 +7,7 @@
#### Author: Phil Connor ####
#### Contact: contact@mylinux.work ####
#### License: MIT ####
#### Version: 1.0 ####
#### Version: 1.1 ####
#### ####
#### Usage: sudo ./install-ntfy-server.sh ####
#############################################################
@@ -28,6 +28,18 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# Detect noexec /tmp — fall back to /usr/local/src
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
echo "=== Installing ntfy v${NTFY_VERSION} ==="
# Create ntfy user
@@ -43,13 +55,13 @@ chown "$NTFY_USER:$NTFY_USER" "$NTFY_DIR"
# Download and install ntfy
echo "Downloading ntfy..."
rm -rf /tmp/ntfy_extract
mkdir -p /tmp/ntfy_extract
wget -q -O /tmp/ntfy.tar.gz "https://github.com/binwiederhier/ntfy/releases/download/v${NTFY_VERSION}/ntfy_${NTFY_VERSION}_linux_amd64.tar.gz"
tar -xzf /tmp/ntfy.tar.gz -C /tmp/ntfy_extract
find /tmp/ntfy_extract -name "ntfy" -type f -exec mv {} /usr/local/bin/ntfy \;
rm -rf ${STAGE_DIR}/ntfy_extract
mkdir -p ${STAGE_DIR}/ntfy_extract
wget -q -O ${STAGE_DIR}/ntfy.tar.gz "https://github.com/binwiederhier/ntfy/releases/download/v${NTFY_VERSION}/ntfy_${NTFY_VERSION}_linux_amd64.tar.gz"
tar -xzf ${STAGE_DIR}/ntfy.tar.gz -C ${STAGE_DIR}/ntfy_extract
find ${STAGE_DIR}/ntfy_extract -name "ntfy" -type f -exec mv {} /usr/local/bin/ntfy \;
chmod +x /usr/local/bin/ntfy
rm -rf /tmp/ntfy.tar.gz /tmp/ntfy_extract
rm -rf ${STAGE_DIR}/ntfy.tar.gz ${STAGE_DIR}/ntfy_extract
# Verify installation
echo "Verifying installation..."