2
1

upgrade.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/sh
  2. set -eu
  3. PEERTUBE_PATH=${1:-/var/www/peertube/}
  4. if [ ! -e "$PEERTUBE_PATH" ]; then
  5. echo "Error - path \"$PEERTUBE_PATH\" wasn't found"
  6. echo ""
  7. echo "If peertube was installed in another path, you can specify it with"
  8. echo " ./upgrade.sh <PATH>"
  9. exit 1
  10. fi
  11. if [ ! -e "$PEERTUBE_PATH/versions" -o ! -e "$PEERTUBE_PATH/config/production.yaml" ]; then
  12. echo "Error - Couldn't find peertube installation in \"$PEERTUBE_PATH\""
  13. echo ""
  14. echo "If peertube was installed in another path, you can specify it with"
  15. echo " ./upgrade.sh <PATH>"
  16. exit 1
  17. fi
  18. # Backup database
  19. SQL_BACKUP_PATH="$PEERTUBE_PATH/backup/sql-peertube_prod-$(date +"%Y%m%d-%H%M").bak"
  20. mkdir -p $PEERTUBE_PATH/backup
  21. pg_dump -U peertube -W -h localhost -F c peertube_prod -f "$SQL_BACKUP_PATH"
  22. # Get and Display the Latest Version
  23. VERSION=$(curl -s https://api.github.com/repos/chocobozzz/peertube/releases/latest | grep tag_name | cut -d '"' -f 4)
  24. echo "Latest Peertube version is $VERSION"
  25. wget -q "https://github.com/Chocobozzz/PeerTube/releases/download/${VERSION}/peertube-${VERSION}.zip" -O "$PEERTUBE_PATH/versions/peertube-${VERSION}.zip"
  26. cd $PEERTUBE_PATH/versions
  27. unzip -o "peertube-${VERSION}.zip"
  28. rm -f "peertube-${VERSION}.zip"
  29. # Upgrade Scripts
  30. rm -rf $PEERTUBE_PATH/peertube-latest
  31. ln -s "$PEERTUBE_PATH/versions/peertube-${VERSION}" $PEERTUBE_PATH/peertube-latest
  32. cd $PEERTUBE_PATH/peertube-latest
  33. yarn install --production --pure-lockfile
  34. cp $PEERTUBE_PATH/peertube-latest/config/default.yaml $PEERTUBE_PATH/config/default.yaml
  35. echo "Differences in configuration files..."
  36. diff "$PEERTUBE_PATH/versions/peertube-${VERSION}/config/production.yaml.example" $PEERTUBE_PATH/config/production.yaml