Commit 0cc15350 authored by Christoph Berg's avatar Christoph Berg

Invoke systemctl only if systemd is running

parent 19cd2cb9
......@@ -387,7 +387,7 @@ if (($< == 0 or $> == 0) and $info{'configuid'} != 0 and
}
# redirect the request through systemd (if we are root and we are not a direct pid 1 child)
if ($> == 0 and getppid() != 1 and not exists $ENV{_SYSTEMCTL_SKIP_REDIRECT} and not exists $ENV{'PG_CLUSTER_CONF_ROOT'}) {
if ($> == 0 and getppid() != 1 and -d '/var/run/systemd/system' and not exists $ENV{_SYSTEMCTL_SKIP_REDIRECT} and not exists $ENV{'PG_CLUSTER_CONF_ROOT'}) {
if ($action =~ /^(start|stop|restart)$/) {
print "Redirecting $1 request to systemctl\n";
system ('systemctl', $1, "postgresql\@$version-$cluster");
......
......@@ -97,7 +97,9 @@ cleanup () {
set +e
umount -l $dirs
sed -i -e '/# by pg-testsuite/d' /etc/postgresql-common/createcluster.conf
systemctl daemon-reload 2> /dev/null || : # poke generator to handle the system's clusters again
if [ -d /var/run/systemd/system ]; then
systemctl daemon-reload || : # poke generator to handle the system's clusters again
fi
}
trap "cleanup" 0 HUP INT QUIT ILL ABRT PIPE TERM
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment