New sequence to backup and update a roundcube installation
This commit is contained in:
8
seqs/roundcube.cfg.example
Normal file
8
seqs/roundcube.cfg.example
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Roundcube sequence configuration
|
||||||
|
# RC = RoundCube
|
||||||
|
|
||||||
|
RC_LOC="/var/www/webmail"
|
||||||
|
RC_BACKUP="/root/backup/roundcube"
|
||||||
|
RC_DATABASE="roundcube_db"
|
99
seqs/roundcube.sh
Executable file
99
seqs/roundcube.sh
Executable file
@@ -0,0 +1,99 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
toolName=roundcube
|
||||||
|
#https://github.com/roundcube/roundcubemail/releases/latest
|
||||||
|
latestUrl="https://api.github.com/repos/roundcube/roundcubemail/releases/latest"
|
||||||
|
|
||||||
|
# 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_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() { echo "Upgrade installation to latest version from github"; }
|
||||||
|
step_22_alias() { ALIAS="upgrade"; }
|
||||||
|
step_22() {
|
||||||
|
local latestVersion=$(curl --silent "$latestUrl" | grep -Po '"tag_name": "\K.*?(?=")')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
local downUrl="https://github.com/roundcube/roundcubemail/releases/download/${latestVersion}/roundcubemail-${latestVersion}-complete.tar.gz"
|
||||||
|
local tempExtract="$tempDown/roundcubemail-$latestVersion"
|
||||||
|
local 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
|
||||||
|
|
||||||
|
step backup
|
||||||
|
echo " [I] Installing version $latestVersion to $RC_LOC"
|
||||||
|
exe "$tempInstall" "$RC_LOC"
|
||||||
|
exe cd "$RC_LOC"
|
||||||
|
echo " [I] Starting post update procedure"
|
||||||
|
exe php composer.phar update --no-dev
|
||||||
|
}
|
||||||
|
tempDown="/tmp/roundcube"
|
||||||
|
tempLoc="$tempDown/rc.tar.gz"
|
||||||
|
|
||||||
|
VERSION_SEQREV=10
|
||||||
|
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user