#!/bin/sh # check-nginx-config.sh - verify nginx conf.active mount is writable when PORT != 20211. # Only check nginx config writability if PORT is not the default 20211 if [ "${PORT:-20211}" = "20211" ]; then exit 0 fi CONF_ACTIVE_DIR="${SYSTEM_SERVICES_ACTIVE_CONFIG}" TARGET_FILE="${CONF_ACTIVE_DIR}/netalertx.conf" # If the directory is missing entirely we warn and exit failure so the caller can see the message. if [ ! -d "${CONF_ACTIVE_DIR}" ]; then YELLOW=$(printf '\033[1;33m') RESET=$(printf '\033[0m') >&2 printf "%s" "${YELLOW}" >&2 cat <&2 printf "%s" "${RESET}" exit 1 fi TMP_FILE="${CONF_ACTIVE_DIR}/.netalertx-write-test" if ! ( : >"${TMP_FILE}" ) 2>/dev/null; then YELLOW=$(printf '\033[1;33m') RESET=$(printf '\033[0m') >&2 printf "%s" "${YELLOW}" >&2 cat <&2 printf "%s" "${RESET}" exit 1 fi rm -f "${TMP_FILE}" exit 0