From d8b2442e6f9f61793611de36a8fd67b860df32ee Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:25:46 +0000 Subject: [PATCH 01/13] Store dbpass --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index 59f9091..7c8bad8 100644 --- a/scripts/install +++ b/scripts/install @@ -48,6 +48,8 @@ dbname=$app dbuser=$app dbpass=$(ynh_string_random) ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" +ynh_app_setting_set "$app" dbuser "$dbuser" +ynh_app_setting_set "$app" dbpass "$dbpass" # Store the database access echo -e "# MySQL Database" From b991341119e2c09677d23f04f4ad824ce7524ce1 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:27:09 +0000 Subject: [PATCH 02/13] Cleaning --- scripts/install | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 7c8bad8..d07fcca 100644 --- a/scripts/install +++ b/scripts/install @@ -90,7 +90,8 @@ sudo php cli_install.php install \ --db_prefix=_ac_ \ --admin_path=admin popd - + +sudo rm -rf /var/www/$app/install/ # file owned by www-data before checking permissions sudo chown www-data:www-data $final_path -R @@ -121,8 +122,6 @@ then ynh_app_setting_set "$app" unprotected_uris "/" fi -sudo rm -rf /var/www/$app/install/ - sudo service php5-fpm reload sudo service nginx reload sudo yunohost app ssowatconf From e6c5dd093a7ef685c8444794d5db6b97efd32a83 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:28:36 +0000 Subject: [PATCH 03/13] Update on secure_remove --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index ebe414b..002eb0a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -11,7 +11,7 @@ domain=$(ynh_app_setting_get $app domain) ynh_mysql_drop_db $app # Remove installed files -SECURE_REMOVE '/var/www/${app}' +SECURE_REMOVE '/var/www/$app' REMOVE_NGINX_CONF REMOVE_FPM_CONF From ba823c8906ad8eeab06eaa4c97728128701dfe50 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:30:52 +0000 Subject: [PATCH 04/13] Clean mysql database removal --- scripts/install | 2 +- scripts/remove | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index d07fcca..41072e6 100644 --- a/scripts/install +++ b/scripts/install @@ -48,7 +48,7 @@ dbname=$app dbuser=$app dbpass=$(ynh_string_random) ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass" -ynh_app_setting_set "$app" dbuser "$dbuser" +ynh_app_setting_set "$app" dbname "$dbname" ynh_app_setting_set "$app" dbpass "$dbpass" # Store the database access diff --git a/scripts/remove b/scripts/remove index 002eb0a..d4554dc 100644 --- a/scripts/remove +++ b/scripts/remove @@ -7,11 +7,12 @@ source /usr/share/yunohost/helpers source .fonctions domain=$(ynh_app_setting_get $app domain) +dbname=$(ynh_app_setting_get $app dbname) -ynh_mysql_drop_db $app +REMOVE_BDD "$dname" # Remove installed files -SECURE_REMOVE '/var/www/$app' +SECURE_REMOVE '/var/www/${app}' REMOVE_NGINX_CONF REMOVE_FPM_CONF From 297cc6e8007b32c3346c3bf56f8c4cf841ee685d Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:43:25 +0000 Subject: [PATCH 05/13] Preparation for upgrade file to be downloaded --- sources/source_upgrade_md5 | 1 + sources/source_upgrade_url | 1 + 2 files changed, 2 insertions(+) create mode 100644 sources/source_upgrade_md5 create mode 100644 sources/source_upgrade_url diff --git a/sources/source_upgrade_md5 b/sources/source_upgrade_md5 new file mode 100644 index 0000000..a216e6a --- /dev/null +++ b/sources/source_upgrade_md5 @@ -0,0 +1 @@ +73cec9b57291e022599d83a403510c22 AbanteCart_1.2.9.tar.gz diff --git a/sources/source_upgrade_url b/sources/source_upgrade_url new file mode 100644 index 0000000..ec130f6 --- /dev/null +++ b/sources/source_upgrade_url @@ -0,0 +1 @@ +https://github.com/abantecart/abantecart-src/releases/download/1.2.9/AbanteCart_1.2.9.tar.gz From 512f22346b2227ec7dd11e38524dbc66fd7efa22 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 19:52:46 +0000 Subject: [PATCH 06/13] Upgrade script and some improvements --- manifest.json | 6 ++-- scripts/install | 23 +++++++------ scripts/remove | 5 +-- scripts/upgrade | 70 ++++++++++++++++++++++++++++++++++++++ sources/source_upgrade | 1 - sources/source_upgrade_md5 | 1 - sources/source_upgrade_url | 1 - 7 files changed, 88 insertions(+), 19 deletions(-) create mode 100644 scripts/upgrade delete mode 100644 sources/source_upgrade delete mode 100644 sources/source_upgrade_md5 delete mode 100644 sources/source_upgrade_url 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 From e85b83bd946a6364c19b52e12df4aa0e667f3124 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 20:00:51 +0000 Subject: [PATCH 07/13] Creation of backup and restore scripts --- scripts/backup | 31 +++++++++++++++++++++++++++++++ scripts/install | 5 +---- scripts/restore | 46 ++++++++++++++++++++++++++++++++++++++++++++++ scripts/upgrade | 3 --- 4 files changed, 78 insertions(+), 7 deletions(-) create mode 100644 scripts/backup create mode 100644 scripts/restore diff --git a/scripts/backup b/scripts/backup new file mode 100644 index 0000000..f6484b1 --- /dev/null +++ b/scripts/backup @@ -0,0 +1,31 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME + +final_path=$(ynh_app_setting_get $app final_path) +domain=$(ynh_app_setting_get $app domain) +db_name=$(ynh_app_setting_get $app db_name) + +# The parameter $1 is the backup directory location +# which will be compressed afterward + +# Backup sources & data +ynh_backup "$final_path" "sources" + +# Copy Nginx and YunoHost parameters to make the script "standalone" +ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "nginx.conf" + +ynh_backup "/etc/yunohost/apps/$app/" "yunohost" + +# Copy dedicated php-fpm process to backup folder +ynh_backup "/etc/php5/fpm/pool.d/$app.conf" "php-fpm.conf" + +# Backup db +root_pwd=$(sudo cat /etc/yunohost/mysql) +sudo mysqldump -u root -p$root_pwd --no-create-db $db_user --result-file="db.sql" +ynh_backup "db.sql" "backupdb.sql" + diff --git a/scripts/install b/scripts/install index d87c551..7165a15 100644 --- a/scripts/install +++ b/scripts/install @@ -52,10 +52,6 @@ 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" - - # Remove trailing "/" for next commands if [[ ! "$path" == "/" ]]; then path=${path%/} @@ -63,6 +59,7 @@ fi # Copy files to the right place final_path=/var/www/$app +ynh_app_setting_set "$app" final_path "$final_path" # We download the sources and check the md5sum SFILE=`sudo cat ../sources/source_file`; diff --git a/scripts/restore b/scripts/restore new file mode 100644 index 0000000..e81e2fe --- /dev/null +++ b/scripts/restore @@ -0,0 +1,46 @@ +#!/bin/bash + +# Source app helpers +source /usr/share/yunohost/helpers + +# Récupère les infos de l'application. +app=$YNH_APP_INSTANCE_NAME + +domain=$(ynh_app_setting_get $app domain) +path=$(ynh_app_setting_get $app path) +final_path=$(ynh_app_setting_get $app final_path) +db_name=$(ynh_app_setting_get $app db_name) +db_pass=$(ynh_app_setting_get $app db_pass) + +if [ -d $final_path ]; then + echo "There is already a directory: $final_path " >&2 + exit 1 +fi + +# Restore Nginx +conf=/etc/nginx/conf.d/$domain.d/$app.conf +if [ -f $conf ]; then + echo "There is already a nginx conf file at this path: $conf " >&2 + exit 1 +fi +sudo cp -a ./nginx.conf $conf + +# Restore YunoHost parameters +sudo cp -a ./yunohost/. /etc/yunohost/apps/$app/ + +# Restore sources & data +sudo mkdir -p $final_path +sudo cp -a ./sources/. $final_path/ + +ynh_mysql_create_db $db_name $db_name $db_pass +mysql --debug-check -u $db_user -p$db_pwd $db_user < ./backupdb.sql + +# Copy dedicated php-fpm process from backup folder to the right location +sudo cp -a ./php-fpm.conf /etc/php5/fpm/pool.d/$app.conf + +# And Reload services +sudo service php5-fpm reload +sudo service nginx reload + +sudo yunohost app ssowatconf + diff --git a/scripts/upgrade b/scripts/upgrade index f151bbe..54fe0f8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,9 +24,6 @@ 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 From a75c8426be87b8562f4b697aad73f8ee802ae869 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 21:41:38 +0000 Subject: [PATCH 08/13] Use of double "" instead of single '' --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 1edfdae..65dc445 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ db_name=$(ynh_app_setting_get $app db_name) REMOVE_BDD "$db_name" # Remove installed files -SECURE_REMOVE '/var/www/${app}' +SECURE_REMOVE "/var/www/${app}" REMOVE_NGINX_CONF REMOVE_FPM_CONF From 76c447dadec9bad0b25e0a4f10e291fad7f4ebad Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 21:46:25 +0000 Subject: [PATCH 09/13] Single ' ' but no { } --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 65dc445..4b0469c 100644 --- a/scripts/remove +++ b/scripts/remove @@ -12,7 +12,7 @@ db_name=$(ynh_app_setting_get $app db_name) REMOVE_BDD "$db_name" # Remove installed files -SECURE_REMOVE "/var/www/${app}" +SECURE_REMOVE '/var/www/$app' REMOVE_NGINX_CONF REMOVE_FPM_CONF From de5f7ddcd3450a8cfc8c041ca52374ea9928e7f7 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 23:28:07 +0000 Subject: [PATCH 10/13] Integrate functions in the file itself --- scripts/remove | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 4b0469c..07cea36 100644 --- a/scripts/remove +++ b/scripts/remove @@ -4,7 +4,60 @@ app=$YNH_APP_INSTANCE_NAME set -u # Source app helpers source /usr/share/yunohost/helpers -source .fonctions + +REMOVE_NGINX_CONF () { # Suppression de la configuration nginx + if [ -e "/etc/nginx/conf.d/$domain.d/$app.conf" ]; then # Delete nginx config + echo "Delete nginx config" + sudo rm "/etc/nginx/conf.d/$domain.d/$app.conf" + fi +} + +REMOVE_FPM_CONF () { # Suppression de la configuration du pool php-fpm + if [ -e "/etc/php5/fpm/pool.d/$app.conf" ]; then # Delete fpm config + echo "Delete fpm config" + sudo rm "/etc/php5/fpm/pool.d/$app.conf" + fi +} + +SECURE_REMOVE () { # Suppression de dossier avec vérification des variables + chaine="$1" # L'argument doit être donné entre quotes simple '', pour éviter d'interpréter les variables. + no_var=0 + while (echo "$chaine" | grep -q '\$') # Boucle tant qu'il y a des $ dans la chaine + do + no_var=1 + global_var=$(echo "$chaine" | cut -d '$' -f 2) # Isole la première variable trouvée. + only_var=\$$(expr "$global_var" : '\([A-Za-z0-9_]*\)') # Isole complètement la variable en ajoutant le $ au début et en gardant uniquement le nom de la variable. Se débarrasse$ + real_var=$(eval "echo ${only_var}") # `eval "echo ${var}` permet d'interpréter une variable contenue dans une variable. + if test -z "$real_var" || [ "$real_var" = "/" ]; then + echo "Variable $only_var is empty, suppression of $chaine cancelled." >&2 + return 1 + fi + chaine=$(echo "$chaine" | sed "s@$only_var@$real_var@") # remplace la variable par sa valeur dans la chaine. + done + if [ "$no_var" -eq 1 ] + then + if [ -e "$chaine" ]; then + echo "Delete directory $chaine" + sudo rm -r "$chaine" + fi + return 0 + else + echo "No detected variable." >&2 + return 1 + fi +} + +REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé. +# $1 = Nom de la base de donnée + # Utilise '$app' comme nom d'utilisateur et de base de donnée + db_user=$1 + if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then + echo "Delete db" + ynh_mysql_drop_db $db_user + ynh_mysql_drop_user $db_user + fi +} + domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) From afd1e6d5f2ac15cdd43e5dd99ade936638b6e501 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 23:37:58 +0000 Subject: [PATCH 11/13] Safe database removal --- scripts/remove | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/remove b/scripts/remove index 07cea36..b55eb04 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,6 +1,7 @@ #!/bin/bash app=$YNH_APP_INSTANCE_NAME + set -u # Source app helpers source /usr/share/yunohost/helpers @@ -59,7 +60,6 @@ REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé } -domain=$(ynh_app_setting_get $app domain) db_name=$(ynh_app_setting_get $app db_name) REMOVE_BDD "$db_name" From 783ad1e1c9ba451d596adb4023557ea0bef27af1 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 23:49:58 +0000 Subject: [PATCH 12/13] Missing domain parameter & cleaning --- scripts/remove | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/remove b/scripts/remove index b55eb04..92bf503 100644 --- a/scripts/remove +++ b/scripts/remove @@ -1,8 +1,7 @@ #!/bin/bash -app=$YNH_APP_INSTANCE_NAME - set -u + # Source app helpers source /usr/share/yunohost/helpers @@ -60,7 +59,10 @@ REMOVE_BDD () { # Suppression de la base de donnée et de l'utilisateur associé } -db_name=$(ynh_app_setting_get $app db_name) +# We retrieve app parameters +app=$YNH_APP_INSTANCE_NAME +domain=$(ynh_app_setting_get "$app" domain) +db_name=$(ynh_app_setting_get "$app" db_name) REMOVE_BDD "$db_name" From 351a285a4a9d981c4c07f7fb630f6685c6ec8228 Mon Sep 17 00:00:00 2001 From: polytan02 Date: Fri, 24 Feb 2017 23:57:56 +0000 Subject: [PATCH 13/13] set -eu & ynh_die --- scripts/backup | 1 + scripts/restore | 5 +++-- scripts/upgrade | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/backup b/scripts/backup index f6484b1..5ddf19d 100644 --- a/scripts/backup +++ b/scripts/backup @@ -1,4 +1,5 @@ #!/bin/bash +set -eu # Source app helpers source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index e81e2fe..6e2db97 100644 --- a/scripts/restore +++ b/scripts/restore @@ -1,4 +1,5 @@ #!/bin/bash +set -eu # Source app helpers source /usr/share/yunohost/helpers @@ -14,14 +15,14 @@ db_pass=$(ynh_app_setting_get $app db_pass) if [ -d $final_path ]; then echo "There is already a directory: $final_path " >&2 - exit 1 + ynh_die fi # Restore Nginx conf=/etc/nginx/conf.d/$domain.d/$app.conf if [ -f $conf ]; then echo "There is already a nginx conf file at this path: $conf " >&2 - exit 1 + ynh_die fi sudo cp -a ./nginx.conf $conf diff --git a/scripts/upgrade b/scripts/upgrade index 54fe0f8..3d6fdd8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -1,4 +1,5 @@ #!/bin/bash +set -eu source .fonctions # Charge les fonctions génériques habituellement utilisées dans le script