diff --git a/manifests/init.pp b/manifests/init.pp index 486875fec0df439ba047bdad5396459bcb17b798..7a03d51fe4e7d34bd6be4329cb766609c72908c9 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -86,10 +86,25 @@ class apache::base */ class apache::daily_restart { + $gracefulcmd = 'o=`/usr/sbin/apachectl graceful 2>&1`' + case $::initsystem + { + 'sysvinit', 'upstart': { + $statuscmd = '/sbin/service httpd status >/dev/null 2>&1' + $extrastatus = 'echo "$o" >&2' + } + 'systemd': { + $statuscmd = '/bin/systemctl status httpd.service >/dev/null 2>&1' + $extrastatus = '/bin/systemctl status -l httpd.service >&2' + } + default: { + fail("${name}: Init system ${::initsystem} not supported") + } + } # This tries to only generate output (mailed to root by Cron) if # the restart fails. And it will not try to start Apache if it is # not running. - $restart = '/sbin/service httpd status >/dev/null 2>&1 && (o=`/usr/sbin/apachectl graceful 2>&1` || echo "$o" >&2)' + $restart = "${statuscmd} && (${gracefulcmd} || ${extrastatus})" cron { 'apache::daily_restart':