#!/bin/sh set -eu PEERTUBE_PATH=${1:-/var/www/peertube} if [ ! -e "$PEERTUBE_PATH" ]; then echo "Error - path \"$PEERTUBE_PATH\" wasn't found" echo "" echo "If peertube was installed in another path, you can specify it with" echo " ./upgrade.sh " exit 1 fi if [ ! -e "$PEERTUBE_PATH/versions" -o ! -e "$PEERTUBE_PATH/config/production.yaml" ]; then echo "Error - Couldn't find peertube installation in \"$PEERTUBE_PATH\"" echo "" echo "If peertube was installed in another path, you can specify it with" echo " ./upgrade.sh " exit 1 fi if [ -x "$(command -v awk)" ] && [ -x "$(command -v sed)" ]; then REMAINING=$(df -k "$PEERTUBE_PATH" | awk '{ print $4}' | sed -n 2p) THREE_GB=$((3 * 1024 * 1024)) if [ "$REMAINING" -lt "$THREE_GB" ]; then echo "Error - not enough free space for upgrading" echo "" echo "Make sure you have at least 3 GB of free space in $PEERTUBE_PATH" exit 1 fi fi # Backup database if [ -x "$(command -v pg_dump)" ]; then mkdir -p "$PEERTUBE_PATH/backup" SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak" echo "Backing up PostgreSQL database in $SQL_BACKUP_PATH" read DB_HOST DB_SUFFIX DB_NAME DB_USER DB_PASS DB_PORT < /dev/null; then echo "You are running HardenedBSD. You might want to set the proper PaX options for node." fi rm -f "$PEERTUBE_PATH/peertube-latest" ln -s "$LATEST_VERSION_DIRECTORY" "$PEERTUBE_PATH/peertube-latest" RESOLVED_TARGET=$(cd -P "$PEERTUBE_PATH/peertube-latest" 2>/dev/null && pwd) || RESOLVED_TARGET="" EXPECTED_TARGET=$(cd -P "$LATEST_VERSION_DIRECTORY" 2>/dev/null && pwd) || { echo "Error - could not resolve $LATEST_VERSION_DIRECTORY" exit 1 } if [ -z "$RESOLVED_TARGET" ] || [ "$RESOLVED_TARGET" != "$EXPECTED_TARGET" ]; then echo "Error - peertube-latest symlink is broken after update" echo " Expected : $EXPECTED_TARGET" echo " Resolved : ${RESOLVED_TARGET:-}" exit 1 fi cp "$PEERTUBE_PATH/peertube-latest/config/default.yaml" "$PEERTUBE_PATH/config/default.yaml" echo "" echo "==========================================================" echo "" if [ -x "$(command -v git)" ]; then cd "$PEERTUBE_PATH" git merge-file -p config/production.yaml "$OLD_VERSION_DIRECTORY/config/production.yaml.example" "peertube-latest/config/production.yaml.example" | tee "config/production.yaml.new" > /dev/null echo "$PEERTUBE_PATH/config/production.yaml.new generated" echo "You can review it and replace your existing production.yaml configuration" else echo "git command not found: unable to generate config/production.yaml.new configuration file based on your existing production.yaml configuration" fi echo "" echo "==========================================================" echo "" echo "Please read the IMPORTANT NOTES on $RELEASE_PAGE_URL" echo "" echo "Then restart PeerTube!"