upgrade 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. ynh_setting() {
  3. app=${1}
  4. setting=${2}
  5. sudo grep "^${setting}:" "/etc/yunohost/apps/${app}/settings.yml" | sed s/^[^:]\\+:\\s*[\"\']\\?// | sed s/\\s*[\"\']\$//
  6. }
  7. source ./helpers
  8. domain=$(ynh_setting piratebox domain)
  9. path=$(ynh_setting piratebox path)
  10. opt_domain=$(ynh_setting piratebox opt_domain)
  11. opt_name=$(ynh_setting piratebox opt_name)
  12. opt_deleting=$(ynh_setting piratebox opt_deleting)
  13. opt_renaming=$(ynh_setting piratebox opt_renaming)
  14. opt_chat=$(ynh_setting piratebox opt_chat)
  15. tmpdir=$(mktemp -dp /tmp/ piratebox-upgrade-XXXXX)
  16. sudo cp -a /etc/yunohost/apps/piratebox/settings.yml "${tmpdir}/"
  17. sudo mv /var/www/piratebox/public/uploads/ "${tmpdir}/"
  18. export PIRATEBOX_UPGRADE=1
  19. sudo bash /etc/yunohost/apps/piratebox/scripts/remove &> /dev/null
  20. bash ./install "${domain}" "${path}" "${opt_domain}" "${opt_name}" "${opt_deleting}" "${opt_renaming}" "${opt_chat}"
  21. gitcommit_upstream=$(ynh_setting piratebox gitcommit_upstream)
  22. sudo cp -a "${tmpdir}/settings.yml" /etc/yunohost/apps/piratebox/
  23. sudo mv "${tmpdir}/uploads/"* /var/www/piratebox/public/uploads/ 2> /dev/null
  24. sudo rm -r "${tmpdir}/"
  25. sudo yunohost app setting piratebox gitcommit_upstream -v "${gitcommit_upstream}"
  26. # Changes
  27. if [ -z "$(ynh_setting piratebox opt_maxspace)" ]; then
  28. sudo yunohost app setting piratebox opt_maxspace -v 90
  29. fi
  30. ynh_systemctl start ynh-piratebox
  31. exit 0