OwlCyberSecurity - MANAGER
Edit File: run-userini-parser.sh
#!/bin/bash # # This script runs the userini-parser and compares the parsed configs with the existing ones # set -eu PARSER="/usr/local/bin/userini-parser" USER_INI_FILE_NAME=".user.ini" # check if USER_INI_OUTPUT_DIR is set if [[ -z "${USER_INI_OUTPUT_DIR:-}" ]]; then echo "USER_INI_OUTPUT_DIR is not set" exit 1 fi USER_INI_FILE="${USER_INI_OUTPUT_DIR}/${USER_INI_FILE_NAME}" USER_INI_FILE_BAK="${USER_INI_OUTPUT_DIR}/${USER_INI_FILE_NAME}.bak" # look for existing parsed configs if any, and backup if [[ -f $USER_INI_FILE ]]; then mv -f $USER_INI_FILE $USER_INI_FILE_BAK fi # run the parser if [[ -x ${PARSER} ]]; then echo "Running ${PARSER}" ${PARSER} else echo "${PARSER} does not exist or is not executable" exit 2 fi # compare the parsed configs with the existing ones if [[ -f $USER_INI_FILE ]]; then if [[ -f $USER_INI_FILE_BAK ]]; then if cmp -s "$USER_INI_FILE" "$USER_INI_FILE_BAK"; then echo "The files ${USER_INI_FILE} and ${USER_INI_FILE_BAK} match" rm -f $USER_INI_FILE_BAK exit 4 else echo "The files ${USER_INI_FILE} and ${USER_INI_FILE_BAK} are different" # Reload PHP-FPM to pick up the new configuration if [[ -f /alloc/tmp/php-fpm.pid ]]; then echo "Reloading PHP-FPM configuration..." kill -SIGUSR2 $(cat /alloc/tmp/php-fpm.pid) echo "PHP-FPM reload signal sent" else echo "Warning: /alloc/tmp/php-fpm.pid not found, cannot reload PHP-FPM" fi fi rm -f $USER_INI_FILE_BAK else echo "The backup file does not exist" fi else echo "The parsed file does not exist" fi exit 0