From a84ca0aa6f540a2170dec716390061970a16cc57 Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 12 Oct 2017 03:44:16 +0200 Subject: [PATCH] New upgrade script 'upgrade_roundcube.sh'. --- .gitignore | 1 + conf/install_roundcube.conf.sample | 354 ------------------ upgrade_roundcube.sh | 563 +++++++++++++++++++++++++++++ 3 files changed, 564 insertions(+), 354 deletions(-) delete mode 100644 conf/install_roundcube.conf.sample create mode 100755 upgrade_roundcube.sh diff --git a/.gitignore b/.gitignore index 12908e9..756be0f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /BAK/* +/log/* /conf/*.conf roundcubemail-* *.swp diff --git a/conf/install_roundcube.conf.sample b/conf/install_roundcube.conf.sample deleted file mode 100644 index 405c352..0000000 --- a/conf/install_roundcube.conf.sample +++ /dev/null @@ -1,354 +0,0 @@ -# -------------------------------------------- -# - Configuration for roundcube install script -# -------------------------------------------- - -# - Version of the Roundcube Webmailer to install -# - -ROUNDCUBE_VERSION="" - -# - Name of the website - usualy 'webmail..' -# - -WEBSITE_NAME="" - -# - IPv4 Address -# - -IPV4="" - -# - IPv6 Address -# - -IPV6="" - -# - Is apache installed from debian package system ? -# - -# - Boolean, possible values are 'true', 'false' -# - -# - Defaults to 'false' -# -#APACHE_DEBIAN_INSTALLATION="" - -# - Apache User -# - -# - If ommitted, script tries to determine the user under which user the webserver -# - is running. If that fails, parameter defaults to 'www-data' -# - -#HTTP_USER="" - -# - Apache Group -# - -# - If ommitted, script tries to determine the user under which group the webserver -# - is running. If that fails, parameter defaults to 'www-data' -# - -#HTTP_GROUP="" - -# - Webmasters E-Mail Address -# - -# - Defaults to 'admin@.' -# - -#WEBMASTER_EMAIL="" - -# - Base Directory of Roundcube Website -# - -# - Note: it's not the 'DocumentRoot' directory, but the directory where -# - the 'DocumentRoot' Directory lives. -# - -# - Defaults to '/var/www/webmail/$WEBSITE_NAME' -# - -#WEBSITE_BASEDIR="" - - -# - Directory for storing temporary files -# - -# - Defaults to '${WEBMAIL_BASEDIR}/temp" -# - -#ROUNDCUBE_TMPDIR="" - -# - Directory, where apache places the log-files for thw webmailers site. -# - -# - Defaults to '/var/log/apache2' -# - -#APACHE_LOG_DIR="" - -# - Directory where certificate and key for the roundcube website -# - are stored. -# - -# - Example: -# - APACHE_CERT_DIR="/var/lib/dehydrated/certs/$WEBSITE_NAME" -# - -# - Defaults to -# - '/etc/apache2' if apache is installed from debian package system -# - '/usr/local/apache2/conf' otherwise -# - -#APACHE_CERT_DIR="" - -# - Certificate for the Rounfcube Website -# - -# - Example: -# - APACHE_SERVER_CERT="fullchain.pem" -# - -# - Defaults to 'server-bundle.crt' -# - -#APACHE_SERVER_CERT="" - -# - Key File for the Rounfcube Website -# - -# - Example: -# - APACHE_SERVER_KEY="privkey.pem" -# - -# - Defaults to 'server.key' -# - -#APACHE_SERVER_KEY="" - -# - Certification Chain File -# - -# - Deprecated since Apache 2.4 - Leave empty if not present -# - -#CERT_ChainFile="" - -# - Type of PHP installation. -# - -# - Possible values are: 'php_fpm' , 'fcgid' , 'mod_php -# - -# - defaults to 'php_fpm'' -# - -#PHP_TYPE="" - -# - Directory where apache vhosts definitions live. -# - -# - Defaults to -# - '/etc/apache2/sites-available' if installed from debain package system -# - '/usr/local/apache2/conf/vhosts' otherwise -# - -#APACHE_VHOST_DIR="" - -# - Hostname for vacation / absence messages -# - -# - Defaults to 'autoreply.. -# - -#AUTOREPLY_HOSTNAME="" - -# - Database type for Roundcube -# - -# - Possible values are 'pgsql' (PostgeSQL) or 'mysql' (MySQL) -# - -DB_TYPE="" - -# - Host of Roundcube Database -# - -# - Defaults to 'localhost' -# - -#DB_HOST="" - -# - Name of Roundcube Database -# - -# - Defaults to 'roundcubemail' -# - -#DB_NAME= - -# - User of Roundcube Database -# - -# - Defaults to 'roundcube' -# - -#DB_USER="" - -# - Password of Roundcube Database -# - -DB_PASS="" - - -# - Is MySQL installed from debian package system? -# - -# - Only needed, if DB_TYPE is set to 'mysql' -# - -# - Defaults to 'false' -# - -#MYSQL_DEBIAN_INSTALLATION="" - -# - mysql_credential_args (root access to MySQL Database) -# - -# - Example -# - mysql_credential_args="--login-path=local" -# - mysql_credential_args="--defaults-file=/etc/mysql/debian.cnf" (Debian default) -# - mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf" -# - -# - Defaults to: -# - '/etc/mysql/debian.cnf' if MySQL is installed from debian package system -# - '/usr/local/mysql/sys-maint.cnf' otherwise -# - -#MYSQL_CREDENTIALS="" - -# - Name of the folder where (assumed) junk mails will be stored -# - -# - Defaults to 'Spam' -# - -#SPAM_FOLDER_NAME="" - -# - You can set your own product name to replace the default. -# - -# - Defaults to 'Roundcube Webmail' -# - -#PRODUCT_NAME="" - -# - URL for users, to get in contact if something goes wrong -# - -# - Defaults to 'www..' -# - -#SUPPORT_URL="" - -# - Provide your own logo under this URI -# - -# - Note: this script will NOT place the logo. You have to do this by your own -# - after installation is finisched. -# - -# - Default is empty -# - -#SKIN_LOGO="" - - - -# -------------------- -# - Plugins Configuration -# -------------------- - - -# ========== -# - Settings Postfix Database -# ========== - -# - Type of Postfix database -# - -# - used for setting $config['password_db_dsn'] -# - -# - Possible values are 'pgsql' (PostgeSQL) or 'mysql' (MySQL) -# - -POSTFIX_DB_TYPE="pgsql" - -# - Host of Postfix Database -# - -# - used for setting $config['password_db_dsn'] -# - -# - Defaults to 'localhost' -# - -#POSTFIX_DB_HOST="" - -# - Name of Postfix Database -# - -# - used for setting $config['password_db_dsn'] -# - -# - Defaults to 'postfix' -# - -#POSTFIX_DB_NAME= - -# - User of Postfix Database -# - -# - used for setting $config['password_db_dsn'] -# - -# - Defaults to 'postfix' -# - -#POSTFIX_DB_USER="" - -# - Password of Postfix Database -# - -# - used for setting $config['password_db_dsn'] -# - -POSTFIX_DB_PASSWD='' - - -# === -# - Plugin acl -# === - -# - Activate plugin 'acl'? -# - -# - Boolean - possible values are 'true' and 'false' -# - -# - Defaults to 'false' -# - -#INCLUDE_ACL_PLUGIN="" - - -# === -# - Plugin password (change password) -# === - -# - Is current password reqired -# - -# - $config['password_confirm_current'] -# - -# - Boolean - possible values are 'true' and 'false' -# - -# - Defaults to 'true' -# - -#PW_CONFIRM_CURRENT="" - -# - Minimun length if new password -# - -# - $config['password_minimum_length'] -# - -# - Defaults to '10' -# - -#PW_MIN_LENGTH="" - -# - New Password requires nonalpha character -# - -# - $config['password_require_nonalpha'] -# - -# - Boolean - possible values are 'true' and 'false' -# - -# - Defaults to 'true' -# - -#PW_REQUIRE_NONALPHA='' - -# - Default password hashing/crypting algorithm. -# - -# - $config['password_algorithm'] -# - -# - Possible values: des-crypt, ext-des-crypt, md5-crypt, blowfish-crypt, -# - sha256-crypt, sha512-crypt, md5, sha, smd5, ssha, samba, -# - ad, dovecot, clear. -# - -# - Defaults to 'dovecot' -# - -#PW_PASSWD_ALGO='' - -# - Password prefix (e.g. {CRYPT}, {SHA}, {CRAM-MD5}) for passwords generated -# - -# - $config['password_algorithm_prefix'] -# - -# - Defaults to '{CRAM-MD5}' -# - -#PW_PASSWD_ALGO_PREFIX='' - -# - Path for dovecotpw/doveadm-pw -# - -# - $config['password_dovecotpw'] -# - -# - Defaults to '/usr/local/dovecot/bin/doveadm pw' -# - -#PW_DOVEADM_PW='' - -# - Dovecot password scheme. -# - -# - $config['password_dovecotpw_method'] -# - -# - Defaults to 'CRAM-MD5 -# - -#PW_DOVECOT_PW_METHOD= - -# - The SQL query used to change the password. -# - -# - $config['password_query'] -# - -PW_DB_UPDATE_STRING='UPDATE mailbox SET password=%P WHERE username=%u' - - -# ========== -# - Plugin password vacation -# ========== - -# - allow vacation forwarder -# - -# - $rcmail_config['vacation_gui_vacationforwarder'] = FALSE; -# - -# - defaults to 'false' -# - -#VAC_GUI_FORWARDER=false diff --git a/upgrade_roundcube.sh b/upgrade_roundcube.sh new file mode 100755 index 0000000..26eec8f --- /dev/null +++ b/upgrade_roundcube.sh @@ -0,0 +1,563 @@ +#!/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" +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 "" +} + + +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 ? +# - +if [[ "X$(which systemd)" = "X" ]]; then + SYSTEMD_EXISTS=false +else + SYSTEMD_EXISTS=true +fi + + + +DEFAULT_DB_HOST="localhost" +DEFAULT_DB_NAME="roundcubemail" +DEFAULT_DB_USER="roundcube" + +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 "$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 "$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 + fatal "Version '${ROUNDCUBE_VERSION}' is already installed" +fi + + +echo "" +echo "" +echo -e "\033[1;32mSettings for installation of \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 "" +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 -u$_mysql_rootuser -p$_mysql_rootpass --opt $DB_NAME > ${WEBSITE_BASEDIR}/${DB_NAME}.$backup_date 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 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 "$_src_base_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then + wget -O ${_src_base_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 "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then + rm -rf "${_src_base_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 < ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz | tar -C ${_src_base_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" +echo "" >> ${logdir}/main.log +echo "crontab -u root -l > $crontab_backup_file" >> ${logdir}/main.log +crontab -u root -l >> $crontab_backup_file 2>> ${logdir}/main.log +if [[ "$?" = "0" ]]; then + echo_ok +else + echo_failed +fi + +echononl " Disable crontab for user root" +echo "" >> ${logdir}/main.log +echo "crontab -r -u root" >> ${logdir}/main.log +crontab -r -u root >> ${logdir}/main.log 2>&1 +if [[ "$?" = "0" ]]; then + echo_ok +else + echo_failed +fi + + +echononl " Stop Apache Webserver.." +if $SYSTEMD_EXISTS ; then + systemctl stop apache2 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +else + /etc/init.d/apache2 stop + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +fi + + + +# - Determin PHP of all installed versions +# - +echononl "\tGet major version of all installed PHP versions" +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 + +# - 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 +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 "${_src_base_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 "${_src_base_dir}/log" ]]; then + mkdir "${_src_base_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: ${_src_base_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log" +echo "y" | ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${_src_base_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 " 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 "$(cat $log_file)" +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 +fi + +# - Start Apache Webserver +# - +echononl " Start Apache Webserver.." +if $SYSTEMD_EXISTS ; then + systemctl start apache2 > $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +else + /etc/init.d/apache2 start> $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "$(cat $log_file)" + fi +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 +