From 27b5edf718a5f3c528f4b639f26f7059b0ca0b55 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Fri, 22 Sep 2017 09:05:28 +0200 Subject: [PATCH] Restore rework --- scripts/restore | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/scripts/restore b/scripts/restore index 9a40218..656d58a 100755 --- a/scripts/restore +++ b/scripts/restore @@ -60,22 +60,14 @@ ynh_restore_file "$final_path" #================================================= # Create the dedicated user (if not existing) -ynh_system_user_create $app - -#================================================= -# RESTORE THE PostgreSQL DATABASE -#================================================= - -db_pwd=$(ynh_app_setting_get $app pgsqlpwd) -ynh_psql_setup_db $db_name $db_name $db_pwd -ynh_psql_connect_as $db_name $db_pwd $db_name < ./db.sql +ynh_system_user_create "$app" #================================================= # RESTORE USER RIGHTS #================================================= # Restore permissions on app files -chown -R root: $final_path +chown -R "$app": "$final_path" #================================================= # SPECIFIC RESTORATION @@ -83,14 +75,19 @@ chown -R root: $final_path # REINSTALL DEPENDENCIES #================================================= -# Define and install dependencies ynh_install_app_dependencies libxml2-dev libxslt-dev libfreetype6-dev \ - libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv + libjpeg-dev libz-dev libyaml-dev python-dev python-pip python-virtualenv \ + postgresql libpq-dev uwsgi uwsgi-plugin-python -virtualenv ${final_path}/venv -source ${final_path}/venv/bin/activate -pip install Weblate==2.16 -pip install pytz python-bidi PyYaML Babel pyuca pylibravatar pydns +#================================================= +# RESTORE THE PostgreSQL DATABASE +#================================================= + +ynh_psql_test_if_first_run + +db_pwd=$(ynh_app_setting_get "$app" pgsqlpwd) +ynh_psql_setup_db "$db_name $db_name" "$db_pwd" +ynh_psql_connect_as "$db_name" "$db_pwd" "$db_name" < ./db.sql #================================================= # RESTORE THE SERVICE @@ -102,7 +99,7 @@ ynh_restore_file "/etc/systemd/system/$app.service" # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add $app.service --log "/var/log/$app/APP.log" +yunohost service add "$app.service" --log "/var/log/$app/APP.log" #================================================= # RESTORE THE CRON FILE @@ -123,4 +120,4 @@ ynh_restore_file "/etc/logrotate.d/$app" #================================================= systemctl reload nginx -systemctl reload $app.service +systemctl reload "$app.service"