Fix upgrade, source cleanups

This commit is contained in:
Jean-Baptiste Holcroft 2018-03-31 12:09:27 +02:00
parent 266578d67d
commit a3fe7313a9
5 changed files with 45 additions and 31 deletions

View file

@ -9,14 +9,15 @@
if [ ! -e _common.sh ]; then if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory # Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh 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 fi
source _common.sh 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 /usr/share/yunohost/helpers
source psql.sh
source nodejs.sh
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE

View file

@ -7,11 +7,9 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ../settings/scripts/psql.sh source /usr/share/yunohost/helpers
source ../settings/scripts/nodejs.sh
source psql.sh source psql.sh
source nodejs.sh source nodejs.sh
source /usr/share/yunohost/helpers
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
@ -19,9 +17,6 @@ source /usr/share/yunohost/helpers
# Exit if an error occurs during the execution of the script # Exit if an error occurs during the execution of the script
ynh_abort_if_errors ynh_abort_if_errors
#ynh_clean_setup () {
#
#}
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST

View file

@ -8,11 +8,9 @@
#================================================= #=================================================
source _common.sh source _common.sh
source ../settings/scripts/psql.sh source /usr/share/yunohost/helpers
source ../settings/scripts/nodejs.sh
source psql.sh source psql.sh
source nodejs.sh source nodejs.sh
source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS

View file

@ -9,14 +9,15 @@
if [ ! -e _common.sh ]; then if [ ! -e _common.sh ]; then
# Get the _common.sh file if it's not in the current directory # Get the _common.sh file if it's not in the current directory
cp ../settings/scripts/_common.sh ./_common.sh 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 fi
source _common.sh 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 /usr/share/yunohost/helpers
source psql.sh
source nodejs.sh
#================================================= #=================================================
# MANAGE SCRIPT FAILURE # MANAGE SCRIPT FAILURE
@ -54,13 +55,10 @@ ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
# FIND AND OPEN A PORT # FIND AND OPEN A PORT
#================================================= #=================================================
# Find a free port
ynh_find_port "$port"
# Open this port # Open this port
yunohost firewall allow Both "$port" 2>&1 yunohost firewall allow Both "$port" 2>&1
ynh_app_setting_set "$app" port "$port" ynh_app_setting_set "$app" port "$port"
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
@ -80,14 +78,6 @@ ynh_system_user_create "$app"
datadir="/home/yunohost.app/${app}/storage" datadir="/home/yunohost.app/${app}/storage"
chown -R "$app" "$datadir" 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 # SPECIFIC RESTORATION
#================================================= #=================================================
@ -109,6 +99,14 @@ ynh_install_app_dependencies postgresql-9.4 ffmpeg redis-server redis-tools
# install nodejs # install nodejs
ynh_install_nodejs 8 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 # RESTORE SYSTEMD
#================================================= #=================================================
@ -125,6 +123,9 @@ ynh_restore_file "/etc/logrotate.d/$app"
#================================================= #=================================================
# GENERIC FINALIZATION # GENERIC FINALIZATION
#================================================= #=================================================
chown -R "$app" "$datadir"
(cd "$final_path" && yarn install --production --pure-lockfile) (cd "$final_path" && yarn install --production --pure-lockfile)
systemctl reload nginx systemctl reload nginx
service "$app" restart service "$app" restart

View file

@ -7,9 +7,9 @@
#================================================= #=================================================
source _common.sh source _common.sh
source /usr/share/yunohost/helpers
source psql.sh source psql.sh
source nodejs.sh source nodejs.sh
source /usr/share/yunohost/helpers
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
@ -75,6 +75,25 @@ yunohost firewall allow Both "$port" 2>&1
# Create a system user # Create a system user
ynh_system_user_create "$app" 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 # CHECK THE PATH
#================================================= #=================================================