From a3fe7313a9f1d3ea5ac7a5a0fa7a9dc38348605c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Holcroft Date: Sat, 31 Mar 2018 12:09:27 +0200 Subject: [PATCH] Fix upgrade, source cleanups --- scripts/backup | 11 ++++++----- scripts/install | 7 +------ scripts/remove | 4 +--- scripts/restore | 33 +++++++++++++++++---------------- scripts/upgrade | 21 ++++++++++++++++++++- 5 files changed, 45 insertions(+), 31 deletions(-) diff --git a/scripts/backup b/scripts/backup index e0c4e32..4070095 100644 --- a/scripts/backup +++ b/scripts/backup @@ -9,14 +9,15 @@ if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh + cp ../settings/scripts/psql.sh ./psql.sh + cp ../settings/scripts/nodejs.sh ./nodejs.sh + chmod a+rx _common.sh psql.sh nodejs.sh fi + source _common.sh -source psql.sh -source ../settings/scripts/psql.sh -source ../settings/scripts/nodejs.sh -source nodejs.sh source /usr/share/yunohost/helpers +source psql.sh +source nodejs.sh #================================================= # MANAGE SCRIPT FAILURE diff --git a/scripts/install b/scripts/install index adc2ec3..c4832e9 100644 --- a/scripts/install +++ b/scripts/install @@ -7,11 +7,9 @@ #================================================= source _common.sh -source ../settings/scripts/psql.sh -source ../settings/scripts/nodejs.sh +source /usr/share/yunohost/helpers source psql.sh source nodejs.sh -source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE @@ -19,9 +17,6 @@ source /usr/share/yunohost/helpers # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#ynh_clean_setup () { -# -#} #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST diff --git a/scripts/remove b/scripts/remove index 7aba88c..b89b9d1 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,11 +8,9 @@ #================================================= source _common.sh -source ../settings/scripts/psql.sh -source ../settings/scripts/nodejs.sh +source /usr/share/yunohost/helpers source psql.sh source nodejs.sh -source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS diff --git a/scripts/restore b/scripts/restore index 7d3a9af..affeb8f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,14 +9,15 @@ if [ ! -e _common.sh ]; then # Get the _common.sh file if it's not in the current directory cp ../settings/scripts/_common.sh ./_common.sh - chmod a+rx _common.sh + cp ../settings/scripts/psql.sh ./psql.sh + cp ../settings/scripts/nodejs.sh ./nodejs.sh + chmod a+rx _common.sh psql.sh nodejs.sh fi + source _common.sh -source psql.sh -source ../settings/scripts/psql.sh -source ../settings/scripts/nodejs.sh -source nodejs.sh source /usr/share/yunohost/helpers +source psql.sh +source nodejs.sh #================================================= # MANAGE SCRIPT FAILURE @@ -54,13 +55,10 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" # FIND AND OPEN A PORT #================================================= -# Find a free port -ynh_find_port "$port" # Open this port yunohost firewall allow Both "$port" 2>&1 ynh_app_setting_set "$app" port "$port" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -80,14 +78,6 @@ ynh_system_user_create "$app" datadir="/home/yunohost.app/${app}/storage" chown -R "$app" "$datadir" -#================================================= -# RESTORE THE PostgreSQL DATABASE -#================================================= - -ynh_psql_test_if_first_run -ynh_psql_setup_db "$app" "$db_name" "$db_pwd" -ynh_psql_execute_file_as_root ./db.sql "$db_name" - #================================================= # SPECIFIC RESTORATION #================================================= @@ -109,6 +99,14 @@ ynh_install_app_dependencies postgresql-9.4 ffmpeg redis-server redis-tools # install nodejs ynh_install_nodejs 8 +#================================================= +# RESTORE THE PostgreSQL DATABASE +#================================================= + +ynh_psql_test_if_first_run +ynh_psql_setup_db "$app" "$db_name" "$db_pwd" +ynh_psql_execute_file_as_root ./db.sql "$db_name" + #================================================= # RESTORE SYSTEMD #================================================= @@ -125,6 +123,9 @@ ynh_restore_file "/etc/logrotate.d/$app" #================================================= # GENERIC FINALIZATION #================================================= + +chown -R "$app" "$datadir" + (cd "$final_path" && yarn install --production --pure-lockfile) systemctl reload nginx service "$app" restart diff --git a/scripts/upgrade b/scripts/upgrade index 6072ed1..a6ec8e6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -7,9 +7,9 @@ #================================================= source _common.sh +source /usr/share/yunohost/helpers source psql.sh source nodejs.sh -source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS @@ -75,6 +75,25 @@ yunohost firewall allow Both "$port" 2>&1 # Create a system user ynh_system_user_create "$app" +#================================================= +# INSTALL DEPENDENCIES +#================================================= + +# install yarn +wget https://github.com/yarnpkg/yarn/releases/download/v1.5.1/yarn_1.5.1_all.deb +echo "a4770cd8dcb13dc9a9218940dbd24b510ddf5eec78adb4e0da9ef3760b55a76e yarn_1.5.1_all.deb" | sha256sum -c || ynh_die +dpkg -i yarn_1.5.1_all.deb + +# add backports (required to install ffmpeg) +echo "deb http://httpredir.debian.org/debian jessie-backports main" | tee /etc/apt/sources.list.d/jessie-backports.list +ynh_package_update + +# install postgresql, ffmpeg, redis +ynh_install_app_dependencies postgresql-9.4 ffmpeg redis-server redis-tools + +# install nodejs +ynh_install_nodejs 8 + #================================================= # CHECK THE PATH #=================================================