From c44d77969597a3f2378a3e7fc585f6549b69b104 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Tue, 11 Jul 2023 20:34:50 -0400 Subject: [PATCH] fix: detect and use systemd on Debian systems Debian Bookworm completely removes invoke-rc.d, thus breaking interactions with nginx. Closes #6020 --- docs/getting-started/troubleshooting.md | 6 ++---- plugins/nginx-vhosts/install | 6 +++++- plugins/nginx-vhosts/internal-functions | 6 +++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/getting-started/troubleshooting.md b/docs/getting-started/troubleshooting.md index e0e4d7b6e..49f9953b1 100644 --- a/docs/getting-started/troubleshooting.md +++ b/docs/getting-started/troubleshooting.md @@ -58,10 +58,8 @@ A value of 64 would allow domains with up to 64 characters. Set it to 128 if you Save the file and try stopping nginx and starting it again: ```shell -/etc/init.d/nginx stop -## * Stopping nginx nginx [ OK ] -/etc/init.d/nginx start -## * Starting nginx nginx [ OK ] +dokku nginx:stop +dokku nginx:start ``` --- diff --git a/plugins/nginx-vhosts/install b/plugins/nginx-vhosts/install index e5f0e7af4..bd1919a4e 100755 --- a/plugins/nginx-vhosts/install +++ b/plugins/nginx-vhosts/install @@ -69,7 +69,11 @@ trigger-nginx-vhosts-install() { local mode="0440" case "$DOKKU_DISTRO" in debian | raspbian) - echo "%dokku ALL=(ALL) NOPASSWD:/usr/sbin/invoke-rc.d $NGINX_INIT_NAME enable, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME disable, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME reload, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME start, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME stop, $NGINX_BIN -t, ${NGINX_BIN} -t -c *" >"$NGINX_SUDOERS_FILE" + if [[ -x /usr/bin/systemctl ]]; then + echo "%dokku ALL=(ALL) NOPASSWD:/usr/bin/systemctl enable $NGINX_INIT_NAME, /usr/bin/systemctl disable $NGINX_INIT_NAME, /usr/bin/systemctl reload $NGINX_INIT_NAME, /usr/bin/systemctl start $NGINX_INIT_NAME, /usr/bin/systemctl stop $NGINX_INIT_NAME, $NGINX_BIN -t, $NGINX_BIN -t -c *" >"$NGINX_SUDOERS_FILE" + else + echo "%dokku ALL=(ALL) NOPASSWD:/usr/sbin/invoke-rc.d $NGINX_INIT_NAME enable, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME disable, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME reload, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME start, /usr/sbin/invoke-rc.d $NGINX_INIT_NAME stop, $NGINX_BIN -t, ${NGINX_BIN} -t -c *" >"$NGINX_SUDOERS_FILE" + fi ;; ubuntu) diff --git a/plugins/nginx-vhosts/internal-functions b/plugins/nginx-vhosts/internal-functions index 7a6ae1e79..a653499ef 100755 --- a/plugins/nginx-vhosts/internal-functions +++ b/plugins/nginx-vhosts/internal-functions @@ -125,7 +125,11 @@ fn-nginx-vhosts-nginx-init-cmd() { case "$DOKKU_DISTRO" in debian | raspbian) - sudo /usr/sbin/invoke-rc.d "$NGINX_INIT_NAME" "$CMD" + if [[ -x /usr/bin/systemctl ]]; then + sudo /usr/bin/systemctl "$CMD" "$NGINX_INIT_NAME" + else + sudo /usr/sbin/invoke-rc.d "$NGINX_INIT_NAME" "$CMD" + fi ;; ubuntu)