235 lines
6.5 KiB
Bash
Executable File
235 lines
6.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
toolName=roundcube
|
|
toolPhpDeps="php\${phpVersion}-gd php-imagick"
|
|
#https://github.com/roundcube/roundcubemail/releases/latest
|
|
latestUrl="https://api.github.com/repos/roundcube/roundcubemail/releases/latest"
|
|
latestVersion=
|
|
tempExtract=
|
|
tempInstall=
|
|
phpVersion=
|
|
|
|
# Get script working directory
|
|
# (when called from a different directory)
|
|
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
|
|
CONFIG=0
|
|
CONFIG_FILE_NAME="${toolName}.cfg"
|
|
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
|
|
|
|
step_config() {
|
|
## use sequencer api:
|
|
initSeqConfig -t "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
|
if [ $CONFIG -eq 0 ] ; then
|
|
CONFIG=1
|
|
fi
|
|
}
|
|
|
|
step_1_info() { echo "Install $toolName"; }
|
|
step_1_alias() { ALIAS="install"; }
|
|
step_1() {
|
|
local aptOpt=
|
|
if [ $QUIET -ne 0 ];then
|
|
aptOpt="-y"
|
|
fi
|
|
|
|
downloadLatest
|
|
fetchPhpVersion
|
|
|
|
if [ ! -z $phpVersion ] ; then
|
|
exe apt update
|
|
exe apt install `eval echo "$toolPhpDeps"` $aptOpt
|
|
fi
|
|
|
|
exe chown -R www-data: "$tempExtract"
|
|
exe cp -nar "$tempExtract" "$RC_LOC"
|
|
}
|
|
|
|
step_2_info() { echo "Install composer"; }
|
|
step_2() {
|
|
exe cd "$RC_LOC"
|
|
local EXPECTED_CHECKSUM="$(wget -q -O - https://composer.github.io/installer.sig)"
|
|
exe php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
|
local ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
|
|
|
|
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]
|
|
then
|
|
echoerr ' [E] Invalid installer checksum'
|
|
exe rm composer-setup.php
|
|
return 1
|
|
fi
|
|
|
|
exe php composer-setup.php --quiet
|
|
saveReturn $?
|
|
exe rm composer-setup.php
|
|
endReturn "Composer setup failed"
|
|
}
|
|
|
|
step_3_info() { echo "Configure $toolName"; }
|
|
step_3_alias() { ALIAS="config"; }
|
|
step_3() {
|
|
echo " [I] Recommended composer packages to be added to \"require\" section:"
|
|
echo ' "melanie2/mobile": "*",'
|
|
echo ' "roundcube/carddav": "*",'
|
|
echo ' "alexandregz/twofactor_gauthenticator": "dev-master"'
|
|
exe read -p "Copy the lines above and press Enter to continue."
|
|
exe vi "$RC_LOC/composer.json"
|
|
step postupgrade
|
|
exit 0
|
|
echo " [I] Generating mysql database $RC_DATABASE"
|
|
echo
|
|
exe $WDIR/mysql.sh createdb_utf8mb4
|
|
|
|
echo
|
|
echo " [I] Now visit: http://url-to-roundcube/installer/"
|
|
echo
|
|
echo " ! Check the database password in $RC_LOC/config/config.inc.php"
|
|
echo " afterwards, the installer may have corrupted some special character"
|
|
echo
|
|
echo " ! After installation please delete $RC_LOC/installer"
|
|
}
|
|
|
|
step_10_info() { echo "Configuration notes"; }
|
|
step_10_alias() { ALIAS="notes"; }
|
|
step_10() {
|
|
echo "# smtp port if missing after installation"
|
|
echo" [$RC_LOC/config/config.inc.php]"
|
|
echo ' // SMTP port (default is 25; use 587 for STARTTLS or 465 for the'
|
|
echo ' // deprecated SSL over SMTP (aka SMTPS))'
|
|
echo " \$config['smtp_port'] = 465;"
|
|
echo
|
|
echo "# Enable two factor auth (installed with step config) for all user"
|
|
echo " [$RC_LOC/plugins/twofactor_gauthenticator/config.inc.php]"
|
|
echo " $rcmail_config['users_allowed_2FA'] = array('.*');"
|
|
echo
|
|
echo "# Add mobile skin to roundcube"
|
|
echo " cd ${RC_LOC}"
|
|
echo " git clone https://github.com/messagerie-melanie2/Roundcube-Skin-Melanie2-Larry-Mobile.git skins/melanie2_larry_mobile"
|
|
echo "# Install pspell and aspell spell check engine"
|
|
echo " apt install php7.x-pspell aspell-en aspell-de"
|
|
echo
|
|
echo " [$RC_LOC/config/config.inc.php]"
|
|
echo " \$config['spellcheck_engine'] = 'pspell';"
|
|
echo " \$config['spellcheck_languages'] = array("
|
|
echo " 'en' => 'English',"
|
|
echo " 'de' => 'Deutsch',"
|
|
echo " );"
|
|
}
|
|
|
|
step_20_info() {
|
|
echo -n "Create a backup"
|
|
if [ $CONFIG -ne 0 ] ; then
|
|
echo " at $RC_BACKUP"
|
|
else
|
|
echo
|
|
fi
|
|
}
|
|
step_20_alias() { ALIAS="backup"; }
|
|
step_20() {
|
|
if [ $CONFIG -eq 0 ] ; then
|
|
echoerr " [E] No configuration file found"
|
|
return 1
|
|
fi
|
|
if [ ! -z $RC_BACKUP ] ; then
|
|
exe mkdir -p "$RC_BACKUP"
|
|
fi
|
|
exe $WDIR/mysql.sh -qq backup "$RC_DATABASE" "$RC_BACKUP"
|
|
local wwwBackup="$RC_BACKUP/${toolName}_www_`date +%Y%m%d-%H%M%S`.tar.gz"
|
|
echo " [I] Backing up webserver directory to $wwwBackup"
|
|
exe cd "$RC_LOC/.."
|
|
exe tar czf "$wwwBackup" $(basename "$RC_LOC")
|
|
}
|
|
|
|
step_22_info() {
|
|
shift
|
|
if [ -z $1 ] ; then
|
|
echo "Upgrade installation to latest version from github [CUSTOM VERSION]"
|
|
else
|
|
echo "Upgrade installation to $1 from github"
|
|
fi
|
|
}
|
|
step_22_alias() { ALIAS="upgrade"; }
|
|
step_22() {
|
|
shift # don't need step number
|
|
if [ ! -z $1 ] ; then
|
|
latestVersion="$1"
|
|
else
|
|
fetchLatestVersion
|
|
fi
|
|
|
|
if [ -z $latestVersion ] ; then
|
|
echoerr " [E] Cannot determine latest version from github repository"
|
|
return 1
|
|
elif [ $QUIET -eq 0 ] ; then
|
|
echo
|
|
exe read -p "Install $latestVersion to $RC_LOC [n]o/(y)es? " answer
|
|
case $answer in
|
|
[yY])
|
|
;;
|
|
*)
|
|
echoerr " [I] Upgrade aborted"
|
|
return 1
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
local isInstalled=$(grep -E "RELEASE $latestVersion" "${RC_LOC}/CHANGELOG" >>/dev/null && echo "1" || echo "0")
|
|
if [ $isInstalled -eq 1 ] ; then
|
|
echoerr " [E] Version $latestVersion is already installed"
|
|
return 2
|
|
fi
|
|
|
|
downloadLatest
|
|
|
|
step backup
|
|
echo " [I] Installing version $latestVersion to $RC_LOC"
|
|
exe "$tempInstall" "$RC_LOC"
|
|
echo " [I] Make sure to check composer.json-dist file for upstream changes"
|
|
}
|
|
|
|
step_23_info() { echo "Post upgrade procedure"; }
|
|
step_23_alias() { ALIAS="postupgrade"; }
|
|
step_23() {
|
|
exe cd "$RC_LOC"
|
|
echo " [I] Starting post update procedure"
|
|
exe php composer.phar update --no-dev
|
|
}
|
|
|
|
fetchPhpVersion() {
|
|
if [ ! -z $phpVersion ] ; then
|
|
return 0
|
|
fi
|
|
|
|
phpVersion="$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')"
|
|
}
|
|
|
|
fetchLatestVersion() {
|
|
if [ ! -z $latestVersion ] ; then
|
|
return 0
|
|
fi
|
|
latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')
|
|
}
|
|
|
|
downloadLatest() {
|
|
fetchLatestVersion
|
|
|
|
local downUrl="https://github.com/roundcube/roundcubemail/releases/download/${latestVersion}/roundcubemail-${latestVersion}-complete.tar.gz"
|
|
tempExtract="$tempDown/roundcubemail-$latestVersion"
|
|
tempInstall="$tempExtract/bin/installto.sh"
|
|
|
|
if [ ! -e "$tempExtract" ] ; then
|
|
exe mkdir -p "$tempDown"
|
|
exe wget -O "$tempLoc" $downUrl
|
|
endReturn -o $? "Download failed: $downUrl"
|
|
exe cd "$tempDown"
|
|
exe tar -xf "$tempLoc"
|
|
endReturn -o $? "Extract failed: $tempLoc"
|
|
else
|
|
echo " [I] Found existing download: $tempExtract"
|
|
fi
|
|
}
|
|
tempDown="/tmp/roundcube"
|
|
tempLoc="$tempDown/rc.tar.gz"
|
|
|
|
VERSION_SEQREV=10
|
|
. /usr/local/bin/sequencer.sh
|