upgrade 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. #=================================================
  3. # GENERIC START
  4. #=================================================
  5. # IMPORT GENERIC HELPERS
  6. #=================================================
  7. source _common.sh
  8. source /usr/share/yunohost/helpers
  9. #=================================================
  10. # LOAD SETTINGS
  11. #=================================================
  12. domain=$(ynh_app_setting_get "$app" domain)
  13. path=$(ynh_app_setting_get "$app" path)
  14. admin=$(ynh_app_setting_get "$app" admin)
  15. is_public=$(ynh_app_setting_get "$app" is_public)
  16. language=$(ynh_app_setting_get "$app" language)
  17. #=================================================
  18. # ENSURE DOWNWARD COMPATIBILITY
  19. #=================================================
  20. # Fix is_public as a boolean value
  21. if [ "$is_public" = "Yes" ]; then
  22. ynh_app_setting_set $app is_public 1
  23. is_public=1
  24. elif [ "$is_public" = "No" ]; then
  25. ynh_app_setting_set $app is_public 0
  26. is_public=0
  27. fi
  28. # If db_name doesn't exist, create it
  29. if [ -z $db_name ]; then
  30. db_name=$(ynh_sanitize_dbid $app)
  31. ynh_app_setting_set $app db_name $db_name
  32. fi
  33. # If final_path doesn't exist, create it
  34. if [ -z $final_path ]; then
  35. final_path=/var/www/$app
  36. ynh_app_setting_set $app final_path $final_path
  37. fi
  38. #=================================================
  39. # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
  40. #=================================================
  41. # Backup the current version of the app
  42. ynh_backup_before_upgrade
  43. ynh_clean_setup () {
  44. # restore it if the upgrade fails
  45. ynh_restore_upgradebackup
  46. }
  47. # Exit if an error occurs during the execution of the script
  48. ynh_abort_if_errors
  49. #=================================================
  50. # CHECK THE PATH
  51. #=================================================
  52. # Normalize the URL path syntax
  53. path_url=$(ynh_normalize_url_path $path_url)
  54. #=================================================
  55. # STANDARD UPGRADE STEPS
  56. #=================================================
  57. # DOWNLOAD, CHECK AND UNPACK SOURCE
  58. #=================================================
  59. # Download, check integrity, uncompress and patch the source from app.src
  60. ynh_setup_source "$final_path"
  61. #=================================================
  62. # NGINX CONFIGURATION
  63. #=================================================
  64. # Create a dedicated nginx config
  65. ynh_add_nginx_config
  66. #=================================================
  67. # CREATE DEDICATED USER
  68. #=================================================
  69. # Create a dedicated user (if not existing)
  70. ynh_system_user_create $app
  71. #=================================================
  72. # PHP-FPM CONFIGURATION
  73. #=================================================
  74. # Create a dedicated php-fpm config
  75. ynh_add_fpm_config
  76. #=================================================
  77. # GENERIC FINALIZATION
  78. #=================================================
  79. # SECURE FILES AND DIRECTORIES
  80. #=================================================
  81. # Set permissions on app files
  82. chown -R $app:$app $final_path
  83. #=================================================
  84. # SETUP SSOWAT
  85. #=================================================
  86. # Make app public if necessary
  87. if [ $is_public -eq 1 ]
  88. then
  89. # unprotected_uris allows SSO credentials to be passed anyway
  90. ynh_app_setting_set $app unprotected_uris "/"
  91. fi
  92. #=================================================
  93. # RELOAD NGINX
  94. #=================================================
  95. systemctl reload nginx