apache init script
PATCH 2/2 apache init script
This patches and installs the included init script. The script mostly works, but could use a little more editing.
--- package/apache/0003-init-script.patch | 56 +++++++++++++++++++++++++++++++++++ package/apache/apache.mk | 6 ++++ 2 files changed, 62 insertions(+) create mode 100644 package/apache/0003-init-script.patch
package/apache/0003-init-script.patch new file +56 -0
@@ -0,0 +1,56 @@ +--- apache-2.4.29/build/rpm/httpd.init.orig 2018-02-26 01:04:07.243097556 -0800 ++++ apache-2.4.29/build/rpm/httpd.init 2018-02-26 01:50:18.311683909 -0800 +@@ -22,7 +22,7 @@ + # description: The Apache HTTP Server is an efficient and extensible \ + # server implementing the current HTTP standards. + # processname: httpd +-# pidfile: /var/run/httpd.pid ++# pidfile: /var/logs/httpd.pid + # config: /etc/sysconfig/httpd + # + ### BEGIN INIT INFO +@@ -36,7 +36,7 @@ + ### END INIT INFO + + # Source function library. +-. /etc/rc.d/init.d/functions ++#. /etc/rc.d/init.d/functions + + # What were we called? Multiple instances of the same daemon can be + # created by creating suitably named symlinks to this startup script +@@ -58,13 +58,13 @@ + # work correctly with a thread-based MPM; notably PHP will refuse to start. + + httpd=${HTTPD-/usr/sbin/httpd} +-pidfile=${PIDFILE-/var/run/${prog}.pid} +-lockfile=${LOCKFILE-/var/lock/subsys/${prog}} ++pidfile=${PIDFILE-/var/logs/httpd.pid} ++lockfile=${LOCKFILE-/var/lock/httpd} + RETVAL=0 + + # check for 1.3 configuration + check13 () { +- CONFFILE=/etc/httpd/conf/httpd.conf ++ CONFFILE=/etc/apache2/httpd.conf + GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|" + GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|" + GONE="${GONE}AccessConfig|ResourceConfig)" +@@ -85,7 +85,8 @@ + start() { + echo -n $"Starting $prog: " + check13 || exit 1 +- LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS ++ LANG=$HTTPD_LANG start-stop-daemon -S -q --pidfile=${pidfile} -x $httpd -- $OPTIONS ++ + RETVAL=$? + echo + [ $RETVAL = 0 ] && touch ${lockfile} +@@ -93,7 +94,7 @@ + } + stop() { + echo -n $"Stopping $prog: " +- killproc -p ${pidfile} -d 10 $httpd ++ start-stop-daemon -K -p ${pidfile} + RETVAL=$? + echo + [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
package/apache/apache.mk +6 -0
@@ -82,6 +82,12 @@ define APACHE_FIX_STAGING_APACHE_CONFIG endef APACHE_POST_INSTALL_STAGING_HOOKS += APACHE_FIX_STAGING_APACHE_CONFIG +define APACHE_INSTALL_INIT_SCRIPT + $(INSTALL) -D -m 0755 $(@D)/build/rpm/httpd.init \ + $(TARGET_DIR)/etc/init.d/S85httpd +endef +APACHE_POST_INSTALL_TARGET_HOOKS += APACHE_INSTALL_INIT_SCRIPT + define APACHE_CLEANUP_TARGET $(RM) -rf $(TARGET_DIR)/usr/manual $(TARGET_DIR)/usr/build endef
Signature · 1 line
2.14.3
PATCH 2/2 apache init script
Hello,
Thanks for this contribution!
The commit title should be something like:
apache: install an sysv init script
Quoted 1 line · Christopher McCrory
This patches and installs the included init script. The script mostly works, but could use a little more editing.
The commit log should be wrapped to 72 characters.
package/apache/0003-init-script.patch
Quoted 10 lines
package/apache/0003-init-script.patch | 56 +++++++++++++++++++++++++++++++++++ package/apache/apache.mk | 6 ++++ 2 files changed, 62 insertions(+) create mode 100644 package/apache/0003-init-script.patchpackage/apache/0003-init-script.patch new file +0
-0
All patches should have a description and a Signed-off-by line.
What does the complete init script looks like after your patch ? Is it worth re-using the init script provided by Apache, as opposed to providing a simple one in package/apache/S<xy>apache ?
Quoted 1 line
+define
APACHE_INSTALL_INIT_SCRIPT
Just call this variable:
APACHE_INSTALL_INIT_SYSV
This way, no need to add it to APACHE_POST_INSTALL_TARGET_HOOKS, and the script will not be installed if the Buildroot configuration uses systemd instead of busybox init or sysvinit.
package/apache/0003-init-script.patch
Quoted 2 lines
package/apache/0003-init-script.patch new file +2
-0+ $(INSTALL) -D -m 0755 $(@D)/build/rpm/httpd.init \ + $(TARGET_DIR)/etc/init.d/S85httpd
Second line should be intended with two tabs.
package/apache/0003-init-script.patch
Quoted 2 lines
package/apache/0003-init-script.patch new file +2
-0+endef +APACHE_POST_INSTALL_TARGET_HOOKS += APACHE_INSTALL_INIT_SCRIPT
So this line can go away.
Could you take into account those comments and submit an updated version ?
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com
PATCH 2/2 apache init script
Hello
D'oh sending to list also
<snip>
Quoted 5 lines
What does the complete init script looks like after your patch ? Is it worth re-using the init script provided by Apache, as opposed to providing a simple one in package/apache/S<xy>apache ?
I started with the idea of changing just enough of the included init script to get the daemon running. I am used to the RedHat/Fedora sysv init system, not the debian/start-stop-daemon style. I didn't want to snag some other init file using start-stop-daemon, replace a variable, and submit it as my own work. I'd rather learn the nuances of start-stop-daemon and write a script that I understand and works as expected.
After testing a few other packages, I noticed quite a few that don't have init scripts. Is this by design? I'd like to add the ability to generate an initscript within the buildroot system. something like $PACKAGE_GENERATE_AND_INSTALL_SYSV_INIT_SCRIPT = YES # with a shorter name though :)
in the package.mk file that would use a template to create a working init script. And a global toggle in makemenu -> Build Options to enable/disable. yes? no? maybe?
<snip>
Signature · 7 lines
Christopher McCrory To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the engineer, the glass is twice as big as it needs to be. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180302/e0f60077/attachment.html>
PATCH 2/2 apache init script
Hello,
Quoted 6 lines · Christopher McCrory
I started with the idea of changing just enough of the included init script to get the daemon running. I am used to the RedHat/Fedora sysv init system, not the debian/start-stop-daemon style. I didn't want to snag some other init file using start-stop-daemon, replace a variable, and submit it as my own work. I'd rather learn the nuances of start-stop-daemon and write a script that I understand and works as expected.
Well, we very much prefer to have init scripts that all follow the same patterns, rather than init scripts that are all very different from each other. Having similar init scriptss makes maintenance a lot easier for us.
So please, re-use the same pattern as existing init scripts. You're not stealing the work of anyone, because you're also contributing to Buildroot, under the same license.
Quoted 8 lines
After testing a few other packages, I noticed quite a few that don't have init scripts. Is this by design? I'd like to add the ability to generate an initscript within the buildroot system. something like $PACKAGE_GENERATE_AND_INSTALL_SYSV_INIT_SCRIPT = YES # with a shorter name though :)
in the package.mk file that would use a template to create a working init script. And a global toggle in makemenu -> Build Options to enable/disable. yes? no? maybe?
Most init scripts have subtle nuances that make a completely auto-generated init script mechanism not really desirable. I think we prefer the dumb approach we have today.
However, patches adding init scripts to more packages are definitely welcome.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering http://bootlin.com
PATCH 2/2 apache init script
In reply to Christopher McCroryQuoted 7 lines · Christopher McCrory
+@@ -58,13 +58,13 @@
+ # work correctly with a thread-based MPM; notably PHP will refuse to start. +
+ httpd=${HTTPD-/usr/sbin/httpd}+-pidfile=${PIDFILE-/var/run/${prog}.pid} +-lockfile=${LOCKFILE-/var/lock/subsys/${prog}}++pidfile=${PIDFILE-/var/logs/httpd.pid}
PID files really should go into /var/run, not in /var/logs.
Regards,
Arnout
Quoted 3 lines
++lockfile=${LOCKFILE-/var/lock/httpd}
+ RETVAL=0
+
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF