install 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. admin=$YNH_APP_ARG_ADMIN
  20. language=$YNH_APP_ARG_LANGUAGE
  21. is_public=$YNH_APP_ARG_IS_PUBLIC
  22. password=$YNH_APP_ARG_PASSWORD
  23. email=$(ynh_user_get_info --username=$admin --key=mail)
  24. app=$YNH_APP_INSTANCE_NAME
  25. #=================================================
  26. # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS
  27. #=================================================
  28. ynh_script_progression --message="Validating installation parameters..." --weight=1
  29. final_path=/var/www/$app
  30. test ! -e "$final_path" || ynh_die --message="This path already contains a folder"
  31. # Register (book) web path
  32. ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url
  33. #=================================================
  34. # STORE SETTINGS FROM MANIFEST
  35. #=================================================
  36. ynh_script_progression --message="Storing installation settings..." --weight=1
  37. ynh_app_setting_set --app=$app --key=domain --value=$domain
  38. ynh_app_setting_set --app=$app --key=path --value=$path_url
  39. ynh_app_setting_set --app=$app --key=admin --value=$admin
  40. ynh_app_setting_set --app=$app --key=password --value=$password
  41. ynh_app_setting_set --app=$app --key=email --value=$email
  42. #=================================================
  43. # CREATE DEDICATED USER
  44. #=================================================
  45. ynh_script_progression --message="Configuring system user..." --weight=1
  46. # Create a system user
  47. ynh_system_user_create --username=$app --home_dir="$final_path"
  48. #=================================================
  49. # CREATE A MYSQL DATABASE
  50. #=================================================
  51. ynh_script_progression --message="Creating a MySQL database..." --weight=1
  52. db_name=$(ynh_sanitize_dbid --db_name=$app)
  53. db_user=$db_name
  54. ynh_app_setting_set --app=$app --key=db_name --value=$db_name
  55. ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name
  56. #=================================================
  57. # DOWNLOAD, CHECK AND UNPACK SOURCE
  58. #=================================================
  59. ynh_script_progression --message="Setting up source files..." --weight=3
  60. ynh_app_setting_set --app=$app --key=final_path --value=$final_path
  61. # Download, check integrity, uncompress and patch the source from app.src
  62. ynh_setup_source --dest_dir="$final_path"
  63. chmod 750 "$final_path"
  64. chmod -R o-rwx "$final_path"
  65. chown -R $app:www-data "$final_path"
  66. #=================================================
  67. # NGINX CONFIGURATION
  68. #=================================================
  69. ynh_script_progression --message="Configuring NGINX web server..." --weight=1
  70. # Create a dedicated NGINX config
  71. ynh_add_nginx_config
  72. #=================================================
  73. # PHP-FPM CONFIGURATION
  74. #=================================================
  75. ynh_script_progression --message="Configuring PHP-FPM..." --weight=3
  76. # Create a dedicated PHP-FPM config
  77. ynh_add_fpm_config --usage=low --footprint=low --package="$extra_php_dependencies"
  78. phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
  79. #=================================================
  80. # Installation de Prestashop
  81. #=================================================
  82. # pushd $final_path/install/
  83. # php7.3 index_cli.php \
  84. # --db_server=localhost \
  85. # --db_user=$db_name \
  86. # --db_password=$db_pwd \
  87. # --db_name=$app \
  88. # --db_driver=amysqli \
  89. # --db_port=3306 \
  90. # --language=${language:0:2} \
  91. # --lastname=$admin_prestashop \
  92. # --firstname=$admin_prestashop \
  93. # --password=$pass \
  94. # --email=$email \
  95. # --domain=$domain \
  96. # --base_uri=$path \
  97. # --prefix=_ps_
  98. # popd
  99. # sudo rm -fr $final_path/install
  100. #=================================================
  101. # active ssl
  102. #=================================================
  103. # mysql -u $db_user -p$db_pwd $db_name -e "UPDATE _ps_configuration SET value=1 WHERE name='PS_SSL_ENABLED';"
  104. # mysql -u $db_user -p$db_pwd $db_name -e "INSERT INTO _ps_configuration (id_configuration, id_shop_group, id_shop, name, value, date_add, date_upd) VALUES (NULL, NULL, NULL, 'PS_SSL_ENABLED_EVERYWHERE', '1', NOW(), NOW());"
  105. #=================================================
  106. # Set /etc/hosts
  107. #=================================================
  108. #echo -e "127.0.0.1 $domain #PRESTASHOP" | sudo tee -a /etc/hosts
  109. #=================================================
  110. # SETUP SSOWAT
  111. #=================================================
  112. ynh_script_progression --message="Configuring permissions..." --weight=1
  113. # Make app public if necessary
  114. if [ $is_public -eq 1 ]
  115. then
  116. ynh_permission_update --permission="main" --add="visitors"
  117. fi
  118. #=================================================
  119. # RELOAD NGINX
  120. #=================================================
  121. ynh_script_progression --message="Reloading NGINX web server..." --weight=1
  122. ynh_systemd_action --service_name=nginx --action=reload
  123. #=================================================
  124. # Nettoyer hosts
  125. #=================================================
  126. #sudo sed -i '/#PRESTASHOP/d' /etc/hosts
  127. #=================================================
  128. # END OF SCRIPT
  129. #=================================================
  130. ynh_script_progression --message="Installation of $app completed" --last