home · contact · privacy
Fix.
[config] / buster / setup_scripts / upgrade_peertube.sh
1 #!/bin/sh
2 set -e
3
4 # Heavily inspired by
5 # <https://docs.joinpeertube.org/#/install-any-os?id=upgrade>
6
7 # backup DB
8 SQL_BACKUP_PATH="backup/sql-peertube_prod-$(date -Im).bak"
9 cd /var/www/peertube/
10 su peertube -c 'mkdir -p backup'
11 su postgres -c "pg_dump -F c peertube_prod" | su peertube -c "tee ${SQL_BACKUP_PATH}" > /dev/null
12
13 # Get new PeerTube version.
14 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"
15 cd /var/www/peertube/versions
16 su peertube -c "wget -q \"https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip\""
17 su peertube -c "unzip -o peertube-${VERSION}.zip && rm peertube-${VERSION}.zip"
18
19 # Yarn new PeerTube.
20 su -l peertube -c "cd /var/www/peertube/versions/peertube-${VERSION} && yarn install --production --pure-lockfile"
21
22 # Copy new default.yaml (TODO: find out what it does)
23 su peertube -c "cp /var/www/peertube/versions/peertube-${VERSION}/config/default.yaml /var/www/peertube/config/default.yaml"
24
25 set +e
26 echo
27 echo "Check differences between new and old production.yaml[.example]"
28 diff /var/www/peertube/versions/peertube-${VERSION}/config/production.yaml.example /var/www/peertube/config/production.yaml
29 echo
30 set -e
31
32 # Link new PeerTube as latest one.
33 cd /var/www/peertube
34 unlink ./peertube-latest
35 su peertube -c "ln -s versions/peertube-${VERSION} ./peertube-latest"
36
37 set +e
38 echo
39 echo "Check differences between new and old NGINX files"
40 cd /var/www/peertube/versions
41 diff "$(ls --sort=t | head -2 | tail -1)/support/nginx/peertube" "$(ls --sort=t | head -1)/support/nginx/peertube"
42 echo
43 echo "Check differences between new and old systemd unit files"
44 diff "$(ls --sort=t | head -2 | tail -1)/support/systemd/peertube.service" "$(ls --sort=t | head -1)/support/systemd/peertube.service"
45 echo
46 set -e
47
48 service peertube restart