upgrade 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. # Get source
  23. SETUP_SOURCE
  24. # Delete install directory after upgrade
  25. rm -fr "$final_path/install"
  26. db_name=$app
  27. # Modify Nginx configuration file and copy it to Nginx conf directory
  28. sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  29. sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
  30. sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
  31. if [ "$is_public" = "Yes" ];
  32. then
  33. sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
  34. fi
  35. # Create the php-fpm pool config
  36. POOL_FPM
  37. # Setup SSOwat
  38. ynh_app_setting_set "$app" is_public "$is_public"
  39. if [ "$is_public" = "Yes" ];
  40. then
  41. ynh_app_setting_set "$app" unprotected_uris "/"
  42. fi
  43. # Reload services
  44. sudo systemctl reload php5-fpm
  45. sudo systemctl reload nginx
  46. sudo yunohost app ssowatconf