upgrade 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. # If db_name doesn't exist, create it
  21. if [ -z $db_name ]; then
  22. db_name=$(ynh_sanitize_dbid $app)
  23. ynh_app_setting_set $app db_name $db_name
  24. fi
  25. # If final_path doesn't exist, create it
  26. if [ -z $final_path ]; then
  27. final_path=/var/www/$app
  28. ynh_app_setting_set $app final_path $final_path
  29. fi
  30. #=================================================
  31. # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
  32. #=================================================
  33. # Backup the current version of the app
  34. ynh_backup_before_upgrade
  35. ynh_clean_setup () {
  36. # restore it if the upgrade fails
  37. ynh_restore_upgradebackup
  38. }
  39. # Exit if an error occurs during the execution of the script
  40. ynh_abort_if_errors
  41. #=================================================
  42. # CHECK THE PATH
  43. #=================================================
  44. # Normalize the URL path syntax
  45. path_url=$(ynh_normalize_url_path $path_url)
  46. #=================================================
  47. # STANDARD UPGRADE STEPS
  48. #=================================================
  49. # DOWNLOAD, CHECK AND UNPACK SOURCE
  50. #=================================================
  51. # Download, check integrity, uncompress and patch the source from app.src
  52. ynh_setup_source "$final_path"
  53. #=================================================
  54. # NGINX CONFIGURATION
  55. #=================================================
  56. # Create a dedicated nginx config
  57. ynh_add_nginx_config
  58. #=================================================
  59. # CREATE DEDICATED USER
  60. #=================================================
  61. # Create a dedicated user (if not existing)
  62. ynh_system_user_create $app
  63. #=================================================
  64. # PHP-FPM CONFIGURATION
  65. #=================================================
  66. # Create a dedicated php-fpm config
  67. ynh_add_fpm_config
  68. #=================================================
  69. # GENERIC FINALIZATION
  70. #=================================================
  71. # SECURE FILES AND DIRECTORIES
  72. #=================================================
  73. # Set permissions on app files
  74. chown -R $app:$app $final_path
  75. #=================================================
  76. # RELOAD NGINX
  77. #=================================================
  78. systemctl reload nginx