From 519b3f00ab73b88885089799266add1f8d766bbb Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 13 May 2018 20:36:46 +0200 Subject: [PATCH] install_roundcube.sh: addes support for systemd apache2 service. --- install_roundcube.sh | 61 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/install_roundcube.sh b/install_roundcube.sh index a9d8401..3e7c1b5 100755 --- a/install_roundcube.sh +++ b/install_roundcube.sh @@ -89,6 +89,44 @@ echo_skipped() { trap clean_up SIGHUP SIGINT SIGTERM +# - 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 + +# - Look for systemd service file or sysv init script for apache2 webservice +# - +APACHE_SERVICE_FILE="" +APACHE_INIT_SCRIPT="" +if $systemd_supported ; then + # - Is Service exclusive controlled by systemd + # - + if systemctl -t service list-unit-files \ + | grep -e "^apache" \ + | grep -q -E "(enabled|disabled)" 2> /devnull ; then + + APACHE_SERVICE_FILE=$(systemctl -t service list-unit-files \ + | grep -e "^apache" \ + | awk '{print$1}') + + fi +fi + +if [[ -z "$APACHE_SERVICE_FILE" ]] ; then + if [ -x "/etc/init.d/apache2" ]; then + APACHE_INIT_SCRIPT="/etc/init.d/apache2" + elif [ -x "/etc/init.d/apachectl" ]; then + APACHE_INIT_SCRIPT="/etc/init.d/apachectl" + fi +fi + + if [ "$DB_TYPE" = "postgres" -o "$DB_TYPE" = "postgresql" -o "$DB_TYPE" = "pgsql" -o "$DB_TYPE" = "psql" ];then DB_TYPE=pgsql fi @@ -1413,16 +1451,21 @@ else fi echononl "\tRestart Apache Webservice.." -if $APACHE_DEBIAN_INSTALLATION ; then - /etc/init.d/apache2 reload > $log_file 2>&1 +if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then + if [[ -n "$APACHE_SERVICE_FILE" ]] ; then + systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1 + else + $APACHE_INIT_SCRIPT restart > $log_file 2>&1 + fi + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi else - /etc/init.d/apache2 restart > $log_file 2>&1 -fi -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "$(cat $log_file)" + echo_skipped + warn "Neither an init-script nor a service file for 'apache2' webservice found!" fi # - Install a cronjob for cleaning up tmp-directory