diff --git a/install_dehydrated.sh b/install_dehydrated.sh index 5419399..74f3c73 100755 --- a/install_dehydrated.sh +++ b/install_dehydrated.sh @@ -1319,6 +1319,16 @@ else verbose=false fi +# -Is systemd supported on this system? +# - +systemd_supported=false +systemd=\$(which systemd) +systemctl=\$(which systemctl) + +if [[ -n "\$systemd" ]] && [[ -n "\$systemctl" ]] ; then + systemd_supported=true +fi + # --- # --- Some checks @@ -2034,39 +2044,51 @@ if \$certs_updated ; then fi fi if \$restart_postfix ; then - /etc/init.d/postfix reload > /dev/null 2>&1 + if \$systemd_supported ; then + \$systemctl reload postfix > /dev/null 2>&1 + else + /etc/init.d/postfix reload > /dev/null 2>&1 + fi if [[ \$? -gt 0 ]]; then if \$verbose ; then - error "Restarting Postfix failed!" + error "Reloading Postfix Service failed!" else - echo -e "\\n [ Error ]: Restarting Postfix failed! \\n" + echo -e "\\n [ Error ]: Reloading Postfix Service failed! \\n" fi else if \$verbose ; then - info "Postfix service restarted." + info "Postfix service successfully reloaded." else - echo -e "\\n [ Info ]: Postfix service restarted.\\n" + echo -e "\\n [ Info ]: Postfix service successfully reloaded.\\n" fi fi fi if \$restart_dovecot ; then - /etc/init.d/dovecot restart > /dev/null 2>&1 + if \$systemd_supported ; then + \$systemctl restart dovecot > /dev/null 2>&1 + else + /etc/init.d/dovecot restart > /dev/null 2>&1 + fi if [[ \$? -gt 0 ]]; then if \$verbose ; then - error "Restarting Dovecot Service failed!" + error "Reloading Dovecot Service failed!" else - echo -e "\\n [ Error ]: Restarting Dovecot Service failed! \\n" + echo -e "\\n [ Error ]: Reloading Dovecot Service failed! \\n" fi else if \$verbose ; then - info "Dovecot service restarted." + info "Dovecot service successfully reloaded." else - echo -e "\\n [ Info ]: Dovecot service restarted.\\n" + echo -e "\\n [ Info ]: Dovecot service successfully reloaded.\\n" fi fi fi if \$restart_pureftpd ; then - /etc/init.d/pure-ftpd restart > /dev/null 2>&1 + if \$systemd_supported ; then + \$systemctl restart pure-ftpd > /dev/null 2>&1 + else + /etc/init.d/pure-ftpd restart > /dev/null 2>&1 + fi if [[ \$? -gt 0 ]]; then if \$verbose ; then error "Restarting PureFTP Server failed!" @@ -2082,7 +2104,11 @@ if \$certs_updated ; then fi fi if \$restart_nginx ; then - /etc/init.d/nginx restart > /dev/null 2>&1 + if \$systemd_supported ; then + \$systemctl restart nginx > /dev/null 2>&1 + else + /etc/init.d/nginx restart > /dev/null 2>&1 + fi if [[ \$? -gt 0 ]]; then if \$verbose ; then error "Restarting Nginx Webserver failed!"