|
#!/usr/bin/env bash |
|
set -euo pipefail |
|
|
|
cd /var/www |
|
export TODAY="$(date -I)" |
|
export GTS_VERSION="0.19.0" |
|
|
|
# Stop the service |
|
echo "Stopping gotosocial service..." |
|
systemctl stop gotosocial |
|
|
|
# Backup |
|
BACKUP_DIR="gtsbck_$TODAY" |
|
mkdir -p "$BACKUP_DIR" |
|
|
|
# Extract DB password and export for pg_dump |
|
export PGPASSWORD=$(grep db-password /var/www/gotosocial/config.yaml | awk -F'"' '{print $2}') |
|
|
|
# Backup the database in both plain and custom formats |
|
echo "Backing up PostgreSQL database..." |
|
pg_dump -U gotosocial -d gotosocial -F p -f "$BACKUP_DIR/gotosocial.dump.sql" |
|
pg_dump -U gotosocial -d gotosocial -F c -f "$BACKUP_DIR/gotosocial.dump" |
|
|
|
# Backup the app folder |
|
echo "Backing up Gotosocial app files..." |
|
cp -R gotosocial "$BACKUP_DIR/gotosocial" |
|
|
|
# Download the new release files |
|
echo "Downloading new Gotosocial binaries and web assets..." |
|
rm -rf gtsnew |
|
mkdir gtsnew |
|
wget -q --show-progress -O gtsnew/gotosocial.tar.gz "https://codeberg.org/superseriousbusiness/gotosocial/releases/download/v${GTS_VERSION}/gotosocial_${GTS_VERSION}_linux_amd64.tar.gz" |
|
wget -q --show-progress -O gtsnew/web.tar.gz "https://codeberg.org/superseriousbusiness/gotosocial/releases/download/v${GTS_VERSION}/gotosocial_${GTS_VERSION}_web-assets.tar.gz" |
|
|
|
# Unpack the gotosocial binary and move it into place |
|
echo "Updating Gotosocial binary..." |
|
tar -xzf gtsnew/gotosocial.tar.gz -C gtsnew |
|
install -m 755 gtsnew/gotosocial "${PWD}/gotosocial/gotosocial" |
|
|
|
# Unpack the web assets |
|
echo "Updating web assets..." |
|
tar -xzf gtsnew/web.tar.gz -C gtsnew |
|
rm -rf gotosocial/web |
|
mv gtsnew/web gotosocial/ |
|
|
|
# Set correct permissions |
|
chown -R gotosocial:www-data gotosocial/gotosocial |
|
chown -R gotosocial:www-data gotosocial/web |
|
|
|
# Start the service again |
|
echo "Starting gotosocial service..." |
|
systemctl start gotosocial |
|
|
|
echo "Update complete." |