upgrade 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. SETUP_SOURCE
  23. # Delete install directory after upgrade
  24. rm -fr "$final_path/install"
  25. db_name=$app
  26. # Modify Nginx configuration file and copy it to Nginx conf directory
  27. sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  28. sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  29. sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
  30. if [ "$is_public" = "Yes" ];
  31. then
  32. sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
  33. fi
  34. # Setup SSOwat
  35. ynh_app_setting_set "$app" is_public "$is_public"
  36. if [ "$is_public" = "Yes" ];
  37. then
  38. ynh_app_setting_set "$app" unprotected_uris "/"
  39. fi
  40. # Reload Nginx
  41. sudo service nginx reload