Linux SRV-16 6.18.44-paas #1 SMP PREEMPT_DYNAMIC Thu Aug 13 10:08:12 UTC 2026 x86_64
/
srv
/
admin
/
scripts
/
init.d
/
/srv/admin/scripts/init.d/php-fpm
#!/bin/bash # Enable errexit option: this explains why we almost never check return values. # We want this script to exit (with exitcode > 0) if anything goes wrong. set -e . /lib/start-lib.sh . /srv/admin/scripts/init-lib.sh # check if WWW_ENGINE is not php if [ "${WWW_ENGINE}" != "php" ]; then # bookworm/stretch instances if [ -d '/opt/php-8.3' ]; then export WWW_VERSION=8.3 # jessie instances elif [ -d '/opt/php-7.0' ]; then export WWW_VERSION=7.0 else echo "No suitable PHP version found" exit 1 fi fi PHP_PATH="/opt/php-${WWW_VERSION}" NAME="${0##*/}" [ "$NAME" == "php-admin" ] \ && CONFIG_FILE="/srv/admin/configs/php/${WWW_VERSION}/fpm/php-admin.conf" \ || CONFIG_FILE="$CUSTOMER_DIR/.config/php-${WWW_VERSION}/php-fpm.conf" DAEMON=${PHP_PATH}/sbin/php-fpm DAEMON_ARGS="--fpm-config $CONFIG_FILE" PIDFILE="$LOCAL_DIR/php/fpm.pid" do_setup() { do_as "$PHP_USER" install -g "$APP_USER" -m 2755 -d "$LOCAL_DIR/php" do_as "$SYS_USER" ln -sfn "/srv/admin/configs/php/$WWW_VERSION" "${CUSTOMER_DIR}/.current_www" } do_start() { do_as "$PHP_USER" "$DAEMON" $DAEMON_ARGS wait_for_pidfile created "$PIDFILE" } do_stop() { do_as "$PHP_USER" /sbin/start-stop-daemon \ --pidfile "$PIDFILE" --exec "$DAEMON" --stop --retry 20 } do_reload() { do_as "$PHP_USER" /sbin/start-stop-daemon \ --pidfile "$PIDFILE" --exec "$DAEMON" --stop --signal USR1 } do_status() { do_as "$PHP_USER" /sbin/start-stop-daemon \ --pidfile "$PIDFILE" --exec "$DAEMON" --stop --signal 0 } case "$1" in start) echo "Starting $NAME" do_setup do_start ;; stop) echo "Stopping $NAME" do_stop ;; reload) do_reload ;; status) do_status ;; *) echo "Usage: $0 {start|stop|reload|status}" exit 1 ;; esac