From d55ba8e189a38e9ad815c110eee3c8fbce4c8ad1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 21 Sep 2024 05:37:34 -0400 Subject: [PATCH] fix: detect correct init when interacting with rsyslog on install This change also skips running a restart of rsyslog as during install, the service isn't properly initiated. While this breaks upgrades of Dokku within containers, that is not how upgrades of container-based Dokku should work, so this is a fine trade-off. --- plugins/20_events/install | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/plugins/20_events/install b/plugins/20_events/install index ffebb1977..f8f080adb 100755 --- a/plugins/20_events/install +++ b/plugins/20_events/install @@ -72,8 +72,39 @@ EOF flag_rsyslog_needs_restart=y fi - if [[ -f "$DOKKU_RSYSLOG_FILTER" && "$flag_rsyslog_needs_restart" == "y" ]]; then - service rsyslog restart + local systemctl_path=/bin/systemctl + if [[ -x /usr/bin/systemctl ]]; then + systemctl_path=/usr/bin/systemctl + fi + + if [[ -f "$DOKKU_RSYSLOG_FILTER" ]] && [[ "$flag_rsyslog_needs_restart" == "y" ]]; then + case "$DOKKU_DISTRO" in + debian | raspbian) + if [[ -x "$systemctl_path" ]]; then + systemctl restart rsyslog + else + /usr/sbin/invoke-rc.d rsyslog restart + fi + ;; + ubuntu) + if [[ "$DOKKU_INIT_SYSTEM" == "sv" ]]; then + # avoid failing runit init calls on install + # the runit binaries are not yet available during dockerfile building + true + elif [[ -x "$systemctl_path" ]]; then + systemctl restart rsyslog + elif [[ -x /usr/bin/sv ]]; then + # avoid failing runit init calls on install + # the runit binaries are not yet available during dockerfile building + true + else + invoke-rc.d rsyslog restart + fi + ;; + arch) + systemctl restart rsyslog + ;; + esac fi [[ ! "$DOKKU_EVENTS" ]] || dokku_log_plugn_trigger_call "$(basename "$0")" "$@"