From: Frank Brehm Date: Wed, 21 Dec 2016 12:25:23 +0000 (+0100) Subject: saving uncommitted changes in /etc prior to emerge run X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=7a99935c986decf16112855a5917a671859bb285;p=config%2Fberta%2Fetc.git saving uncommitted changes in /etc prior to emerge run --- diff --git a/.etckeeper b/.etckeeper index 3dab2c2..c3bc882 100755 --- a/.etckeeper +++ b/.etckeeper @@ -111,6 +111,7 @@ maybe chmod 0644 'conf.d/modules' maybe chmod 0644 'conf.d/net-online' maybe chmod 0644 'conf.d/netmount' maybe chmod 0644 'conf.d/pciparm' +maybe chmod 0644 'conf.d/php-fpm' maybe chmod 0644 'conf.d/pydoc-2.7' maybe chmod 0644 'conf.d/pydoc-3.4' maybe chmod 0644 'conf.d/rarpd' @@ -357,6 +358,7 @@ maybe chmod 0755 'init.d/netmount' maybe chmod 0755 'init.d/numlock' maybe chmod 0755 'init.d/osclock' maybe chmod 0755 'init.d/pciparm' +maybe chmod 0755 'init.d/php-fpm' maybe chmod 0755 'init.d/procfs' maybe chmod 0755 'init.d/pydoc-2.7' maybe chmod 0755 'init.d/pydoc-3.4' diff --git a/conf.d/php-fpm b/conf.d/php-fpm new file mode 100644 index 0000000..b3efdbf --- /dev/null +++ b/conf.d/php-fpm @@ -0,0 +1,8 @@ +# The OpenRC conf.d file that accompanies the php-fpm init script. +# Not to be confused with the php-fpm.conf file that ships with +# PHP itself. + +# Set the umask of the FPM process to the given (octal) value. This is +# passed directly to start-stop-daemon. If not specified, the system +# default will be used. +#PHP_FPM_UMASK=0002 diff --git a/init.d/php-fpm b/init.d/php-fpm new file mode 100755 index 0000000..6369e9f --- /dev/null +++ b/init.d/php-fpm @@ -0,0 +1,71 @@ +#!/sbin/openrc-run + +extra_started_commands="reload" +extra_commands="configtest" + +set_phpvars() { + PHPSLOT="${SVCNAME#php-fpm-}" + PHP_FPM_PID="/run/php-fpm-${PHPSLOT}.pid" + if [ "${PHPSLOT}" = "php-fpm" ] ; then + PHPSLOT="$(eselect php show fpm)" + PHP_FPM_PID="/run/php-fpm.pid" + fi + + PHP_FPM_CONF="/etc/php/fpm-${PHPSLOT}/php-fpm.conf" + PHP_FPM_BIN="/usr/lib/${PHPSLOT}/bin/php-fpm" +} + +start() { + # If configtest fails, we don't have to sit around for five + # seconds waiting for a pid to show up. + configtest || return $? + ebegin "Starting PHP FastCGI Process Manager" + set_phpvars + start-stop-daemon --start --pidfile "${PHP_FPM_PID}" \ + --exec "${PHP_FPM_BIN}" \ + ${PHP_FPM_UMASK:+--umask ${PHP_FPM_UMASK}} \ + -- \ + --fpm-config "${PHP_FPM_CONF}" \ + --pid "${PHP_FPM_PID}" + local i=0 + local timeout=5 + while [ ! -f "${PHP_FPM_PID}" ] && [ $i -le $timeout ]; do + sleep 1 + i=$(($i + 1)) + done + + [ $timeout -gt $i ] + eend $? +} + +stop() { + ebegin "Stopping PHP FastCGI Process Manager" + set_phpvars + start-stop-daemon --signal QUIT \ + --stop \ + --exec "${PHP_FPM_BIN}" \ + --pidfile "${PHP_FPM_PID}" + eend $? +} + +reload() { + configtest || return $? + ebegin "Reloading PHP FastCGI Process Manager" + set_phpvars + [ -f "${PHP_FPM_PID}" ] && kill -USR2 $(cat "${PHP_FPM_PID}") + eend $? +} + +configtest() { + ebegin "Testing PHP FastCGI Process Manager configuration" + set_phpvars + # Hide the "test is successful" message (which goes to stderr) if + # the test passed, but show the entire output if the test failed + # because it may contain hints about the problem. + OUTPUT=$( "${PHP_FPM_BIN}" --fpm-config "${PHP_FPM_CONF}" --test 2>&1 ) + + # Save this so `echo` doesn't clobber it. + local exit_code=$? + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2 + eend $exit_code +}