#!/bin/bash source /usr/share/yunohost/helpers source ./_common source .fonctions set -eu # Retrieve app id app=abantecart # Retrieve arguments domain=$1 path=$2 is_public=$3 user=$4 passwd=$5 email=$6 script_dir=$PWD # Vérifie que les variables ne sont pas vides. CHECK_VAR "$app" "app name not set" CHECK_VAR "$script_dir" "script_dir not set" CHECK_PATH # Vérifie et corrige la syntaxe du path. CHECK_DOMAINPATH # Vérifie la disponibilité du path et du domaine. CHECK_FINALPATH # Vérifie que le dossier de destination n'est pas déjà utilisé. # Install dependency to convert tracks to a readable format for the browser sudo apt-get update sudo apt-get -y -qq install php5-mysql # Check password strength [[ ${#passwd} -gt 5 ]] || ynh_die \ "The password is too weak, it must be longer than 5 characters" # Save app settings user="$app" ynh_app_setting_set "$app" is_public "$is_public" ynh_app_setting_set "$app" password "$passwd" ynh_app_setting_set "$app" user "$user" # Initialize database as needed dbname=$app dbuser=$app dbpass=$(ynh_string_random) ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" # Store the database access echo -e "# MySQL Database" # Remove trailing "/" for next commands if [[ ! "$path" == "/" ]]; then path=${path%/} fi # Copy files to the right place final_path=/var/www/$app extract_source SUDO unzip $final_path/prestashop.zip $final_path/prestashop sudo mv $final_path/prestashop/* $final_path/ sudo rm -rf $final_path/prestashop pushd $final_path/install/ sudo php index_cli.php install \ --db_server=localhost \ --db_user=$dbuser \ --db_password=$dbpass \ --db_name=$dbname \ --db_driver=amysqli \ --db_port=3306 \ --lastname=$user \ --password=$passwd \ --email=$email \ --domain=$domain$path \ --prefix=_ps_ popd # file owned by www-data before checking permissions sudo chown www-data:www-data $final_path -R # Files owned by root, www-data can just read sudo chmod 0775 $final_path/config/ -R sudo chmod 0775 $final_path/cache/ -R sudo chmod 0775 $final_path/mails/ -R sudo chmod 0775 $final_path/log/ -R sudo chmod 0775 $final_path/img/ -R sudo chmod 0775 $final_path/modules/ -R sudo chmod 0775 $final_path/override/ -R sudo chmod 0775 $final_path/themes/default/lang/ -R sudo chmod 0775 $final_path/themes/default/pdf/lang/ -R sudo chmod 0775 $final_path/themes/default/cache/ -R sudo chmod 0775 $final_path/translations/ -R sudo chmod 0775 $final_path/upload/ -R sudo chmod 0775 $final_path/download/ -R sudo chmod 0775 $final_path/extensions/ -R sudo chmod 0775 $final_path/resources/ -R sudo chmod 0775 $final_path/sitemap.xml # set database configuration sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@YNH_WWW_PATH@$path@g" ../conf/nginx.conf sed -i "s@YNH_WWW_ALIAS@$final_path/@g" ../conf/nginx.conf nginxconf=/etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf $nginxconf sudo chown root: $nginxconf sudo chmod 600 $nginxconf sudo yunohost app setting $app is_public -v "$is_public" if [ "$is_public" = "Yes" ]; then sudo yunohost app setting $app unprotected_uris -v "/" fi sudo rm -rf /var/www/$app/install/ sudo service nginx reload sudo yunohost app ssowatconf