install 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/bash
  2. source /usr/share/yunohost/helpers
  3. source ./_common
  4. source .fonctions
  5. set -eu
  6. # Retrieve app id
  7. app=abantecart
  8. # Retrieve arguments
  9. domain=$1
  10. path=$2
  11. is_public=$3
  12. user=$4
  13. passwd=$5
  14. email=$6
  15. script_dir=$PWD
  16. # Vérifie que les variables ne sont pas vides.
  17. CHECK_VAR "$app" "app name not set"
  18. CHECK_VAR "$script_dir" "script_dir not set"
  19. CHECK_PATH # Vérifie et corrige la syntaxe du path.
  20. CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine.
  21. CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé.
  22. # Install dependency to convert tracks to a readable format for the browser
  23. sudo apt-get update
  24. sudo apt-get -y -qq install php5-mysql
  25. # Check password strength
  26. [[ ${#passwd} -gt 5 ]] || ynh_die \
  27. "The password is too weak, it must be longer than 5 characters"
  28. # Save app settings
  29. user="$app"
  30. ynh_app_setting_set "$app" is_public "$is_public"
  31. ynh_app_setting_set "$app" password "$passwd"
  32. ynh_app_setting_set "$app" user "$user"
  33. # Initialize database as needed
  34. dbname=$app
  35. dbuser=$app
  36. dbpass=$(ynh_string_random)
  37. ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
  38. # Store the database access
  39. echo -e "# MySQL Database"
  40. # Remove trailing "/" for next commands
  41. if [[ ! "$path" == "/" ]]; then
  42. path=${path%/}
  43. fi
  44. # Copy files to the right place
  45. final_path=/var/www/$app
  46. extract_source
  47. SUDO unzip $final_path/prestashop.zip $final_path/prestashop
  48. sudo mv $final_path/prestashop/* $final_path/
  49. sudo rm -rf $final_path/prestashop
  50. pushd $final_path/install/
  51. sudo php index_cli.php install \
  52. --db_server=localhost \
  53. --db_user=$dbuser \
  54. --db_password=$dbpass \
  55. --db_name=$dbname \
  56. --db_driver=amysqli \
  57. --db_port=3306 \
  58. --lastname=$user \
  59. --password=$passwd \
  60. --email=$email \
  61. --domain=$domain$path \
  62. --prefix=_ps_
  63. popd
  64. # file owned by www-data before checking permissions
  65. sudo chown www-data:www-data $final_path -R
  66. # Files owned by root, www-data can just read
  67. sudo chmod 0775 $final_path/config/ -R
  68. sudo chmod 0775 $final_path/cache/ -R
  69. sudo chmod 0775 $final_path/mails/ -R
  70. sudo chmod 0775 $final_path/log/ -R
  71. sudo chmod 0775 $final_path/img/ -R
  72. sudo chmod 0775 $final_path/modules/ -R
  73. sudo chmod 0775 $final_path/override/ -R
  74. sudo chmod 0775 $final_path/themes/default/lang/ -R
  75. sudo chmod 0775 $final_path/themes/default/pdf/lang/ -R
  76. sudo chmod 0775 $final_path/themes/default/cache/ -R
  77. sudo chmod 0775 $final_path/translations/ -R
  78. sudo chmod 0775 $final_path/upload/ -R
  79. sudo chmod 0775 $final_path/download/ -R
  80. sudo chmod 0775 $final_path/extensions/ -R
  81. sudo chmod 0775 $final_path/resources/ -R
  82. sudo chmod 0775 $final_path/sitemap.xml
  83. # set database configuration
  84. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  85. # Modify Nginx configuration file and copy it to Nginx conf directory
  86. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  87. sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
  88. nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
  89. sudo cp ../conf/nginx.conf $nginxconf
  90. sudo chown root: $nginxconf
  91. sudo chmod 600 $nginxconf
  92. sudo yunohost app setting $app is_public -v "$is_public"
  93. if [ "$is_public" = "Yes" ];
  94. then
  95. sudo yunohost app setting $app unprotected_uris -v "/"
  96. fi
  97. sudo rm -rf /var/www/$app/install/
  98. sudo service nginx reload
  99. sudo yunohost app ssowatconf