upgrade_roundcube.sh: addes support for systemd apache2 service.
This commit is contained in:
		| @@ -95,12 +95,40 @@ trap clean_up SIGHUP SIGINT SIGTERM | |||||||
|  |  | ||||||
| # - Support systemd ? | # - Support systemd ? | ||||||
| # - | # - | ||||||
| if [[ "X$(which systemd)" = "X" ]]; then | systemd_supported=false | ||||||
|    SYSTEMD_EXISTS=false |  | ||||||
| else | systemd=$(which systemd) | ||||||
|    SYSTEMD_EXISTS=true | systemctl=$(which systemctl) | ||||||
|  |  | ||||||
|  | if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then | ||||||
|  |    systemd_supported=true | ||||||
| fi | 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 | ||||||
|  |  | ||||||
|  |  | ||||||
| DEFAULT_DB_HOST="localhost" | DEFAULT_DB_HOST="localhost" | ||||||
| @@ -340,22 +368,21 @@ fi | |||||||
|  |  | ||||||
|  |  | ||||||
| echononl "   Stop Apache Webserver.." | echononl "   Stop Apache Webserver.." | ||||||
| if $SYSTEMD_EXISTS ; then | if [[ -n "$APACHE_SERVICE_FILE" ]] ||  [[ -n "$APACHE_INIT_SCRIPT" ]] ; then | ||||||
|    systemctl stop apache2 > $log_file 2>&1 |    if [[ -n "$APACHE_SERVICE_FILE" ]] ; then | ||||||
|  |       systemctl stop $APACHE_SERVICE_FILE > $log_file 2>&1 | ||||||
|  |    else | ||||||
|  |       $APACHE_INIT_SCRIPT stop > $log_file 2>&1 | ||||||
|  |    fi | ||||||
|    if [[ $? -eq 0 ]]; then |    if [[ $? -eq 0 ]]; then | ||||||
|       echo_ok |       echo_ok | ||||||
|    else |    else | ||||||
|       echo_failed |       echo_failed | ||||||
|       fatal "$(cat $log_file)" |       error "$(cat $log_file)" | ||||||
|    fi |    fi | ||||||
| else | else | ||||||
|    /etc/init.d/apache2 stop > ${logdir}/main.log 2>&1 |    echo_skipped | ||||||
|    if [[ $? -eq 0 ]]; then |    warn "Neither an init-script nor a service file for 'apache2' webservice  found!" | ||||||
|       echo_ok |  | ||||||
|    else |  | ||||||
|       echo_failed |  | ||||||
|       fatal "$(cat $log_file)" |  | ||||||
|    fi |  | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -583,22 +610,21 @@ fi | |||||||
| # - Start Apache Webserver | # - Start Apache Webserver | ||||||
| # - | # - | ||||||
| echononl "   Start Apache Webserver.." | echononl "   Start Apache Webserver.." | ||||||
| if $SYSTEMD_EXISTS ; then | if [[ -n "$APACHE_SERVICE_FILE" ]] ||  [[ -n "$APACHE_INIT_SCRIPT" ]] ; then | ||||||
| 	systemctl start apache2 > $log_file 2>&1 |    if [[ -n "$APACHE_SERVICE_FILE" ]] ; then | ||||||
| 	if [[ $? -eq 0 ]]; then |       systemctl start $APACHE_SERVICE_FILE > $log_file 2>&1 | ||||||
| 		echo_ok |    else | ||||||
| 	else |       $APACHE_INIT_SCRIPT start > $log_file 2>&1 | ||||||
| 		echo_failed |    fi | ||||||
| 		fatal "$(cat $log_file)" |    if [[ $? -eq 0 ]]; then | ||||||
| 	fi |       echo_ok | ||||||
|  |    else | ||||||
|  |       echo_failed | ||||||
|  |       error "$(cat $log_file)" | ||||||
|  |    fi | ||||||
| else | else | ||||||
| 	/etc/init.d/apache2 start> $log_file 2>&1 |    echo_skipped | ||||||
| 	if [[ $? -eq 0 ]]; then |    warn "Neither an init-script nor a service file for 'apache2' webservice  found!" | ||||||
| 		echo_ok |  | ||||||
| 	else |  | ||||||
| 		echo_failed |  | ||||||
| 		fatal "$(cat $log_file)" |  | ||||||
| 	fi |  | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user