[apache2] 02/04: Make apachectl start httpd via systemd if present
Stefan Fritsch
sf at moszumanska.debian.org
Fri Jan 20 07:54:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
sf pushed a commit to branch master
in repository apache2.
commit 964caa90b55e9b94d112ac2edf766ca027f44318
Author: Stefan Fritsch <sf at sfritsch.de>
Date: Sat Jan 14 19:13:54 2017 +0100
Make apachectl start httpd via systemd if present
---
debian/apache2.service | 1 +
debian/apache2 at .service | 2 +-
debian/apache2ctl | 27 ++++++++++++++++++++++++++-
debian/changelog | 3 +++
4 files changed, 31 insertions(+), 2 deletions(-)
diff --git a/debian/apache2.service b/debian/apache2.service
index 92a371a..8e8884a 100644
--- a/debian/apache2.service
+++ b/debian/apache2.service
@@ -4,6 +4,7 @@ After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
+Environment=APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
diff --git a/debian/apache2 at .service b/debian/apache2 at .service
index 395137b..a2b2e75 100644
--- a/debian/apache2 at .service
+++ b/debian/apache2 at .service
@@ -5,7 +5,7 @@ ConditionPathIsDirectory=/etc/apache2-%i
[Service]
Type=forking
-Environment=APACHE_CONFDIR=/etc/apache2-%i
+Environment=APACHE_CONFDIR=/etc/apache2-%i APACHE_STARTED_BY_SYSTEMD=true
ExecStart=/usr/sbin/apachectl start
ExecStop=/usr/sbin/apachectl stop
ExecReload=/usr/sbin/apachectl graceful
diff --git a/debian/apache2ctl b/debian/apache2ctl
index 63db198..360f9ae 100755
--- a/debian/apache2ctl
+++ b/debian/apache2ctl
@@ -50,6 +50,18 @@ if test -z "$APACHE_CONFDIR" ; then
APACHE_CONFDIR=/etc/apache2
fi
fi
+
+SUFFIX="${APACHE_CONFDIR##/etc/apache2-}"
+case "$SUFFIX" in
+ /etc/apache2)
+ SUFFIX=""
+ ;;
+ *)
+ SUFFIX="@$SUFFIX"
+ ;;
+esac
+APACHE_SYSTEMD_SERVICE="apache2$SUFFIX"
+
# the path to the environment variable file
test -z "$APACHE_ENVVARS" && APACHE_ENVVARS="$APACHE_CONFDIR/envvars"
# pick up any necessary environment variables
@@ -140,7 +152,20 @@ start)
# ssl_scache shouldn't be here if we're just starting up.
# (this is bad if there are several apache2 instances running)
rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache*
- $HTTPD ${APACHE_ARGUMENTS} -k $ARGV
+
+ # If running on systemd we should not start httpd without systemd
+ # or systemd will get confused about the status of httpd.
+ if [ "$APACHE_STARTED_BY_SYSTEMD" != 'true' -a -d "/run/systemd" -a \
+ -x "/bin/systemctl" ]
+ then
+ echo "Invoking 'systemctl start $APACHE_SYSTEMD_SERVICE'."
+ echo "Use 'systemctl status $APACHE_SYSTEMD_SERVICE' for more info."
+ systemctl start "$APACHE_SYSTEMD_SERVICE"
+ else
+ unset APACHE_STARTED_BY_SYSTEMD
+ $HTTPD ${APACHE_ARGUMENTS} -k $ARGV
+ fi
+
ERROR=$?
;;
stop|graceful-stop)
diff --git a/debian/changelog b/debian/changelog
index 2bb7901..9e25609 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -7,6 +7,9 @@ apache2 (2.4.25-2) UNRELEASED; urgency=medium
* Restart htcacheclean on updates and tighten dependency on apache2-utils
to ensure that apache2-utils cannot be upgraded without apache2.
Closes: #851122
+ * When running on systems with systemd, make 'apache2ctl start' invoke
+ systemctl instead. Otherwise systemd will think apache2 is not running
+ and ignore further commands like reload. Closes: #839227
* Add test for some modules to be enabled.
* Remove mention of CVE-2016-5387 in 2.4.25-1 changelog. It was already
fixed in 2.4.23-2.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-apache/apache2.git
More information about the Pkg-apache-commits
mailing list