upgrade 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. app=$YNH_APP_INSTANCE_NAME
  13. domain=$(ynh_app_setting_get $app domain)
  14. path_url=$(ynh_app_setting_get $app path)
  15. admin=$(ynh_app_setting_get $app admin)
  16. is_public=$(ynh_app_setting_get $app is_public)
  17. final_path=$(ynh_app_setting_get $app final_path)
  18. port=$(ynh_app_setting_get $app port)
  19. db_name=$(ynh_app_setting_get $app db_name)
  20. #=================================================
  21. # ENSURE DOWNWARD COMPATIBILITY
  22. #=================================================
  23. if [ "$is_public" = "Yes" ]; then
  24. ynh_app_setting_set $app is_public 1 # Fix is_public as a boolean value
  25. is_public=1
  26. elif [ "$is_public" = "No" ]; then
  27. ynh_app_setting_set $app is_public 0
  28. is_public=0
  29. fi
  30. if [ -z $db_name ]; then # If db_name doesn't exist, create it
  31. db_name=$(ynh_sanitize_dbid $app)
  32. ynh_app_setting_set $app db_name $db_name
  33. fi
  34. #=================================================
  35. # CHECK THE PATH
  36. #=================================================
  37. # Normalize the URL path syntax
  38. path_url=$(ynh_normalize_url_path $path_url)
  39. #=================================================
  40. # STANDARD UPGRADE STEPS
  41. #=================================================
  42. # DOWNLOAD, CHECK AND UNPACK SOURCE
  43. #=================================================
  44. # Download, check integrity, uncompress and patch the source from app.src
  45. ynh_setup_source "$final_path"
  46. #=================================================
  47. # NGINX CONFIGURATION
  48. #=================================================
  49. # Create a dedicated nginx config
  50. ynh_nginx_config
  51. #=================================================
  52. # CREATE DEDICATED USER
  53. #=================================================
  54. # Create a system user
  55. ynh_system_user_create $app
  56. #=================================================
  57. # PHP-FPM CONFIGURATION
  58. #=================================================
  59. # Create a dedicated php-fpm config
  60. ynh_fpm_config
  61. #=================================================
  62. # SPECIFIC UPGRADE
  63. #=================================================
  64. # ...
  65. #=================================================
  66. # Verify the checksum and backup the file if it's different
  67. ynh_backup_if_checksum_is_different "$final_path/CONFIG_FILE"
  68. # Recalculate and store the config file checksum into the app settings
  69. ynh_store_file_checksum "$final_path/CONFIG_FILE"
  70. #=================================================
  71. # SETUP LOGROTATE
  72. #=================================================
  73. # Use logrotate to manage app-specific logfile(s)
  74. ynh_use_logrotate
  75. #=================================================
  76. # SETUP SYSTEMD
  77. #=================================================
  78. # Create a dedicated systemd config
  79. ynh_systemd_config
  80. #=================================================
  81. # GENERIC FINALIZATION
  82. #=================================================
  83. # SECURE FILES AND DIRECTORIES
  84. #=================================================
  85. # Set right permissions for curl installation
  86. sudo chown -R root: $final_path
  87. #=================================================
  88. # SETUP SSOWAT
  89. #=================================================
  90. if [ $is_public -eq 0 ]
  91. then # Remove the public access
  92. ynh_app_setting_delete $app skipped_uris
  93. fi
  94. # Make app public if necessary
  95. if [ $is_public -eq 1 ]
  96. then
  97. # unprotected_uris allows SSO credentials to be passed anyway
  98. ynh_app_setting_set $app unprotected_uris "/"
  99. fi
  100. #=================================================
  101. # RELOAD NGINX
  102. #=================================================
  103. sudo systemctl reload nginx