restore 863 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. # The parameter $1 is the uncompressed restore directory location
  3. backup_dir="${1}/apps/piratebox"
  4. sudo rm -f /etc/nginx/conf.d/captive-piratebox.conf
  5. sudo mkdir -p /var/www/piratebox/public/
  6. sudo mv "${backup_dir}/uploads/" /var/www/piratebox/public/
  7. sudo chown -R www-data: /var/www/piratebox/public/uploads/
  8. gitcommit=$(sudo grep revision /etc/yunohost/apps/piratebox/status.json | sed 's/.*"revision": "\([^"]\+\)".*/\1/')
  9. gitcommit_upstream=$(sudo yunohost app setting piratebox gitcommit_upstream)
  10. tmpdir=$(mktemp -dp /tmp/ piratebox-restore-XXXXX)
  11. git clone https://github.com/labriqueinternet/piratebox_ynh.git "${tmpdir}/"
  12. git --work-tree "${tmpdir}/" --git-dir "${tmpdir}/.git/" reset --hard "${gitcommit}"
  13. export PIRATEBOX_GITCOMMIT_UPSTREAM=$gitcommit_upstream
  14. cd "${tmpdir}/scripts/"
  15. bash ./upgrade
  16. sudo rm -r "${tmpdir}/"
  17. exit 0