install 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. # MANAGE SCRIPT FAILURE
  11. #=================================================
  12. # Exit if an error occurs during the execution of the script
  13. ynh_abort_if_errors
  14. #=================================================
  15. # RETRIEVE ARGUMENTS FROM THE MANIFEST
  16. #=================================================
  17. domain=$YNH_APP_ARG_DOMAIN
  18. path_url=$YNH_APP_ARG_PATH
  19. is_public=$YNH_APP_ARG_IS_PUBLIC
  20. app=$YNH_APP_INSTANCE_NAME
  21. #=================================================
  22. # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
  23. #=================================================
  24. ynh_script_progression --message="Validating installation parameters..." --weight=1
  25. final_path=/var/www/$app
  26. test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
  27. # Register (book) web path
  28. ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
  29. #=================================================
  30. # STORE SETTINGS FROM MANIFEST
  31. #=================================================
  32. ynh_script_progression --message="Storing installation settings..." --weight=1
  33. ynh_app_setting_set --app=$app --key=domain --value=$domain
  34. ynh_app_setting_set --app=$app --key=path --value=$path_url
  35. #=================================================
  36. # INSTALL DEPENDENCIES
  37. #=================================================
  38. ynh_script_progression --message="Installing dependencies..." --weight=1
  39. ynh_install_app_dependencies $pkg_dependencies
  40. #=================================================
  41. # CREATE DEDICATED USER
  42. #=================================================
  43. ynh_script_progression --message="Configuring system user..." --weight=1
  44. # Create a system user
  45. ynh_system_user_create --username=$app --home_dir="$final_path"
  46. #=================================================
  47. # CREATE A MYSQL DATABASE
  48. #=================================================
  49. ynh_script_progression --message="Creating a MySQL database..." --weight=1
  50. db_name=$(ynh_sanitize_dbid --db_name=$app)
  51. db_user=$db_name
  52. ynh_app_setting_set --app=$app --key=db_name --value=$db_name
  53. ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
  54. #=================================================
  55. # DOWNLOAD, CHECK AND UNPACK SOURCE
  56. #=================================================
  57. ynh_script_progression --message="Setting up source files..." --weight=3
  58. ynh_app_setting_set --app=$app --key=final_path --value=$final_path
  59. # Download, check integrity, uncompress and patch the source from app.src
  60. ynh_setup_source --dest_dir="$final_path"
  61. chmod 750 "$final_path"
  62. chmod -R o-rwx "$final_path"
  63. chown -R $app:www-data "$final_path"
  64. #=================================================
  65. # NGINX CONFIGURATION
  66. #=================================================
  67. ynh_script_progression --message="Configuring NGINX web server..." --weight=1
  68. # Create a dedicated NGINX config
  69. ynh_add_nginx_config
  70. #=================================================
  71. # PHP-FPM CONFIGURATION
  72. #=================================================
  73. ynh_script_progression --message="Configuring PHP-FPM..." --weight=3
  74. # Create a dedicated PHP-FPM config
  75. ynh_add_fpm_config
  76. #=================================================
  77. # SETUP SSOWAT
  78. #=================================================
  79. ynh_script_progression --message="Configuring permissions..." --weight=1
  80. # Make app public if necessary
  81. if [ $is_public -eq 1 ]
  82. then
  83. ynh_permission_update --permission="main" --add="visitors"
  84. fi
  85. #=================================================
  86. # RELOAD NGINX
  87. #=================================================
  88. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  89. ynh_systemd_action --service_name=nginx --action=reload
  90. #=================================================
  91. # SEND A README FOR THE ADMIN
  92. #=================================================
  93. ynh_script_progression --message="Sending a readme for the admin..." --weight=1
  94. message="Prestashop was successfully installed :)
  95. Please open your $app domain: https://$domain$path_url
  96. Complete the registration process from the setup page displayed.
  97. Details for MySQL database to be enterted while registration process:
  98. Database login: $app
  99. Database name: $app
  100. Database password: $db_pwd
  101. If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/prestashop_ynh/issues"
  102. ynh_send_readme_to_admin "$message"
  103. #=================================================
  104. # END OF SCRIPT
  105. #=================================================
  106. ynh_script_progression --message="Installation of $app completed" --last