From: Christian Heller Date: Wed, 12 Feb 2020 21:23:41 +0000 (+0100) Subject: Add PeerTube upgrade script. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/static/%7B%7Bprefix%7D%7D/do_day?a=commitdiff_plain;h=3062fe8ca803898eb16fa7ec52507c1bb3be05e9;p=config Add PeerTube upgrade script. --- diff --git a/buster/setup_scripts/upgrade_peertube.sh b/buster/setup_scripts/upgrade_peertube.sh new file mode 100755 index 0000000..2f434a7 --- /dev/null +++ b/buster/setup_scripts/upgrade_peertube.sh @@ -0,0 +1,48 @@ +#!/bin/sh +set -e + +# Heavily inspired by +# + +# backup DB +SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak" +cd /var/www/peertube/ +su peertube -c 'mkdir -p backup' +su postgres -c "pg_dump -F c peertube_prod" | su peertube -c "tee ${SQL_BACKUP_PATH}" > /dev/null + +# Get new PeerTube version. +VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest Peertube version is $VERSION" +cd /var/www/peertube/versions +su peertube -c "wget -q \"https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip\"" +su peertube -c "unzip -o peertube-${VERSION}.zip && rm peertube-${VERSION}.zip" + +# Yarn new PeerTube. +su -l peertube -c "cd /var/www/peertube/versions/peertube-${VERSION} && yarn install --production --pure-lockfile" + +# Copy new default.yaml (TODO: find out what it does) +su peertube -c "cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml" + +set +e +echo +echo "Check differences between new and old production.yaml[.example]" +diff /var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example /var/www/peertube/config/production.yaml +echo +set -e + +# Link new PeerTube as latest one. +cd /var/www/peertube +unlink ./peertube-latest +su peertube -c "ln -s versions/peertube-${VERSION} ./peertube-latest" + +set +e +echo +echo "Check differences between new and old NGINX files" +cd /var/www/peertube/versions +diff "$(ls --sort=t | head -2 | tail -1)/support/nginx/peertube" "$(ls --sort=t | head -1)/support/nginx/peertube" +echo +echo "Check differences between new and old systemd unit files" +diff "$(ls --sort=t | head -2 | tail -1)/support/systemd/peertube.service" "$(ls --sort=t | head -1)/support/systemd/peertube.service" +echo +set -e + +service peertube restart