upgrade 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # Exit on command errors and treat unset variables as an error
  3. set -eu
  4. source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script
  5. # See comments in install script
  6. app=$YNH_APP_INSTANCE_NAME
  7. # Source YunoHost helpers
  8. source /usr/share/yunohost/helpers
  9. # Retrieve app settings
  10. domain=$(ynh_app_setting_get "$app" domain)
  11. path=$(ynh_app_setting_get "$app" path)
  12. admin=$(ynh_app_setting_get "$app" admin)
  13. is_public=$(ynh_app_setting_get "$app" is_public)
  14. language=$(ynh_app_setting_get "$app" language)
  15. CHECK_PATH # Vérifie et corrige la syntaxe du path.
  16. # Check if admin is not null
  17. if [[ "$admin" = "" || "$is_public" = "" || "$language" = "" ]]; then
  18. echo "Unable to upgrade, please contact support"
  19. ynh_die
  20. fi
  21. root_pwd=$(sudo cat /etc/yunohost/mysql)
  22. final_path=/var/www/$app
  23. db_name=$app
  24. CHECK_MD5_CONFIG "connect.php" "$final_path/config/connect.php" # Créé un backup du fichier de config si il a été modifié.
  25. # Modify Nginx configuration file and copy it to Nginx conf directory
  26. sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf*
  27. sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
  28. if [ $is_public = "Yes" ];
  29. then
  30. sudo cp ../conf/nginx.conf-public /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. # If app is public, add url to SSOWat conf as skipped_uris
  35. if [[ $is_public -eq 1 ]]; then
  36. # See install script
  37. ynh_app_setting_set "$app" unprotected_uris "/"
  38. sudo cp ../conf/nginx.conf-public /etc/nginx/conf.d/$domain.d/$app.conf
  39. else
  40. sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
  41. fi
  42. # Reload Nginx
  43. sudo service nginx reload