diff --git a/manifest.json b/manifest.json index 0e59688..ccea735 100644 --- a/manifest.json +++ b/manifest.json @@ -51,7 +51,7 @@ "default": "Yes" }, { - "name": "user", + "name": "admin_name", "type": "user", "ask": { "en": "Choose the Abantecart administrator (must be an existing YunoHost user)", @@ -60,7 +60,7 @@ "example": "homer" }, { - "name": "passwd", + "name": "admin_pass", "type": "password", "ask": { "en": "Set the password for the Admin user ≥ 5 character", @@ -69,7 +69,7 @@ "example": "myreallystrengthpassword" }, { - "name": "email", + "name": "admin_email", "type": "email", "ask": { "fr": "Votre adresse mail." diff --git a/scripts/install b/scripts/install index 41072e6..d87c551 100644 --- a/scripts/install +++ b/scripts/install @@ -12,9 +12,9 @@ app=$YNH_APP_INSTANCE_NAME domain=$YNH_APP_ARG_DOMAIN path=$YNH_APP_ARG_PATH is_public=$YNH_APP_ARG_IS_PUBLIC -user=$YNH_APP_ARG_USER -passwd=$YNH_APP_ARG_PASSWD -email=$YNH_APP_ARG_EMAIL +admin_name=$YNH_APP_ARG_ADMIN_NAME +admin_pass=$YNH_APP_ARG_ADMIN_PASS +admin_email=$YNH_APP_ARG_ADMIN_EMAIL # Vérifie que les variables ne sont pas vides. CHECK_VAR "$app" "app name not set" @@ -39,17 +39,18 @@ ynh_package_install_from_equivs ../conf/abantecart-deps.control \ # 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" +ynh_app_setting_set "$app" admin_pass "$admin_pass" +ynh_app_setting_set "$app" admin_name "$admin_name" +ynh_app_setting_set "$app" admin_email "$admin_email" # Initialize database as needed -dbname=$app -dbuser=$app -dbpass=$(ynh_string_random) -ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -ynh_app_setting_set "$app" dbname "$dbname" -ynh_app_setting_set "$app" dbpass "$dbpass" +db_name=$app +db_user=$app +db_pass=$(ynh_string_random) +ynh_mysql_create_db "$db_name" "$db_user" "$db_pass" +ynh_app_setting_set "$app" db_name "$db_name" +ynh_app_setting_set "$app" db_pass "$db_pass" # Store the database access echo -e "# MySQL Database" diff --git a/scripts/remove b/scripts/remove index d4554dc..1edfdae 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,9 +7,9 @@ source /usr/share/yunohost/helpers source .fonctions domain=$(ynh_app_setting_get $app domain) -dbname=$(ynh_app_setting_get $app dbname) +db_name=$(ynh_app_setting_get $app db_name) -REMOVE_BDD "$dname" +REMOVE_BDD "$db_name" # Remove installed files SECURE_REMOVE '/var/www/${app}' @@ -24,3 +24,4 @@ fi sudo service nginx reload +sudo service php5-fpm reload diff --git a/scripts/upgrade b/scripts/upgrade new file mode 100644 index 0000000..f151bbe --- /dev/null +++ b/scripts/upgrade @@ -0,0 +1,70 @@ +#!/bin/bash + +source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script + +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME + +# Source app helpers +source /usr/share/yunohost/helpers + +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +admin_name=$(ynh_app_setting_get $app admin_name) +admin_pass=$(ynh_app_setting_get $app admin_pass) +admin_email=$(ynh_app_setting_get $app admin_email) +db_pass=$(ynh_app_setting_get $app mysqlpwd) +db_user=$(ynh_app_setting_get $app db_user) + +CHECK_PATH # Vérifie et corrige la syntaxe du path. + +# Remove trailing "/" for next commands +if [[ ! "$path" == "/" ]]; then + path=${path%/} +fi + +# Copy files to the right place +final_path=/var/www/$app + +# We download the sources and check the md5sum +SFILE=`sudo cat ../sources/source_file`; +sudo wget -nv -i ../sources/source_url -O ${SFILE}.tar.gz +sudo md5sum -c ../sources/source_md5 --status || (echo "Corrupt source" >&2 && false) +sudo tar xvf ${SFILE}.tar.gz -C ../sources/ +sudo cp -a ../sources/abantecart-src-master/. $final_path + +sudo rm -rf $final_path/tests +sudo rm -rf $final_path/install.txt +sudo mv $final_path/public_html/* $final_path/ +sudo rm -rf $final_path/public_html + +# file owned by www-data before checking permissions +sudo chown www-data:www-data $final_path -R + +# 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 +sudo sed -i "s@NAMETOCHANGE@$app@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 644 $nginxconf + +sudo sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf +sudo sed -i "s@FOLDERTOCHANGE@$final_path@g" ../conf/php-fpm.conf +finalphpconf=/etc/php5/fpm/pool.d/$app.conf + +ynh_app_setting_set "$app" is_public "$is_public" +if [ "$is_public" = "Yes" ]; +then + ynh_app_setting_set "$app" unprotected_uris "/" +fi + +sudo service php5-fpm reload +sudo service nginx reload +sudo yunohost app ssowatconf + diff --git a/sources/source_upgrade b/sources/source_upgrade deleted file mode 100644 index 59259b6..0000000 --- a/sources/source_upgrade +++ /dev/null @@ -1 +0,0 @@ -https://github.com/abantecart/abantecart-src/releases/download/1.2.9/abantecart_1.2.9_upgrade_only.tar.gz diff --git a/sources/source_upgrade_md5 b/sources/source_upgrade_md5 deleted file mode 100644 index a216e6a..0000000 --- a/sources/source_upgrade_md5 +++ /dev/null @@ -1 +0,0 @@ -73cec9b57291e022599d83a403510c22 AbanteCart_1.2.9.tar.gz diff --git a/sources/source_upgrade_url b/sources/source_upgrade_url deleted file mode 100644 index ec130f6..0000000 --- a/sources/source_upgrade_url +++ /dev/null @@ -1 +0,0 @@ -https://github.com/abantecart/abantecart-src/releases/download/1.2.9/AbanteCart_1.2.9.tar.gz