From 24b77433ba7a83847fda5a75663bf281a0b87c2a Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 26 Jul 2017 11:53:05 -0400 Subject: Use "init.d" and "conf.d" subdirectories of "openrc". OpenRC's init and conf files need to be named the same, and so we hit problems trying to store them both in the "openrc" directory. This commit puts the conf file in a "conf.d" subdirectory and the init script in an "init.d" subdirectory. --- .gitignore | 4 +-- Makefile.am | 8 ++--- configure.ac | 2 +- openrc/conf.d/php-fpm | 8 +++++ openrc/init.d/php-fpm.in.in | 77 +++++++++++++++++++++++++++++++++++++++++++++ openrc/php-fpm.conf | 8 ----- openrc/php-fpm.in.in | 77 --------------------------------------------- 7 files changed, 92 insertions(+), 92 deletions(-) create mode 100644 openrc/conf.d/php-fpm create mode 100644 openrc/init.d/php-fpm.in.in delete mode 100644 openrc/php-fpm.conf delete mode 100644 openrc/php-fpm.in.in diff --git a/.gitignore b/.gitignore index ab72e36..5a461dd 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ autom4te.cache/ config.log config.status configure -openrc/php-fpm -openrc/php-fpm.in +openrc/init.d/php-fpm +openrc/init.d/php-fpm.in install-sh missing src/php.eselect diff --git a/Makefile.am b/Makefile.am index 08359dc..1d3122a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ eselectdir = $(datadir)/eselect/modules nodist_eselect_DATA = $(srcdir)/src/php.eselect # Without EXTRA_DIST, these files don't wind up in the tarball. -EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in openrc/*.* +EXTRA_DIST = $(srcdir)/src/70_mod_php.conf.in openrc if APACHE2 # Without these set, we won't try to install the conf file. @@ -13,10 +13,10 @@ endif if FPM # Same as the APACHE2 conditional. initdir = $(sysconfdir)/init.d - nodist_init_SCRIPTS = $(srcdir)/openrc/php-fpm + nodist_init_SCRIPTS = $(srcdir)/openrc/init.d/php-fpm confdir = $(sysconfdir)/conf.d - nodist_conf_DATA = $(srcdir)/openrc/php-fpm.conf + nodist_conf_DATA = $(srcdir)/openrc/conf.d/php-fpm endif # The next few rules allow us to replace bindir, libdir, etc. @@ -37,4 +37,4 @@ $(nodist_eselect_DATA) $(nodist_apacheconf_DATA) $(nodist_init_SCRIPTS): Makefil $(srcdir)/src/php.eselect: $(srcdir)/src/php.eselect.in $(srcdir)/src/70_mod_php.conf: $(srcdir)/src/70_mod_php.conf.in -$(srcdir)/openrc/php-fpm: $(srcdir)/openrc/php-fpm.in +$(srcdir)/openrc/init.d/php-fpm: $(srcdir)/openrc/init.d/php-fpm.in diff --git a/configure.ac b/configure.ac index 02aeaf2..a55baf8 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,6 @@ AC_ARG_WITH(piddir, AC_HELP_STRING([--with-piddir=DIR], AC_SUBST(piddir) # List of output files. -AC_CONFIG_FILES([Makefile src/php.eselect.in openrc/php-fpm.in]) +AC_CONFIG_FILES([Makefile src/php.eselect.in openrc/init.d/php-fpm.in]) AC_OUTPUT diff --git a/openrc/conf.d/php-fpm b/openrc/conf.d/php-fpm new file mode 100644 index 0000000..b3efdbf --- /dev/null +++ b/openrc/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/openrc/init.d/php-fpm.in.in b/openrc/init.d/php-fpm.in.in new file mode 100644 index 0000000..2eaa2c3 --- /dev/null +++ b/openrc/init.d/php-fpm.in.in @@ -0,0 +1,77 @@ +#!/sbin/openrc-run + +# +# We support both slot-agnostic and slotted versions of the init +# script. The slotted versions would be named something like +# php-fpm-php7.1, and PHP_SLOT below would be set to "php7.1". But we +# also support a general init script named "php-fpm" that uses +# whatever the currently-eselected fpm implementation is. In that +# case, PHP_SLOT winds up set to "php-fpm" and we need to get the +# actual slot by querying eselect. +# +# An open question is, what should we do if the user has both a +# slot-agnostic and slotted init script, which happen to point to the +# same slot? In other words, if the user has a php-fpm init script and +# slot php7.1 eselected, but also a php-fpm-php7.1 init script. Should +# they manage the same instance? I think so... +# +PHP_SLOT="${SVCNAME#php-fpm-}" +if [ "${PHP_SLOT}" = "php-fpm" ] ; then + PHP_SLOT="$(eselect php show fpm)" +fi + +PHP_FPM_CONF="@SYSCONFDIR@/php/fpm-${PHP_SLOT}/php-fpm.conf" + +command="@LIBDIR@/${PHP_SLOT}/bin/php-fpm" +pidfile="@piddir@/php-fpm-${PHP_SLOT}.pid" + +# Force the daemon into the background and make it use our pid file, +# regardless of what the config file says. +command_args="--fpm-config ${PHP_FPM_CONF} --pid ${pidfile} --daemonize" +extra_started_commands="reload" +extra_commands="configtest" + +# Wait five seconds after starting for the pidfile to show up. +start_stop_daemon_args="--wait 5000 ${PHP_FPM_UMASK:+--umask ${PHP_FPM_UMASK}}" + +configtest() { + ebegin "Testing PHP FastCGI Process Manager configuration" + + # 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=$( ${command} ${command_args} --test 2>&1 ) + + # Save this so `echo` doesn't clobber it. + local exit_code=$? + [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2 + eend $exit_code +} + +start_pre() { + # If this isn't a restart, make sure that the user's config isn't + # busted before we try to start the daemon (this will produce + # better error messages than if we just try to start it blindly). + # + # If, on the other hand, this *is* a restart, then the stop_pre + # action will have ensured that the config is usable and we don't + # need to do that again. + if [ "${RC_CMD}" != "restart" ] ; then + configtest || return $? + fi +} + +stop_pre() { + # If this is a restart, check to make sure the user's config + # isn't busted before we stop the running daemon. + if [ "${RC_CMD}" = "restart" ] ; then + configtest || return $? + fi +} + +reload() { + configtest || return $? + ebegin "Reloading PHP FastCGI Process Manager" + start-stop-daemon --signal USR2 --pidfile "${pidfile}" + eend $? +} diff --git a/openrc/php-fpm.conf b/openrc/php-fpm.conf deleted file mode 100644 index b3efdbf..0000000 --- a/openrc/php-fpm.conf +++ /dev/null @@ -1,8 +0,0 @@ -# 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/openrc/php-fpm.in.in b/openrc/php-fpm.in.in deleted file mode 100644 index 2eaa2c3..0000000 --- a/openrc/php-fpm.in.in +++ /dev/null @@ -1,77 +0,0 @@ -#!/sbin/openrc-run - -# -# We support both slot-agnostic and slotted versions of the init -# script. The slotted versions would be named something like -# php-fpm-php7.1, and PHP_SLOT below would be set to "php7.1". But we -# also support a general init script named "php-fpm" that uses -# whatever the currently-eselected fpm implementation is. In that -# case, PHP_SLOT winds up set to "php-fpm" and we need to get the -# actual slot by querying eselect. -# -# An open question is, what should we do if the user has both a -# slot-agnostic and slotted init script, which happen to point to the -# same slot? In other words, if the user has a php-fpm init script and -# slot php7.1 eselected, but also a php-fpm-php7.1 init script. Should -# they manage the same instance? I think so... -# -PHP_SLOT="${SVCNAME#php-fpm-}" -if [ "${PHP_SLOT}" = "php-fpm" ] ; then - PHP_SLOT="$(eselect php show fpm)" -fi - -PHP_FPM_CONF="@SYSCONFDIR@/php/fpm-${PHP_SLOT}/php-fpm.conf" - -command="@LIBDIR@/${PHP_SLOT}/bin/php-fpm" -pidfile="@piddir@/php-fpm-${PHP_SLOT}.pid" - -# Force the daemon into the background and make it use our pid file, -# regardless of what the config file says. -command_args="--fpm-config ${PHP_FPM_CONF} --pid ${pidfile} --daemonize" -extra_started_commands="reload" -extra_commands="configtest" - -# Wait five seconds after starting for the pidfile to show up. -start_stop_daemon_args="--wait 5000 ${PHP_FPM_UMASK:+--umask ${PHP_FPM_UMASK}}" - -configtest() { - ebegin "Testing PHP FastCGI Process Manager configuration" - - # 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=$( ${command} ${command_args} --test 2>&1 ) - - # Save this so `echo` doesn't clobber it. - local exit_code=$? - [ $exit_code -ne 0 ] && echo "${OUTPUT}" >&2 - eend $exit_code -} - -start_pre() { - # If this isn't a restart, make sure that the user's config isn't - # busted before we try to start the daemon (this will produce - # better error messages than if we just try to start it blindly). - # - # If, on the other hand, this *is* a restart, then the stop_pre - # action will have ensured that the config is usable and we don't - # need to do that again. - if [ "${RC_CMD}" != "restart" ] ; then - configtest || return $? - fi -} - -stop_pre() { - # If this is a restart, check to make sure the user's config - # isn't busted before we stop the running daemon. - if [ "${RC_CMD}" = "restart" ] ; then - configtest || return $? - fi -} - -reload() { - configtest || return $? - ebegin "Reloading PHP FastCGI Process Manager" - start-stop-daemon --signal USR2 --pidfile "${pidfile}" - eend $? -} -- cgit v1.2.3-65-gdbad