Seq to upgrade an existing torrentwatch installation
Installation is WIP
This commit is contained in:
6
seqs/torrentwatch-xa.cfg.example
Normal file
6
seqs/torrentwatch-xa.cfg.example
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
TWXA_GIT_LOC='~/downloads/torrentwatch-xa'
|
||||
TWXA_CONFIG_LOC='/var/lib/torrentwatch-xa'
|
||||
TWXA_HTML_LOC='/var/www/torrentwatch-xa'
|
||||
TWXA_BACKUP_LOC='~/backup/torrentwatch-xa'
|
147
seqs/torrentwatch.sh
Executable file
147
seqs/torrentwatch.sh
Executable file
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
toolName=torrentwatch-xa
|
||||
toolDeps="git php-mbstring php-curl php-xml"
|
||||
toolGitUrl="https://github.com/dchang0/torrentwatch-xa.git"
|
||||
toolConfigName="torrentwatch-xa.config"
|
||||
# Initialized by config of input
|
||||
toolVersion="master"
|
||||
toolConfigLoc=
|
||||
toolConfig=
|
||||
toolHtmlLoc=
|
||||
toolBackupLoc=
|
||||
|
||||
# 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() {
|
||||
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
|
||||
if [ $? -eq 0 ] ; then
|
||||
CONFIG=1
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
toolConfigLoc=`eval echo "$TWXA_CONFIG_LOC"`
|
||||
toolConfig="$toolConfigLoc/config_cache/$toolConfigName"
|
||||
toolHtmlLoc=`eval echo "$TWXA_HTML_LOC"`
|
||||
toolBackupLoc=`eval echo "$TWXA_BACKUP_LOC"`
|
||||
toolGitLoc=`eval echo "$TWXA_GIT_LOC"`
|
||||
gitLibLoc=`eval echo "$TWXA_GIT_LOC/var/lib/torrentwatch-xa"`
|
||||
gitHtmlLoc=`eval echo "$TWXA_GIT_LOC/var/www/html/torrentwatch-xa"`
|
||||
echo " git: $toolGitLoc"
|
||||
echo " config: $toolConfig"
|
||||
echo " html: $toolHtmlLoc"
|
||||
echo " backup: $toolBackupLoc"
|
||||
}
|
||||
|
||||
step_1_info() { echo "Install $toolName [VERSION]"; }
|
||||
step_1_alias() { ALIAS="install"; }
|
||||
step_1() {
|
||||
shift
|
||||
if [ ! -z $1 ] ; then
|
||||
toolVersion="$1"
|
||||
fi
|
||||
echo $toolConfig
|
||||
}
|
||||
|
||||
step_2_info() { echo "Setup git repository at $toolGitLoc [VERSION e.g. 1.4.1]"; }
|
||||
step_2_alias() { ALIAS="git"; }
|
||||
step_2() {
|
||||
shift
|
||||
if [ ! -e "$toolGitLoc/.git" ] ; then
|
||||
exe mkdir -p "$toolGitLoc"
|
||||
exe cd "$toolGitLoc"
|
||||
exe git clone $toolGitUrl .
|
||||
else
|
||||
exe cd "$toolGitLoc"
|
||||
exe git pull
|
||||
fi
|
||||
if [ ! -z $1 ] ; then
|
||||
toolVersion="$1"
|
||||
fi
|
||||
exe git checkout $toolVersion
|
||||
}
|
||||
|
||||
step_20_info() { echo "Backup $toolName"; }
|
||||
step_20_alias() { ALIAS="backup"; }
|
||||
step_20() {
|
||||
shift
|
||||
if [ ! -e "$toolConfigLoc" ] ; then
|
||||
echoerr " [E] No installation found"
|
||||
return 1
|
||||
fi
|
||||
|
||||
local buType="all"
|
||||
if [ ! -z $1 ] ; then
|
||||
buType="$1"
|
||||
fi
|
||||
local buDate=`date +%Y%m%d-%H%M%S`
|
||||
local buDir="$toolBackupLoc/$buDate"
|
||||
local buConfig="$buDir/$toolConfigName"
|
||||
local buHtmlConfig="$buDir/config.php"
|
||||
local dataBackup="$buDir/${toolName}_data_${buDate}.tar.gz"
|
||||
local htmlBackup="$buDir/${toolName}_html_${buDate}.tar.gz"
|
||||
|
||||
if [ "$buType" == "all" ] || [ "$buType" == "config" ] ; then
|
||||
exe mkdir -p "$buDir"
|
||||
saveReturn $?
|
||||
exe cd "$toolConfigLoc/.."
|
||||
saveReturn $?
|
||||
exe tar czf "$dataBackup" $(basename "$toolConfigLoc")
|
||||
saveReturn $?
|
||||
exe cp -ar "$toolConfig" "$buConfig"
|
||||
saveReturn $?
|
||||
exe ln -sf "$buConfig" "$toolBackupLoc"
|
||||
saveReturn $?
|
||||
fi
|
||||
|
||||
if [ "$buType" == "all" ] || [ "$buType" == "html" ] ; then
|
||||
exe mkdir -p "$buDir"
|
||||
saveReturn $?
|
||||
exe cd "$toolHtmlLoc/.."
|
||||
saveReturn $?
|
||||
exe tar czf "$htmlBackup" $(basename "$toolHtmlLoc")
|
||||
saveReturn $?
|
||||
exe cp -ar "$toolHtmlLoc/config.php" "$buHtmlConfig"
|
||||
saveReturn $?
|
||||
exe ln -sf "$buHtmlConfig" "$toolBackupLoc"
|
||||
saveReturn $?
|
||||
fi
|
||||
endReturn
|
||||
}
|
||||
|
||||
step_30_info() { echo "Upgrade $toolName [VERSION]"; }
|
||||
step_30_alias() { ALIAS="upgrade"; }
|
||||
step_30() {
|
||||
shift
|
||||
if [ ! -z $1 ] ; then
|
||||
toolVersion="$1"
|
||||
fi
|
||||
|
||||
#step backup
|
||||
if [ $? -ne 0 ]; then
|
||||
echoerr " [E] Backup failed. Aborting upgrade."
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo " [I] Upgrading data"
|
||||
exe mv "$toolConfigLoc/lib" "$toolConfigLoc/lib_bu"
|
||||
exe cp -ar "$gitLibLoc/lib" "$toolConfigLoc/"
|
||||
|
||||
echo " [I] Upgrading html"
|
||||
exe mv "$toolHtmlLoc" "${toolHtmlLoc}_bu"
|
||||
exe cp -ar "$gitHtmlLoc" "$toolHtmlLoc"
|
||||
exe cp -arL "$toolBackupLoc/config.php" "$toolHtmlLoc"
|
||||
|
||||
exe chown www-data: "$toolHtmlLoc/config.php"
|
||||
exe touch /var/log/twxalog
|
||||
exe chown www-data: /var/log/twxalog
|
||||
exe chown -R www-data: "$toolConfigLoc/*_cache"
|
||||
}
|
||||
|
||||
VERSION_SEQREV=11
|
||||
. /usr/local/bin/sequencer.sh
|
Reference in New Issue
Block a user