|
|
@@ -1,177 +0,0 @@
|
|
|
-#!/bin/bash
|
|
|
-# info: Install Rainloop webmail client
|
|
|
-# options: [MODE]
|
|
|
-#
|
|
|
-# This function installs the Rainloop webmail client.
|
|
|
-
|
|
|
-#----------------------------------------------------------#
|
|
|
-# Variables & Functions #
|
|
|
-#----------------------------------------------------------#
|
|
|
-
|
|
|
-# Includes
|
|
|
-# shellcheck source=/etc/hestiacp/hestia.conf
|
|
|
-source /etc/hestiacp/hestia.conf
|
|
|
-# shellcheck source=/usr/local/hestia/func/main.sh
|
|
|
-source $HESTIA/func/main.sh
|
|
|
-# load config file
|
|
|
-source_conf "$HESTIA/conf/hestia.conf"
|
|
|
-# upgrade config file
|
|
|
-source "$HESTIA/install/upgrade/upgrade.conf"
|
|
|
-
|
|
|
-MODE=$1
|
|
|
-UPDATE="no"
|
|
|
-# Version and Download paths
|
|
|
-# Version to be moved to upgrade script
|
|
|
-RL_FILE="rainloop-latest.zip"
|
|
|
-# For removal of folder
|
|
|
-RL_EXTRACT_MAIN="rainloop"
|
|
|
-
|
|
|
-# Downloading full version
|
|
|
-RL_URL="https://www.rainloop.net/repository/webmail/rainloop-latest.zip"
|
|
|
-
|
|
|
-# Folder paths
|
|
|
-RL_INSTALL_DIR="/var/lib/rainloop"
|
|
|
-RL_CONFIG_DIR="/etc/rainloop"
|
|
|
-RL_LOG="/var/log/rainloop"
|
|
|
-
|
|
|
-#----------------------------------------------------------#
|
|
|
-# Verifications #
|
|
|
-#----------------------------------------------------------#
|
|
|
-
|
|
|
-# Checking root permissions
|
|
|
-if [ "x$(id -u)" != 'x0' ]; then
|
|
|
- echo "ERROR: v-add-sys-rainloop can only be executed by the root user"
|
|
|
- exit 10
|
|
|
-fi
|
|
|
-
|
|
|
-# Ensure that $HESTIA (/usr/local/hestia/) and other variables are valid.
|
|
|
-if [ -z "$HESTIA" ]; then
|
|
|
- HESTIA="/usr/local/hestia"
|
|
|
-fi
|
|
|
-
|
|
|
-if [ -z "$HOMEDIR" ] || [ -z "$HESTIA_INSTALL_DIR" ]; then
|
|
|
- echo "ERROR: Environment variables not present, installation aborted."
|
|
|
- exit 2
|
|
|
-fi
|
|
|
-
|
|
|
-# Get current version
|
|
|
-if [ -f "/var/lib/rainloop/data/VERSION" ]; then
|
|
|
- version=$(cat $RL_INSTALL_DIR/data/VERSION)
|
|
|
- if [ "$version" == "$rl_v" ]; then
|
|
|
- echo "Error: Installed version ($version) is equal to the available version ($rl_v)"
|
|
|
- exit 2
|
|
|
- else
|
|
|
- UPDATE="yes"
|
|
|
- fi
|
|
|
-fi
|
|
|
-
|
|
|
-# Perform verification if read-only mode is enabled
|
|
|
-check_hestia_demo_mode
|
|
|
-
|
|
|
-#----------------------------------------------------------#
|
|
|
-# Action #
|
|
|
-#----------------------------------------------------------#
|
|
|
-
|
|
|
-if [ "$UPDATE" == "no" ]; then
|
|
|
- rm -f -r $RL_INSTALL_DIR
|
|
|
- rm -f -r $RL_CONFIG_DIR
|
|
|
-
|
|
|
- mkdir $RL_INSTALL_DIR
|
|
|
- mkdir $RL_CONFIG_DIR
|
|
|
-
|
|
|
- cd "$RL_INSTALL_DIR"
|
|
|
- [ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RL_URL" --retry-connrefused --quiet -O "${RL_INSTALL_DIR}/${RL_FILE}"
|
|
|
-
|
|
|
- key=$(openssl rand -hex 4)
|
|
|
-
|
|
|
- admin_account="admin_$key"
|
|
|
- admin_password=$(generate_password)
|
|
|
- r=$(generate_password)
|
|
|
-
|
|
|
- echo "Username: admin_$key" > ~/.rainloop
|
|
|
- echo "Password: $admin_password" >> ~/.rainloop
|
|
|
- echo "Secret key: admin_$key" >> ~/.rainloop
|
|
|
-
|
|
|
- unzip -q ${RL_INSTALL_DIR}/${RL_FILE}
|
|
|
-
|
|
|
- mv ./data $RL_CONFIG_DIR/
|
|
|
- ln -s $RL_CONFIG_DIR/data/ ./data
|
|
|
-
|
|
|
- SALT=$(openssl rand -base64 64)
|
|
|
- cp ./data/VERSION ./data/INSTALLED
|
|
|
- echo "<?php //$SALT" > ./data/SALT.php
|
|
|
- echo "Forbidden" > ./data/index.php
|
|
|
- echo "Forbidden" > ./data/index.html
|
|
|
-
|
|
|
- # Create database
|
|
|
- mysql -e "CREATE DATABASE rainloop"
|
|
|
- # Mysql available on system
|
|
|
- r=$(generate_password)
|
|
|
- mysql -e "GRANT ALL ON rainloop.*
|
|
|
- TO rainloop@localhost IDENTIFIED BY '$r'"
|
|
|
-
|
|
|
- mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/configs
|
|
|
- php -f $HESTIA_INSTALL_DIR/rainloop/change_password.php "admin_$key" "$admin_password" "$r"
|
|
|
- mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/domains
|
|
|
- cp -f $HESTIA_INSTALL_DIR/rainloop/default.ini $RL_CONFIG_DIR/data/_data_/_default_/domains
|
|
|
- mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/plugins
|
|
|
- cp -f -r $HESTIA_INSTALL_DIR/rainloop/plugins/hestia-change-password/ $RL_CONFIG_DIR/data/_data_/_default_/plugins
|
|
|
- mkdir -p $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header
|
|
|
- # Download add-x-originating-ip-header from rainloop github
|
|
|
- wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/index.php https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/index.php
|
|
|
- wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/VERSION https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/VERSION
|
|
|
- wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/README https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/README
|
|
|
- wget --quiet -O $RL_CONFIG_DIR/data/_data_/_default_/plugins/add-x-originating-ip-header/LICENSE https://raw.githubusercontent.com/RainLoop/rainloop-webmail/master/plugins/add-x-originating-ip-header/LICENSE
|
|
|
-
|
|
|
- cp -f $HESTIA_INSTALL_DIR/rainloop/plugins/plugin-add-x-originating-ip-header.ini $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-add-x-originating-ip-header.ini
|
|
|
- cp -f $HESTIA_INSTALL_DIR/rainloop/plugins/plugin-hestia-change-password.ini $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
|
|
|
-
|
|
|
- sed -i "s/%hostname%/$(hostname)/g" $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
|
|
|
- sed -i "s/%port%/$BACKEND_PORT/g" $RL_CONFIG_DIR/data/_data_/_default_/configs/plugin-hestia-change-password.ini
|
|
|
-
|
|
|
- chown -R www-data:www-data ./data
|
|
|
- chown -R www-data:www-data $RL_CONFIG_DIR/
|
|
|
-
|
|
|
- rm ${RL_INSTALL_DIR}/${RL_FILE}
|
|
|
- # Add robots.txt
|
|
|
- echo "User-agent: *" > $RL_INSTALL_DIR/robots.txt
|
|
|
- echo "Disallow: /" >> $RL_INSTALL_DIR/robots.txt
|
|
|
-
|
|
|
- # Updating hestia.conf
|
|
|
- if [ -z "$(grep WEBMAIL_SYSTEM $HESTIA/conf/hestia.conf)" ]; then
|
|
|
- $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' 'rainloop'
|
|
|
- else
|
|
|
- if [ -z "$(echo "$WEBMAIL_SYSTEM" | grep -w 'rainloop')" ]; then
|
|
|
- if [ -n "$WEBMAIL_SYSTEM" ]; then
|
|
|
- $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "rainloop,$WEBMAIL_SYSTEM"
|
|
|
- else
|
|
|
- $BIN/v-change-sys-config-value 'WEBMAIL_SYSTEM' "rainloop"
|
|
|
- fi
|
|
|
- fi
|
|
|
- fi
|
|
|
-
|
|
|
-else
|
|
|
- [ ! -f "${RC_INSTALL_DIR}/${RC_FILE}" ] && wget "$RL_URL" --quiet -O "${RL_INSTALL_DIR}/${RL_FILE}"
|
|
|
- version=$(cat $RL_INSTALL_DIR/data/VERSION)
|
|
|
-
|
|
|
- unzip -q -j ${RL_INSTALL_DIR}/${RL_FILE} "data/VERSION" -d $RL_INSTALL_DIR/
|
|
|
- version_source=$(cat $RL_INSTALL_DIR/VERSION)
|
|
|
-
|
|
|
- # Check version inside .zip file in case hestia didn't update yet
|
|
|
- if [ "$version" != "$version_source" ]; then
|
|
|
- unzip -q -o ${RL_INSTALL_DIR}/${RL_FILE} -d $RL_INSTALL_DIR/
|
|
|
- rm $RL_INSTALL_DIR/$RL_FILE
|
|
|
- fi
|
|
|
- rm ${RL_INSTALL_DIR}/VERSION
|
|
|
-fi
|
|
|
-
|
|
|
-#----------------------------------------------------------#
|
|
|
-# Hestia #
|
|
|
-#----------------------------------------------------------#
|
|
|
-
|
|
|
-if [ "$UPDATE" = "yes" ]; then
|
|
|
- $BIN/v-log-action "system" "Info" "Plugins" "Rainloop updated (Version: $version)."
|
|
|
-else
|
|
|
- $BIN/v-log-action "system" "Info" "Plugins" "Rainloop enabled (Version: $version)."
|
|
|
-fi
|
|
|
-log_event "$OK" "$ARGUMENTS"
|