[apache2] 03/03: Fix systemd detection logic
Stefan Fritsch
sf at moszumanska.debian.org
Wed Jan 25 21:17:51 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 f4e22fe73cf57ff19ff63e51c1070b32aaa3761b
Author: Stefan Fritsch <sf at sfritsch.de>
Date: Wed Jan 25 20:59:09 2017 +0100
Fix systemd detection logic
---
debian/a2enmod | 8 +++++++-
debian/apache2ctl | 23 ++++++++++++-----------
debian/changelog | 7 +++++++
debian/setup-instance | 13 ++++++++++++-
4 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/debian/a2enmod b/debian/a2enmod
index 2656a2e..9d2b091 100755
--- a/debian/a2enmod
+++ b/debian/a2enmod
@@ -123,7 +123,7 @@ foreach my $acton (@objs) {
my $htcstart = "";
my $apache_reload = "";
my $cmd = ($act eq "enable") ? "start" : "stop";
-if (-d "/run/systemd" and -x "/bin/systemctl") {
+if (is_systemd()) {
$htcstart = " systemctl $cmd $htc_service\n";
$apache_reload = " systemctl $reload $apache_service\n";
} else {
@@ -608,4 +608,10 @@ sub special_module_handling {
}
}
+sub is_systemd
+{
+ my $init = readlink("/proc/1/exe") || "";
+ return scalar $init =~ /systemd/;
+}
+
# vim: syntax=perl sw=4 sts=4 sr et
diff --git a/debian/apache2ctl b/debian/apache2ctl
index 360f9ae..8caa806 100755
--- a/debian/apache2ctl
+++ b/debian/apache2ctl
@@ -153,18 +153,19 @@ start)
# (this is bad if there are several apache2 instances running)
rm -f ${APACHE_RUN_DIR:-/var/run/apache2}/*ssl_scache*
- # 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
+ case "$(readlink -f /proc/1/exe)" in
+ *systemd*)
+ # If running on systemd we should not start httpd without systemd
+ # or systemd will get confused about the status of httpd.
+ echo "Invoking 'systemctl start $APACHE_SYSTEMD_SERVICE'."
+ echo "Use 'systemctl status $APACHE_SYSTEMD_SERVICE' for more info."
+ systemctl start "$APACHE_SYSTEMD_SERVICE"
+ ;;
+ *)
+ unset APACHE_STARTED_BY_SYSTEMD
$HTTPD ${APACHE_ARGUMENTS} -k $ARGV
- fi
+ ;;
+ esac
ERROR=$?
;;
diff --git a/debian/changelog b/debian/changelog
index fef492a..06f2735 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+apache2 (2.4.25-3) UNRELEASED; urgency=medium
+
+ * Fix detection of systemd to fix 'apache2ctl start' on sysv-init.
+ Closes: #852543
+
+ -- Stefan Fritsch <sf at debian.org> Wed, 25 Jan 2017 20:56:56 +0100
+
apache2 (2.4.25-2) unstable; urgency=medium
* Activate mod_reqtimeout in new installs and during updates from
diff --git a/debian/setup-instance b/debian/setup-instance
index e404dec..b202457 100644
--- a/debian/setup-instance
+++ b/debian/setup-instance
@@ -7,6 +7,17 @@ if [ $# != 1 ] ; then
exit 1
fi
+is_systemd () {
+ case "$(readlink -f /proc/1/exe || true)" in
+ *systemd*)
+ return 0
+ ;;
+ *)
+ return 1
+ ;;
+ esac
+}
+
# the SUFFIX must not contain spaces or shell meta characters
SUFFIX=$1
@@ -18,7 +29,7 @@ fi
echo Setting up /etc/apache2-$SUFFIX ...
cp -a /etc/apache2 /etc/apache2-$SUFFIX
-if [ -d /run/systemd ] && [ -x /bin/systemctl ]; then
+if is_systemd ; then
echo "systemd is in use, no init script installed"
echo "use the 'apache2@$SUFFIX.service' service to control your new instance"
echo "sample commands:"
--
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