#!/usr/bin/env bash clear echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m" ## ----------------------------------------------------------------- ## ---------------------------------------------------------------- ## --- ## --- For configurations see file conf/install_upgrade_roundcube.conf ## --- ## --- Dont make changes here! ## --- ## ----------------------------------------------------------------- ## ----------------------------------------------------------------- # ------------- # - Settings # ------------- #_src_base_dir="$(realpath $(dirname $0))" #conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf" script_name="$(basename $(realpath $0))" script_dir="$(dirname $(realpath $0))" conf_dir="${script_dir}/conf" declare -a unsorted_website_arr declare -a website_arr curdir=`pwd` log_file="$(mktemp)" tmp_dir="$(mktemp -d)" backup_date="$(date +%Y-%m-%d-%H%M)" crontab_backup_file="/root/crontab-root.${backup_date}" # ------------- # - Functions # ------------- clean_up() { # Perform program exit housekeeping rm -f "$log_file" rm -rf "$tmp_dir" exit $1 } echononl(){ echo X\\c > /tmp/shprompt$$ if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then echo "$*\\c" 1>&2 else echo -e -n "$*" 1>&2 fi rm /tmp/shprompt$$ } fatal(){ echo "" echo -e "\t[ \033[31m\033[1mFatal\033[m ]: $*" echo "" echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m" echo "" clean_up 1 } error(){ echo "" echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*" echo "" } warn (){ echo "" echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" echo "" } info (){ echo "" echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" echo "" } is_number() { return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1); # - also possible # - #[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1 #return $([[ ! -z "${1##*[!0-9]*}" ]]) } echo_ok() { echo -e "\033[85G[ \033[32mok\033[m ]" } echo_failed(){ echo -e "\033[85G[ \033[1;31mfailed\033[m ]" } echo_skipped() { echo -e "\033[85G[ \033[30m\033[1mskipped\033[m ]" } echo_not_yet_implemented(){ echo -e "\033[85G[ \033[30m\033[1mnot yet implemented\033[m ]" } trap clean_up SIGHUP SIGINT SIGTERM # - Support systemd ? # - 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 "^apache2.service" \ | grep -q -E "(enabled|disabled)" 2> /dev/null ; then APACHE_SERVICE_FILE=$(systemctl -t service list-unit-files \ | grep -e "^apache2.service" \ | 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_NAME="roundcubemail" DEFAULT_DB_USER="roundcube" DEFAULT_DEBIAN_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf" DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf" while IFS='' read -r -d '' _conf_file ; do WEBSITE_NAME="$(grep -E "^WEBSITE_NAME" "${_conf_file}" 2>/dev/null | cut -d"=" -f2)" #Remove leading / trailling double quotes WEBSITE_NAME="${WEBSITE_NAME#"${WEBSITE_NAME%%[!\"]*}"}" WEBSITE_NAME="${WEBSITE_NAME%"${WEBSITE_NAME##*[!\"]}"}" #Remove leading / trailling single quotes WEBSITE_NAME="${WEBSITE_NAME#"${WEBSITE_NAME%%[!\']*}"}" WEBSITE_NAME="${WEBSITE_NAME%"${WEBSITE_NAME##*[!\']}"}" #Remove leading / trailling space WEBSITE_NAME="${WEBSITE_NAME#"${WEBSITE_NAME%%[![:space:]]*}"}" WEBSITE_NAME="${WEBSITE_NAME%"${WEBSITE_NAME##*[![:space:]]}"}" if [[ -n "$WEBSITE_NAME" ]] ; then unsorted_website_arr+=("${WEBSITE_NAME}:$_conf_file") fi WEBSITE_NAME="" done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0) if [[ ${#unsorted_website_arr} -eq 0 ]]; then fatal "No configuration files found in '${script_dir}/conf' or no website configured!" fi # - Sort array # - IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) IFS=' ' WEBSITE_NAME= _OK=false echo "" echo "Which site would you like to update?" echo "" declare -i i=0 for _site in ${website_arr[@]} ; do IFS=':' read -a _arr <<< ${_site} echo " [$i] ${_arr[0]}" ((i++)) done echo echononl " Eingabe: " while ! $_OK ; do read _IN if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then IFS=':' read -a _arr <<< ${website_arr[$_IN]} conf_file=${_arr[1]} _OK=true else echo "" echo -e "\tFalsche Eingabe !" echo "" echononl " Eingabe: " fi done echo "" echononl " Include Configuration file.." if [[ ! -f $conf_file ]]; then echo_failed fatal "Missing configuration file '$conf_file'" else source $conf_file echo_ok fi [[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!" DEFAULT_WEBSITE_BASEDIR="/var/www/${WEBSITE_NAME}" [[ -n "$WEBSITE_BASEDIR" ]] || WEBSITE_BASEDIR=$DEFAULT_WEBSITE_BASEDIR CUR_INSTALL_DIR="$(realpath "${WEBSITE_BASEDIR}/htdocs")" if [[ ! -d "$CUR_INSTALL_DIR" ]] ; then fatal "No current installation of roundcube found!" fi [[ -n "$PHP_DEBIAN_INSTALLATION" ]] || PHP_DEBIAN_INSTALLATION=false [[ -n "$DB_TYPE" ]] || fatal "Database Type of Roundcube Database (DB_TYPE) not present!" [[ -n "$DB_HOST" ]] || DB_HOST="$DEFAULT_DB_HOST" [[ -n "$DB_NAME" ]] || DB_NAME="$DEFAULT_DB_NAME" [[ -n "$DB_USER" ]] || DB_USER="$DEFAULT_DB_USER" [[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Plugin password: Database Type for Password Database (POSTFIX_DB_TYPE) not given!" if [[ "$POSTFIX_DB_TYPE" != "pgsql" ]] && [[ "$POSTFIX_DB_TYPE" != "mysql" ]]; then fatal "Unknown Database Type '$POSTFIX_DB_TYPE' for Password Database (POSTFIX_DB_TYPE)" fi [[ -n "$POSTFIX_DB_HOST" ]] || POSTFIX_DB_HOST="localhost" [[ -n "$POSTFIX_DB_NAME" ]] || POSTFIX_DB_NAME="postfix" [[ -n "$POSTFIX_DB_USER" ]] || POSTFIX_DB_USER="postfix" [[ -n "$POSTFIX_DB_PASSWD" ]] || fatal "Plugin password: Password for Password Database (POSTFIX_DB_PASSWD) not given!" [[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false if [ "$DB_TYPE" = "postgres" -o "$DB_TYPE" = "postgresql" -o "$DB_TYPE" = "pgsql" -o "$DB_TYPE" = "psql" ];then DB_TYPE="pgsql" fi if [[ "$DB_TYPE" = "mysql" ]]; then if $MYSQL_DEBIAN_INSTALLATION ; then [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS" else [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS" fi else [[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)" fi echo -e "\033[32m--\033[m" echo "" echo "Version of the Roundcube Webmailer to install" echo "" echo "" ROUNDCUBE_VERSION= while [ "X$ROUNDCUBE_VERSION" = "X" ] do echononl "Roundcube Version: " read ROUNDCUBE_VERSION if [ "X$ROUNDCUBE_VERSION" = "X" ]; then echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n" fi done echo "" echo -e "\033[32m--\033[m" echo "" NEW_INSTALL_DIR="${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" if [[ "$NEW_INSTALL_DIR" = "$CUR_INSTALL_DIR" ]] ; then warn "Version '${ROUNDCUBE_VERSION}' is already installed" echononl "Type uppercase \"yes\" to proceed with upgrading: " read _proceed [[ "${_proceed^^}" = "YES" ]] || fatal "Exiting by user request.." fi # - Determin PHP of all installed versions # - if $PHP_DEBIAN_INSTALLATION ; then echononl " Get get major version installed PHP" php_major_version="$(php --version | head -1 | cut -d' ' -f2 | cut -d '-' -f1 | cut -d'.' -f1,2)" if [[ -z "$php_major_version" ]]; then echo_failed error "Getting version numbers of installed PHP versions failed! No installed PHP versiond found!" else echo_ok fi else echononl " Get major version of all installed PHP versions" IFS=$'\n' php_major_versions="$(find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort)" if [[ -z "$php_major_versions" ]]; then echo_failed error "Getting version numbers of installed PHP versions failed! No installed PHP versiond found!" else echo_ok fi fi echo "" echo "" echo -e "\033[1;32mSettings for upgrading \033[1;37mRoundcube Webmail\033[m" echo "" echo -e "\tRoundcube Version....................: $ROUNDCUBE_VERSION" echo "" echo -e "\tName of the Website..................: $WEBSITE_NAME" echo "" if [[ "$DB_TYPE" = "mysql" ]]; then echo -e "\tDatabase type of Roundcube Database..: MySQL" echo -e "\tMySQL from Debian Package System.....: $MYSQL_DEBIAN_INSTALLATION" else echo -e "\tDatabase type of Roundcube Database..: PostgreSQL" fi echo -e "\tHost of Roundcube Database...........: $DB_HOST" echo -e "\tName of Roundcube Database...........: $DB_NAME" echo -e "\tUser of Roundcube Database...........: $DB_USER" echo -e "\tPassword of Roundcube Database.......: $DB_PASS" if [[ "$DB_TYPE" = "mysql" ]]; then echo -e "\tMySQL Credentials (root access)......: $MYSQL_CREDENTIALS" fi echo "" if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then echo -e "\tDatabase type of Postfix Database....: MySQL" echo -e "\tMySQL from Debian Package System.....: $MYSQL_DEBIAN_INSTALLATION" else echo -e "\tDatabase type of Postfix Database....: PostgreSQL" fi echo -e "\tHost of Roundcube Database...........: $POSTFIX_DB_HOST" echo -e "\tName of Roundcube Database...........: $POSTFIX_DB_NAME" echo -e "\tUser of Roundcube Database...........: $POSTFIX_DB_USER" echo -e "\tPassword of Roundcube Database.......: $POSTFIX_DB_PASSWD" if [[ "$DB_TYPE" = "mysql" ]]; then echo -e "\tMySQL Credentials (root access)......: $MYSQL_CREDENTIALS" fi echo "" if $PHP_DEBIAN_INSTALLATION ; then echo -e "\tInstalled PHP version................: $php_major_version" else declare -i index=1 for _ver in $php_major_versions ; do if [[ $index -eq 1 ]] ; then echo -en "\tInstalled PHP versions...............: $_ver" else echo -en " $_ver" fi ((index++)) done echo "" echo -e "\tNewest PHP Version...................: $php_latest_ver" fi echo "" echo -e "\tCrontab backup file..................: $crontab_backup_file" echo "" echo -n "Type upper case 'YES' to continue executing with this parameters: " read OK if [[ "$OK" = "YES" ]] ; then echo "" echo "" echo -e " \033[1;32mGoing to upgrade Roundcube Webmailer \033[1;37m$network \033[m" echo "" else fatal "Abort by user request - Answer as not 'YES'" fi if [[ "$DB_TYPE" = "mysql" ]]; then if ! mysql $MYSQL_CREDENTIALS -N -s -e \ "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>> $log_file \ | grep $DB_NAME >> $log_file 2>&1 ; then fatal "MySQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')" fi elif [[ "$DB_TYPE" = "pgsql" ]]; then count=$(su - postgres -c "psql -q -A -t -l" | grep -c -e "^$DB_NAME") if [[ $count -eq 0 ]];then fatal "PostgreSQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')" fi else fatal "Cannot detect database type (value of DB_TYPE is neither 'mysql' nor 'pgsql')" fi echo -e "\n\n \033[37m\033[1mCreate some Backups..\033[m\n" echononl " Backup existing Database '$DB_NAME'" if [[ "$DB_TYPE" = "mysql" ]]; then echo -n " (MySQL).." mysqldump $MYSQL_CREDENTIALS --opt $DB_NAME > ${WEBSITE_BASEDIR}/${DB_NAME}.$backup_date.sql 2> $log_file if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi elif [[ "$DB_TYPE" = "pgsql" ]]; then echo -n " (PostgreSQL).." su - postgres -c "pg_dump -c $DB_NAME" > ${WEBSITE_BASEDIR}/${DB_NAME}.$backup_date.sql 2> $log_file if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi fi echononl " Backup existing Database '$POSTFIX_DB_NAME'" if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then echo -n " (MySQL).." mysqldump $MYSQL_CREDENTIALS --opt $POSTFIX_DB_NAME > ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.$backup_date.sql 2> $log_file if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi elif [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then echo -n " (PostgreSQL).." su - postgres -c "pg_dump -c $POSTFIX_DB_NAME" > ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.$backup_date.sql 2> $log_file if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi fi echononl " Backup existing web-directory .." if [[ -d "$CUR_INSTALL_DIR" ]]; then mv "$CUR_INSTALL_DIR" "${CUR_INSTALL_DIR}.$backup_date" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi else fatal "No current installation of roundcube found!" fi echo -e "\n\n \033[37m\033[1mDownloud/Unpack source archive..\033[m\n" echononl " Download 'roundcubemail-${ROUNDCUBE_VERSION}'.." if [[ ! -f "$script_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then wget -O ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz https://github.com/roundcube/roundcubemail/releases/download/${ROUNDCUBE_VERSION}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi echononl " Remove existing source directory" if [[ -d "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then rm -rf "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi echononl " Unpack roundcube source archive.." gunzip < ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz | tar -C ${script_dir} -xf - > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi echo -e "\n\n \033[37m\033[1mSome pre-installation tasks..\033[m\n" ## - Disable crontab for user root ## - echononl " Backup crontab" crontab -u root -l >> $crontab_backup_file 2> $log_file if [[ "$?" = "0" ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi echononl " Disable crontab for user root" crontab -r -u root > $log_file 2>&1 if [[ "$?" = "0" ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi echononl " Stop Apache Webserver.." if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then 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 echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped warn "Neither an init-script nor a service file for 'apache2' webservice found!" fi # - Stop all PHP FPM engines # - if [[ -n "$php_major_versions" ]]; then for _ver in $php_major_versions ; do echononl " Stop PHP FPM engine v${_ver}.." if [[ -f "/etc/init.d/php-${_ver}-fpm" ]]; then /etc/init.d/php-${_ver}-fpm stop > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi elif [[ -f "/etc/systemd/system/php-${_ver}-fpm.service" ]] ; then systemctl stop php-${_ver}-fpm > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi done else if $PHP_DEBIAN_INSTALLATION ; then echononl " Stop PHP FPM engine v${php_major_version}.." if [[ -f "/etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm" ]] ; then /etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm stop > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi else echo_skipped fi fi echo -e "\n\n \033[37m\033[1mUgrade Roundcube Webmail..\033[m\n" echononl " Copy current web-directory into a the new one.." cp -a "${CUR_INSTALL_DIR}.$backup_date" "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi echononl " Set actual timestamp to the new web-directory" touch -t "$(date +%Y%m%d%H%M.%S)" "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi echononl " Change into new roundcube source directory" cd "${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi echononl " Create log-directory for update log file" if [[ ! -d "${script_dir}/log" ]]; then mkdir "${script_dir}/log" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi else echo_skipped fi echo "" echo " Update the the roundcube web-directory to version '${ROUNDCUBE_VERSION}'" echononl " See: ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log" echo "y" | ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fi echo "" echononl " Change into new roundcube web directory" cd "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $log_file)" fi echononl " Update dependencies by running 'php composer.phar update --no-dev'" php composer.phar --no-interaction update --no-dev > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "command was:\n\t # cd "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}"\n\t #php composer.phar --no-interaction update --no-dev\n\n$(cat ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log)" echononl "continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do echononl "Wrong entry! - repeat [yes/no]: " read OK done [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi echononl " Index build-in addressbook" ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/indexcontacts.sh > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "command was:\n\t # ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/indexcontacts.sh\n\n$(cat $log_file)" echononl "continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do echononl "Wrong entry! - repeat [yes/no]: " read OK done [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi _failed=false echononl " Symlink DocumentRoot to the new installation directory.." if [[ -h "${WEBSITE_BASEDIR}/htdocs" ]]; then rm "${WEBSITE_BASEDIR}/htdocs" > $log_file 2>&1 if [[ $? -ne 0 ]]; then _failed=true fi elif [[ -f "${WEBSITE_BASEDIR}/htdocs" ]]; then mv "${WEBSITE_BASEDIR}/htdocs" "${WEBSITE_BASEDIR}/htdocs/.$backup_date" > $log_file 2>&1 if [[ $? -ne 0 ]]; then _failed=true fi fi ln -s "roundcubemail-${ROUNDCUBE_VERSION}" "${WEBSITE_BASEDIR}/htdocs" >> $log_file 2>&1 if [[ $? -ne 0 ]]; then _failed=true fi if $_failed ; then echo_failed error "$(cat $log_file)" else echo_ok fi echo -e "\n\n \033[37m\033[1mSome post-installation tasks..\033[m\n" # - Start all PHP FPM engines # - if [[ -n "$php_major_versions" ]]; then for _ver in $php_major_versions ; do echononl " Start PHP FPM engine v${_ver}.." if [[ -f "/etc/init.d/php-${_ver}-fpm" ]]; then /etc/init.d/php-${_ver}-fpm start > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi elif [[ -f "/etc/systemd/system/php-${_ver}-fpm.service" ]] ; then systemctl start php-${_ver}-fpm > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi done else if $PHP_DEBIAN_INSTALLATION ; then echononl " Start PHP FPM engine v${php_major_version}.." if [[ -f "/etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm" ]] ; then /etc/init.d/php$(echo $php_major_version | cut -d'.' -f1)-fpm start > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped fi else echo_skipped fi fi # - Start Apache Webserver # - echononl " Start Apache Webserver.." if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then if [[ -n "$APACHE_SERVICE_FILE" ]] ; then systemctl start $APACHE_SERVICE_FILE > $log_file 2>&1 else $APACHE_INIT_SCRIPT start > $log_file 2>&1 fi if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi else echo_skipped warn "Neither an init-script nor a service file for 'apache2' webservice found!" fi echononl " Renstall previously saved crontab from '$crontab_backup_file'.." crontab $crontab_backup_file > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi echononl " Delete previously saved crontab file '$crontab_backup_file'.." rm "$crontab_backup_file" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi echo "" clean_up 0