upgrade 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  25. sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  26. sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
  27. if [ "$is_public" = "Yes" ];
  28. then
  29. sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
  30. fi
  31. # Setup SSOwat
  32. ynh_app_setting_set "$app" is_public "$is_public"
  33. if [ "$is_public" = "Yes" ];
  34. then
  35. ynh_app_setting_set "$app" unprotected_uris "/"
  36. fi
  37. # Reload Nginx
  38. sudo service nginx reload