diff --git a/jobs/syslog_forwarder/templates/pre-start.erb b/jobs/syslog_forwarder/templates/pre-start.erb index 22f3db14..eebd9164 100644 --- a/jobs/syslog_forwarder/templates/pre-start.erb +++ b/jobs/syslog_forwarder/templates/pre-start.erb @@ -51,7 +51,16 @@ chmod 0644 /etc/rsyslog.d/40-syslog-release-file-exclusion.conf <% end %> -if command -v systemctl &>/dev/null; then +service_manager="$(cat /proc/1/comm 2>/dev/null)" +if [ -f "/var/vcap/bosh/agent.json" ] && command -v jq &>/dev/null; then + if jq 'paths(scalars) as $p | getpath($p) == "systemd"' /var/vcap/bosh/agent.json | grep -q true; then + service_manager="systemd" + else + service_manager="init" + fi +fi + +if [ "${service_manager}" = "systemd" ] && command -v systemctl &>/dev/null; then systemctl restart rsyslog else service rsyslog restart diff --git a/jobs/syslog_storer/templates/pre-start.erb b/jobs/syslog_storer/templates/pre-start.erb index 079e1b82..7bbef7fd 100644 --- a/jobs/syslog_storer/templates/pre-start.erb +++ b/jobs/syslog_storer/templates/pre-start.erb @@ -16,8 +16,17 @@ if [ -d "/etc/apparmor.d/rsyslog.d/" ]; then fi fi -if command -v systemctl &>/dev/null; then +service_manager="$(cat /proc/1/comm 2>/dev/null)" +if [ -f "/var/vcap/bosh/agent.json" ] && command -v jq &>/dev/null; then + if jq 'paths(scalars) as $p | getpath($p) == "systemd"' /var/vcap/bosh/agent.json | grep -q true; then + service_manager="systemd" + else + service_manager="init" + fi +fi + +if [ "${service_manager}" = "systemd" ] && command -v systemctl &>/dev/null; then systemctl restart rsyslog else service rsyslog restart -fi +fi \ No newline at end of file