upgrade 3.7 KB

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