install 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. sudo git clone https://github.com/abantecart/abantecart-src.git /var/www/$app
  47. sudo rm -rf $final_path/tests
  48. sudo rm -rf $final_path/install.txt
  49. sudo mv $final_path/public_html/* $final_path/
  50. sudo rm -rf $final_path/public_html
  51. pushd $final_path/install/
  52. sudo php cli_install.php install \
  53. --db_host=localhost \
  54. --db_user=$dbuser \
  55. --db_password=$dbpass \
  56. --db_name=$dbname \
  57. --db_driver=amysqli \
  58. --db_port=3306 \
  59. --username=$user \
  60. --password=$passwd \
  61. --email=$email \
  62. --http_server=$domain$path \
  63. --db_prefix=_ac_ \
  64. --admin_path=admin
  65. popd
  66. # file owned by www-data before checking permissions
  67. sudo chown www-data:www-data $final_path -R
  68. # Files owned by root, www-data can just read
  69. sudo chmod 0777 $final_path/system/config.php
  70. sudo chmod 0777 $final_path/system/
  71. sudo chmod 0777 $final_path/system/cache/ -R
  72. sudo chmod 0777 $final_path/system/logs/ -R
  73. sudo chmod 0777 $final_path/image/ -R
  74. sudo chmod 0777 $final_path/image/thumbnails/ -R
  75. sudo chmod 0777 $final_path/download/ -R
  76. sudo chmod 0777 $final_path/extensions/ -R
  77. sudo chmod 0777 $final_path/resources/ -R
  78. # set database configuration
  79. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  80. # Modify Nginx configuration file and copy it to Nginx conf directory
  81. sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf
  82. sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf
  83. nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf
  84. sudo cp ../conf/nginx.conf $nginxconf
  85. sudo chown root: $nginxconf
  86. sudo chmod 600 $nginxconf
  87. sudo yunohost app setting $app is_public -v "$is_public"
  88. if [ "$is_public" = "Yes" ];
  89. then
  90. sudo yunohost app setting $app unprotected_uris -v "/"
  91. fi
  92. sudo rm -rf /var/www/$app/install/
  93. sudo service nginx reload
  94. sudo yunohost app ssowatconf