- Adjust sample configuration file.
- Support composer for installing roundcube's dependencies (PHP + JS).
This commit is contained in:
		| @@ -71,6 +71,9 @@ IPV6="" | |||||||
| # - Directory where certificate and key for the roundcube website | # - Directory where certificate and key for the roundcube website | ||||||
| # - are stored. | # - are stored. | ||||||
| # - | # - | ||||||
|  | # - Example: | ||||||
|  | # -    APACHE_CERT_DIR="/var/lib/dehydrated/certs/$WEBSITE_NAME" | ||||||
|  | # - | ||||||
| # - Defaults to | # - Defaults to | ||||||
| # -    '/etc/apache2' if apache is installed from debian package system | # -    '/etc/apache2' if apache is installed from debian package system | ||||||
| # -    '/usr/local/apache2/conf' otherwise | # -    '/usr/local/apache2/conf' otherwise | ||||||
| @@ -79,12 +82,18 @@ IPV6="" | |||||||
|  |  | ||||||
| # - Certificate for the Rounfcube Website | # - Certificate for the Rounfcube Website | ||||||
| # - | # - | ||||||
|  | # - Example: | ||||||
|  | # -    APACHE_SERVER_CERT="fullchain.pem" | ||||||
|  | # - | ||||||
| # - Defaults to 'server-bundle.crt' | # - Defaults to 'server-bundle.crt' | ||||||
| # - | # - | ||||||
| #APACHE_SERVER_CERT="" | #APACHE_SERVER_CERT="" | ||||||
|  |  | ||||||
| # - Key File for the Rounfcube Website | # - Key File for the Rounfcube Website | ||||||
| # - | # - | ||||||
|  | # - Example: | ||||||
|  | # -    APACHE_SERVER_KEY="privkey.pem" | ||||||
|  | # - | ||||||
| # - Defaults to 'server.key' | # - Defaults to 'server.key' | ||||||
| # - | # - | ||||||
| #APACHE_SERVER_KEY="" | #APACHE_SERVER_KEY="" | ||||||
| @@ -241,7 +250,7 @@ POSTFIX_DB_TYPE="pgsql" | |||||||
| # - | # - | ||||||
| # -    used for setting  $config['password_db_dsn'] | # -    used for setting  $config['password_db_dsn'] | ||||||
| # - | # - | ||||||
| POSTFIX_DB_PASSWD='CbX8vg347Vvm' | POSTFIX_DB_PASSWD='' | ||||||
|  |  | ||||||
|  |  | ||||||
| # === | # === | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ conf_file="${_src_base_dir}/conf/install_roundcube.conf" | |||||||
| curdir=`pwd` | curdir=`pwd` | ||||||
|  |  | ||||||
| log_file="$(mktemp)" | log_file="$(mktemp)" | ||||||
|  | backup_date="$(date +%Y-%m-%d-%H%M)" | ||||||
|  |  | ||||||
|  |  | ||||||
| # ------------- | # ------------- | ||||||
| @@ -242,7 +243,7 @@ fi | |||||||
| [[ -n "$PW_MIN_LENGTH" ]] || PW_MIN_LENGTH=10 | [[ -n "$PW_MIN_LENGTH" ]] || PW_MIN_LENGTH=10 | ||||||
| [[ -n "$PW_REQUIRE_NONALPHA" ]] || PW_REQUIRE_NONALPHA=true | [[ -n "$PW_REQUIRE_NONALPHA" ]] || PW_REQUIRE_NONALPHA=true | ||||||
| [[ -n "$PW_PASSWD_ALGO" ]] || PW_PASSWD_ALGO="dovecot" | [[ -n "$PW_PASSWD_ALGO" ]] || PW_PASSWD_ALGO="dovecot" | ||||||
| [[ -n "$PW_PASSWD_ALGO_PREFIX" ]] || PW_PASSWD_ALGO_PREFIX="{CRAM-MD5}" | #[[ -n "$PW_PASSWD_ALGO_PREFIX" ]] || PW_PASSWD_ALGO_PREFIX="{CRAM-MD5}" | ||||||
|  |  | ||||||
| [[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Plugin password: Database Type for Password Database (POSTFIX_DB_TYPE) not given!" | [[ -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 | if [[ "$POSTFIX_DB_TYPE" != "pgsql" ]] && [[ "$POSTFIX_DB_TYPE" != "mysql" ]]; then | ||||||
| @@ -367,37 +368,36 @@ _log_dir=${_src_base_dir}/log-roundcube-$_version | |||||||
| ## ---------------------------- | ## ---------------------------- | ||||||
| ## - Begin Installation | ## - Begin Installation | ||||||
|  |  | ||||||
| ## - REQUIREMENTS | # - REQUIREMENTS | ||||||
| ## - ============ | # - ============ | ||||||
| ## -  | # -  | ||||||
| ## - * The Apache, Lighttpd, Cherokee or Hiawatha web server | # - * An IMAP, HTTP and SMTP server | ||||||
| ## - * .htaccess support allowing overrides for DirectoryIndex | # - * .htaccess support allowing overrides for DirectoryIndex | ||||||
| ## - * PHP Version 5.2.1 or greater including | # - * PHP Version 5.4 or greater including: | ||||||
| ## -    - PCRE, DOM, JSON, XML, Session, Sockets (required) | # -    - PCRE, DOM, JSON, Session, Sockets, OpenSSL, Mbstring (required) | ||||||
| ## -    - libiconv (recommended) | # -    - PHP PDO with driver for either MySQL, PostgreSQL, SQL Server, Oracle or SQLite (required) | ||||||
| ## -    - mbstring, fileinfo, mcrypt (optional) | # -    - Iconv, Zip, Fileinfo, Intl, Exif (recommended) | ||||||
| ## - * PEAR packages distributed with Roundcube or external: | # -    - LDAP for LDAP addressbook support (optional) | ||||||
| ## -    - MDB2 2.5.0 or newer | # - * PEAR and PEAR packages distributed with Roundcube or external: | ||||||
| ## -    - Mail_Mime 1.8.1 or newer | # -    - Mail_Mime 1.10.0 or newer | ||||||
| ## -    - Mail_mimeDecode 1.5.5 or newer | # -    - Net_SMTP 1.7.1 or newer | ||||||
| ## -    - Net_SMTP 1.4.2 or newer | # -    - Net_Socket 1.0.12 or newer | ||||||
| ## -    - Net_IDNA2 0.1.1 or newer | # -    - Net_IDNA2 0.1.1 or newer | ||||||
| ## -    - Auth_SASL 1.0.6 or newer | # -    - Auth_SASL 1.0.6 or newer | ||||||
| ## - * php.ini options (see .htaccess file): | # -    - Net_Sieve 1.3.2 or newer (for managesieve plugin) | ||||||
| ## -    - error_reporting E_ALL & ~E_NOTICE (or lower) | # -    - Crypt_GPG 1.6.0 or newer (for enigma plugin) | ||||||
| ## -    - memory_limit > 16MB (increase as suitable to support large attachments) | # -    - Endroid/QrCode 1.6.0 or newer (https://github.com/endroid/QrCode) | ||||||
| ## -    - file_uploads enabled (for attachment upload features) | # - * php.ini options (see .htaccess file): | ||||||
| ## -    - session.auto_start disabled | # -    - error_reporting E_ALL & ~E_NOTICE & ~E_STRICT | ||||||
| ## -    - zend.ze1_compatibility_mode disabled | # -    - memory_limit > 16MB (increase as suitable to support large attachments) | ||||||
| ## -    - suhosin.session.encrypt disabled | # -    - file_uploads enabled (for attachment upload features) | ||||||
| ## -    - mbstring.func_overload disabled | # -    - session.auto_start disabled | ||||||
| ## -    - magic_quotes_runtime disabled | # -    - suhosin.session.encrypt disabled | ||||||
| ## -    - magic_quotes_sybase disabled | # -    - mbstring.func_overload disabled | ||||||
| ## - * PHP compiled with OpenSSL to connect to IMAPS and to use the spell checker | # - * A MySQL, PostgreSQL, MS SQL Server (2005 or newer), Oracle database | ||||||
| ## - * A MySQL (4.0.8 or newer), PostgreSQL, MSSQL database engine | # -   or SQLite support in PHP - with permission to create tables | ||||||
| ## -   or the SQLite extension for PHP | # - * Composer installed either locally or globally (https://getcomposer.org) | ||||||
| ## - * One of the above databases with permission to create tables |  | ||||||
| ## - * An SMTP server (recommended) or PHP configured for mail delivery |  | ||||||
|  |  | ||||||
| needed_php_pear_modules=" | needed_php_pear_modules=" | ||||||
|    MDB2 |    MDB2 | ||||||
| @@ -448,13 +448,57 @@ for _version in $php_major_versions ; do | |||||||
| done | done | ||||||
|  |  | ||||||
|  |  | ||||||
| echo -e "\n\n\t\033[37m\033[1mBase install Roundcube Webmail..\033[m\n" | echo -e "\n\n\t\033[37m\033[1mInstall (global) composer..\033[m\n" | ||||||
|  |  | ||||||
| # - install roundcube | echononl "\tDownload composer from 'getcomposer.org'.." | ||||||
| # - | php -r "copy('https://getcomposer.org/installer', '${_src_base_dir}/composer-setup.php');" > $log_file 2>&1 | ||||||
| echononl "\tDownload 'roundcubemail-${ROUNDCUBE_VERSION}'.." | if [[ "$?" = "0" ]]; then | ||||||
| if [[ ! -f "$_src_base_dir/roundcubemail-${ROUNDCUBE_VERSION}.tar.gz" ]]; then | 	echo_ok | ||||||
|    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 | else | ||||||
|  | 	echo_failed | ||||||
|  | 	error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tInstall composer to /usr/local/bin" | ||||||
|  | php ${_src_base_dir}/composer-setup.php --install-dir=/usr/local/bin --filename=composer > $log_file 2>&1 | ||||||
|  | if [[ "$?" = "0" ]]; then | ||||||
|  | 	echo_ok | ||||||
|  | else | ||||||
|  | 	echo_failed | ||||||
|  | 	error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tRemove the installer" | ||||||
|  | php -r "unlink('${_src_base_dir}/composer-setup.php');" > $log_file 2>&1 | ||||||
|  | if [[ "$?" = "0" ]]; then | ||||||
|  | 	echo_ok | ||||||
|  | else | ||||||
|  | 	echo_failed | ||||||
|  | 	error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echo -e "\n\n\t\033[37m\033[1mCreate some Backups..\033[m\n" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echononl "\tBackup existing source directory 'roundcubemail-${ROUNDCUBE_VERSION}'.." | ||||||
|  | if [[ -d "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]] ;then | ||||||
|  |    mv ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION} \ | ||||||
|  |       ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.$backup_date > $log_file 2>&1 | ||||||
|  |    if [[ $? -eq 0 ]]; then | ||||||
|  |        echo_ok | ||||||
|  |    else | ||||||
|  |       echo_failed | ||||||
|  |       error "$(cat $log_file)" | ||||||
|  |    fi | ||||||
|  | else | ||||||
|  |    echo_skipped | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tBackup existing web-directory 'roundcubemail-${ROUNDCUBE_VERSION}'.." | ||||||
|  | if [[ -d "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then | ||||||
|  |    mv ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} \ | ||||||
|  |       ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}.$backup_date > $log_file 2>&1 | ||||||
|    if [[ $? -eq 0 ]]; then |    if [[ $? -eq 0 ]]; then | ||||||
|        echo_ok |        echo_ok | ||||||
|    else |    else | ||||||
| @@ -466,10 +510,13 @@ else | |||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
| echononl "\tBackup existing source directory 'roundcubemail-${ROUNDCUBE_VERSION}'.." | echo -e "\n\n\t\033[37m\033[1mBase install Roundcube Webmail..\033[m\n" | ||||||
| if [[ -d "${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}" ]] ;then |  | ||||||
|    mv ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION} \ | # - install roundcube | ||||||
|       ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION}.`date +%Y%m%d-%H%M` > $log_file 2>&1 | # - | ||||||
|  | echononl "\tDownload '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 |    if [[ $? -eq 0 ]]; then | ||||||
|        echo_ok |        echo_ok | ||||||
|    else |    else | ||||||
| @@ -502,10 +549,76 @@ else | |||||||
|    echo_skipped |    echo_skipped | ||||||
| fi | fi | ||||||
|  |  | ||||||
| echononl "\tBackup existing web-directory 'roundcubemail-${ROUNDCUBE_VERSION}'.." | echononl "\tCopy Roundcube to web-directory" | ||||||
| if [[ -d "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" ]]; then | cp -a ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION} $WEBSITE_BASEDIR/ > $log_file 2>&1 | ||||||
|    mv ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} \ | if [[ $? -eq 0 ]]; then | ||||||
|       ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}.`date +%Y%m%d-%H%M` > $log_file 2>&1 |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tChange owner/group for Roundcube Webdirectory.." | ||||||
|  | chown -R ${HTTP_USER}:$HTTP_GROUP $WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION} > $log_file 2>&1 | ||||||
|  | if [[ $? -eq 0 ]]; then | ||||||
|  |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echononl "\tChange into Roundcube Webdirectory.." | ||||||
|  | cd "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > $log_file 2>&1 | ||||||
|  | if [[ $? -eq 0 ]]; then | ||||||
|  |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tRename the composer.json-dist file into composer.json" | ||||||
|  | cp -a "composer.json-dist" "composer.json" > $log_file 2>&1 | ||||||
|  | if [[ $? -eq 0 ]]; then | ||||||
|  |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echononl "\tInstall PHP dependencies.." | ||||||
|  | #/usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev | ||||||
|  | su www-data -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} | ||||||
|  |    /usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev" -s /bin/bash \ | ||||||
|  |    > $log_file 2>&1 | ||||||
|  | if [[ $? -eq 0 ]]; then | ||||||
|  |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tInstall Javascript dependencies.." | ||||||
|  | ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/bin/install-jsdeps.sh > $log_file 2>&1 | ||||||
|  | if [[ $? -eq 0 ]]; then | ||||||
|  |       echo_ok | ||||||
|  | else | ||||||
|  |    echo_failed | ||||||
|  |    error "$(cat $log_file)" | ||||||
|  | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | # - Install a cronjob for cleaning up database | ||||||
|  | # - | ||||||
|  | echononl "\tInstall a cronjob for cleaning up database" | ||||||
|  | crontab -l > /tmp/tmp_crontab | ||||||
|  | if ! grep -q -E "${WEBSITE_BASEDIR}/htdocs/bin/cleandb.sh" /tmp/tmp_crontab 2> /dev/null ; then | ||||||
|  | 	echo "" >> /tmp/tmp_crontab | ||||||
|  | 	echo "# - Keep roundcube database slick and clean" >> /tmp/tmp_crontab | ||||||
|  | 	echo "# -" >> /tmp/tmp_crontab | ||||||
|  | 	echo "37 3 * * * ${WEBSITE_BASEDIR}/htdocs/bin/cleandb.sh" >> /tmp/tmp_crontab | ||||||
|  | 	crontab /tmp/tmp_crontab > $log_file 2>&1 | ||||||
| 	if [[ $? -eq 0 ]]; then | 	if [[ $? -eq 0 ]]; then | ||||||
| 		echo_ok | 		echo_ok | ||||||
| 	else | 	else | ||||||
| @@ -516,14 +629,6 @@ else | |||||||
| 	echo_skipped | 	echo_skipped | ||||||
| fi | fi | ||||||
|  |  | ||||||
| echononl "\tCopy Roundcube to web-directory" |  | ||||||
| cp -a ${_src_base_dir}/roundcubemail-${ROUNDCUBE_VERSION} $WEBSITE_BASEDIR/ > $log_file 2>&1 |  | ||||||
| if [[ $? -eq 0 ]]; then |  | ||||||
|       echo_ok |  | ||||||
| else |  | ||||||
|    echo_failed |  | ||||||
|    error "$(cat $log_file)" |  | ||||||
| fi |  | ||||||
|  |  | ||||||
| echononl "\tSet Permissions 'root:root' on \n\t   ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" | echononl "\tSet Permissions 'root:root' on \n\t   ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" | ||||||
| chown -R root:root $WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION} > $log_file 2>&1 | chown -R root:root $WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION} > $log_file 2>&1 | ||||||
| @@ -648,19 +753,6 @@ else | |||||||
|    echo_skipped |    echo_skipped | ||||||
| fi | fi | ||||||
|  |  | ||||||
| echononl "\tCreate Web-Directory '$WEBSITE_BASEDIR'.." |  | ||||||
| if [[ ! -d "$WEBSITE_BASEDIR" ]]; then |  | ||||||
|    mkdir $WEBSITE_BASEDIR |  | ||||||
|    if [[ "$?" = "0" ]]; then |  | ||||||
|       echo_ok |  | ||||||
|    else |  | ||||||
|       echo_failed |  | ||||||
|       error "$(cat $log_file)" |  | ||||||
|    fi |  | ||||||
| else |  | ||||||
|    echo_skipped |  | ||||||
| fi |  | ||||||
|  |  | ||||||
|  |  | ||||||
| if [[  "$PHP_TYPE" = "fcgid" ]] ; then | if [[  "$PHP_TYPE" = "fcgid" ]] ; then | ||||||
|  |  | ||||||
| @@ -951,7 +1043,7 @@ echo "" | |||||||
| echononl "\tSave existing vhost file.." | echononl "\tSave existing vhost file.." | ||||||
| if [ -f ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf ];then | if [ -f ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf ];then | ||||||
|    if [[ -f "${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf" ]]; then |    if [[ -f "${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf" ]]; then | ||||||
|       mv ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf.`date +%Y%m%d-%H%M`  > $log_file 2>&1 |       mv ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf.$backup_date  > $log_file 2>&1 | ||||||
|       if [[ $? -eq 0 ]]; then |       if [[ $? -eq 0 ]]; then | ||||||
|          echo_ok |          echo_ok | ||||||
|       else |       else | ||||||
| @@ -1321,26 +1413,43 @@ echo -e "\n\n\t\033[37m\033[1mSetup Database '$DB_TYPE'..\033[m\n" | |||||||
| # - MySQL/PostgreSQL Datenbank erstellen | # - MySQL/PostgreSQL Datenbank erstellen | ||||||
| # - | # - | ||||||
| # - | # - | ||||||
| echo "" |  | ||||||
| echononl "\tCreate Database '$DB_NAME'" | 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 $POSTFIX_DB_NAME >> $log_file 2>&1 ; then | ||||||
|  | 		database_exists=false | ||||||
|  |    else | ||||||
|  |       database_exists=true | ||||||
|  |    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 | ||||||
|  | 		database_exists=false | ||||||
|  | 	else | ||||||
|  |       database_exists=true | ||||||
|  |    fi | ||||||
|  | else | ||||||
|  |    fatal "Cannot detect database type (value of  DB_TYPE is neither 'mysql' nor 'pgsql')" | ||||||
|  | fi | ||||||
|  |  | ||||||
| _failed=false | _failed=false | ||||||
| if [ "$DB_TYPE" = "mysql" ]; then | echononl "\tCreate Database '$DB_NAME'" | ||||||
|  | if ! $database_exists ; then | ||||||
|  | 	if [[ "$DB_TYPE" = "mysql" ]]; then | ||||||
| 		echo -n " (MySQL).." | 		echo -n " (MySQL).." | ||||||
|    if ! mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e \ |  | ||||||
|       "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>/dev/null \ |  | ||||||
|       | grep $DB_NAME > /dev/null 2>&1 ; then |  | ||||||
| 		mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e \ | 		mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e \ | ||||||
|          "CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET utf8 COLLATE utf8_general_ci" |          "CREATE DATABASE IF NOT EXISTS $DB_NAME CHARACTER SET utf8 COLLATE utf8_general_ci" | ||||||
|       if [[ $0 -ne 0 ]]; then |       if [[ $? -ne 0 ]]; then | ||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
| 		mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e \ | 		mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e \ | ||||||
|          "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS'" |          "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS'" | ||||||
|       if [[ $0 -ne 0 ]]; then |       if [[ $? -ne 0 ]]; then | ||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|       mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e "FLUSH PRIVILEGES" |       mysql -u$_mysql_rootuser -p$_mysql_rootpass -N -s -e "FLUSH PRIVILEGES" | ||||||
|       if [[ $0 -ne 0 ]]; then |       if [[ $? -ne 0 ]]; then | ||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|       if ! $_failed ; then |       if ! $_failed ; then | ||||||
| @@ -1348,20 +1457,15 @@ if [ "$DB_TYPE" = "mysql" ]; then | |||||||
|       else |       else | ||||||
|          echo_failed |          echo_failed | ||||||
|       fi |       fi | ||||||
|    else | 	elif [[ "$DB_TYPE" = "pgsql" ]]; then  | ||||||
|       echo_skipped |  | ||||||
|    fi |  | ||||||
| elif [ "$DB_TYPE" = "pgsql" ]; then |  | ||||||
| 		echo -n " (PostgreSQL).." | 		echo -n " (PostgreSQL).." | ||||||
|    count=`su - postgres -c "psql -q -A -t -l" | grep -c -e "^$DB_NAME"` |  | ||||||
|    if [ $count -eq 0 ];then |  | ||||||
| 		echo "CREATE ROLE $DB_USER WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$DB_PASS'" \ | 		echo "CREATE ROLE $DB_USER WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$DB_PASS'" \ | ||||||
|          | su - postgres -c "psql" > /dev/null |          | su - postgres -c "psql" > /dev/null | ||||||
|       if [[ $0 -ne 0 ]]; then |       if [[ $? -ne 0 ]]; then | ||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|       su - postgres -c "createdb -E utf8 -O $DB_USER $DB_NAME" |       su - postgres -c "createdb -E utf8 -O $DB_USER $DB_NAME" | ||||||
|       if [[ $0 -ne 0 ]]; then |       if [[ $? -ne 0 ]]; then | ||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|       if ! $_failed ; then |       if ! $_failed ; then | ||||||
| @@ -1369,8 +1473,31 @@ elif [ "$DB_TYPE" = "pgsql" ]; then | |||||||
|       else |       else | ||||||
|          echo_failed |          echo_failed | ||||||
|       fi |       fi | ||||||
|    else | 	fi | ||||||
|  | else | ||||||
| 	echo_skipped | 	echo_skipped | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | echononl "\tBackup existing Database '$DB_NAME'" | ||||||
|  | if $database_exists ; then | ||||||
|  | 	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 $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 | 	fi | ||||||
| else | else | ||||||
| 	echo_skipped | 	echo_skipped | ||||||
| @@ -1427,7 +1554,7 @@ read OK | |||||||
| if [[ "$OK" = "YES" ]] ; then | if [[ "$OK" = "YES" ]] ; then | ||||||
|    echo "" |    echo "" | ||||||
|    echo "" |    echo "" | ||||||
|    echo -e "\t\033[1;32mGoing to install Roundcube Webmailer \033[1;37m$network \033[m" |    echo -e "\t\033[1;32mGoing to configure Roundcube Webmailer \033[1;37m$network \033[m" | ||||||
|    echo "" |    echo "" | ||||||
| else | else | ||||||
|    warn "Abort by user request - Answer as not 'YES'" |    warn "Abort by user request - Answer as not 'YES'" | ||||||
| @@ -2009,7 +2136,7 @@ _plugin="vacation" | |||||||
| add_plugin_arr+=("$_plugin") | add_plugin_arr+=("$_plugin") | ||||||
|  |  | ||||||
| _config_file="${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/plugins/${_plugin}/config.inc.php" | _config_file="${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}/plugins/${_plugin}/config.inc.php" | ||||||
| _backup_file="${_config_file}.$(date +%Y-%m-%d-%H%M)" | _backup_file="${_config_file}.$backup_date" | ||||||
|  |  | ||||||
| echo -e "\n\t\033[32mPlugin '$_plugin'\033[m" | echo -e "\n\t\033[32mPlugin '$_plugin'\033[m" | ||||||
| echononl "\tDownload Pluging '$_plugin'.." | echononl "\tDownload Pluging '$_plugin'.." | ||||||
| @@ -2543,7 +2670,7 @@ EOF | |||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|  |  | ||||||
|       _pgppass_back_file="~/.pgpass.$(date +%Y-%m-%d-%H%M)" |       _pgppass_back_file="~/.pgpass.$backup_date" | ||||||
|       _pgpass_was_present=false |       _pgpass_was_present=false | ||||||
|       if [[ -f "~/.pgpass" ]]; then |       if [[ -f "~/.pgpass" ]]; then | ||||||
|          _pgpass_was_present=true |          _pgpass_was_present=true | ||||||
| @@ -2637,7 +2764,7 @@ EOF | |||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|  |  | ||||||
|       _pgppass_back_file="~/.pgpass.$(date +%Y-%m-%d-%H%M)" |       _pgppass_back_file="~/.pgpass.$backup_date" | ||||||
|       _pgpass_was_present=false |       _pgpass_was_present=false | ||||||
|       if [[ -f "~/.pgpass" ]]; then |       if [[ -f "~/.pgpass" ]]; then | ||||||
|          _pgpass_was_present=true |          _pgpass_was_present=true | ||||||
| @@ -2731,7 +2858,7 @@ EOF | |||||||
|          _failed=true |          _failed=true | ||||||
|       fi |       fi | ||||||
|  |  | ||||||
|       _pgppass_back_file="~/.pgpass.$(date +%Y-%m-%d-%H%M)" |       _pgppass_back_file="~/.pgpass.$backup_date" | ||||||
|       _pgpass_was_present=false |       _pgpass_was_present=false | ||||||
|       if [[ -f "~/.pgpass" ]]; then |       if [[ -f "~/.pgpass" ]]; then | ||||||
|          _pgpass_was_present=true |          _pgpass_was_present=true | ||||||
| @@ -2837,6 +2964,19 @@ else | |||||||
|    echo_skipped |    echo_skipped | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|  | echo -e "\n\n\t\033[37m\033[1mPost installation tasks\033[m" | ||||||
|  | echo "" | ||||||
|  |  | ||||||
|  | echononl "\tIndex 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 | ||||||
|  |  | ||||||
| echo "" | echo "" | ||||||
| echononl "\tRemove installer Folder.." | echononl "\tRemove installer Folder.." | ||||||
| rm -r $WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/installer > $log_file 2>&1 | rm -r $WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/installer > $log_file 2>&1 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user