upgrade 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/bash
  2. # Exit on command errors and treat unset variables as an error
  3. set -eu
  4. source .fonctions # Loads the generic functions usually used in the script
  5. source /usr/share/yunohost/helpers # Source YunoHost helpers
  6. # See comments in install script
  7. app=$YNH_APP_INSTANCE_NAME
  8. # Retrieve app settings
  9. domain=$(ynh_app_setting_get "$app" domain)
  10. path=$(ynh_app_setting_get "$app" path)
  11. admin=$(ynh_app_setting_get "$app" admin)
  12. is_public=$(ynh_app_setting_get "$app" is_public)
  13. language=$(ynh_app_setting_get "$app" language)
  14. CHECK_PATH # Checks and corrects the syntax of the path.
  15. # Check if admin is not null
  16. if [[ "$admin" = "" || "$is_public" = "" || "$language" = "" ]]; then
  17. echo "Unable to upgrade, please contact support"
  18. ynh_die
  19. fi
  20. root_pwd=$(sudo cat /etc/yunohost/mysql)
  21. final_path=/var/www/$app
  22. db_name=$app
  23. # Modify Nginx configuration file and copy it to Nginx conf directory
  24. sed -i "s@__PATHTOCHANGE__@$app@g" ../conf/nginx.conf*
  25. sed -i "s@__FINALPATH__@$final_path/@g" ../conf/nginx.conf*
  26. # If app is public, add url to SSOWat conf as skipped_uris
  27. if [ $is_public = "Yes" ];
  28. then
  29. ynh_app_setting_set "$app" unprotected_uris "/"
  30. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  31. else
  32. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  33. fi
  34. # Reload Nginx
  35. sudo service nginx reload