70 lines
1.5 KiB
Bash
Executable file
70 lines
1.5 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#
|
|
## Update Dendrite with git running on alpinelinux
|
|
#
|
|
|
|
#
|
|
## Variables
|
|
#
|
|
|
|
# User running dendrite
|
|
dendriteuser=dendrite
|
|
|
|
# How to stop and start dendrite
|
|
stopdendrite="rc-service dendrite stop"
|
|
startdendrite="rc-service dendrite start"
|
|
|
|
# Installdir
|
|
installdir="/opt/dendrite"
|
|
|
|
# Workdir
|
|
workdir="/tmp"
|
|
|
|
# Backupdir
|
|
backupdir="/home/dendrite/backup"
|
|
|
|
# Delete old backups? "yes" or "no"
|
|
deletebackup="no"
|
|
|
|
#
|
|
## Main
|
|
#
|
|
|
|
# Set Starttime of script
|
|
starttime=`date +"%Y%m%d_%H%M%S"`
|
|
echo "Starting update at $starttime"
|
|
|
|
# Stopping dendrite
|
|
$stopdendrite
|
|
|
|
# Delete old backups if not wanted
|
|
if [[ "$deletebackup" = "yes" ]]; then
|
|
rm -r $backupdir/dendrite-*
|
|
elif [[ "$deletebackup" = "no" ]]; then
|
|
echo "Will not delete old backups."
|
|
else
|
|
echo "Wrong argument $deletebackup. Please set *deletebackup* to *yes* or *no*"
|
|
exit 1
|
|
fi
|
|
|
|
# Move old dendrite to backup
|
|
if [[ ! -d "$backupdir" ]]; then
|
|
echo "Since $backupdir doesn't exist - create it."
|
|
mkdir -p $backupdir
|
|
fi
|
|
|
|
mkdir $backupdir/dendrite-$starttime/
|
|
mv $installdir/* $backupdir/dendrite-$starttime
|
|
|
|
# Clone https://github.com/matrix-org/dendrite to $workdir
|
|
su $dendriteuser -s $SHELL -lc "git clone https://github.com/matrix-org/dendrite $workdir/dendrite"
|
|
|
|
# Compile dendrite
|
|
su $dendriteuser -s $SHELL -lc "cd $workdir/dendrite && go build -o /opt/dendrite/bin/ ./cmd/..."
|
|
|
|
# Starting dendrite
|
|
$startdendrite
|
|
|
|
# Finish
|
|
echo "New dendrite-version is running! Check if it is working: https://federationtester.matrix.org/"
|