From 37afd78cacbd8357b43a7141d26111c00e61ee5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 22 Jun 2022 10:58:12 +0200 Subject: [PATCH] install postgresql --- scripts/_common.sh | 3 +++ scripts/install | 7 +++++++ scripts/remove | 12 ++++++++++-- scripts/restore | 19 ++++++++++++++----- scripts/upgrade | 7 +++++++ 5 files changed, 41 insertions(+), 7 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 944a65e..91f698b 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,6 +4,9 @@ # COMMON VARIABLES #================================================= +# dependencies used by the app +pkg_dependencies="postgresql" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 6bb3c6b..94ee558 100644 --- a/scripts/install +++ b/scripts/install @@ -68,6 +68,13 @@ ynh_script_progression --message="Finding an available port..." --weight=3 port=$(ynh_find_port --port=8065) ynh_app_setting_set --app=$app --key=port --value=$port +#================================================= +# INSTALL DEPENDENCIES +#================================================= +ynh_script_progression --message="Installing dependencies..." --weight=10 + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies + #================================================= # CREATE DEDICATED USER #================================================= diff --git a/scripts/remove b/scripts/remove index 4aaf73b..a89969a 100755 --- a/scripts/remove +++ b/scripts/remove @@ -44,12 +44,20 @@ ynh_script_progression --message="Stopping and removing the systemd service..." ynh_remove_systemd_config #================================================= -# REMOVE THE MySQL DATABASE +# REMOVE THE DATABASE #================================================= ynh_script_progression --message="Removing the MySQL database..." --weight=2 # Remove a database if it exists, along with the associated user -ynh_mysql_remove_db --db_user=$db_user --db_name=$db_name +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name + +#================================================= +# REMOVE DEPENDENCIES +#================================================= +ynh_script_progression --message="Removing dependencies..." --weight=3 + +# Remove metapackage and its dependencies +ynh_remove_app_dependencies #================================================= # REMOVE APP MAIN DIR diff --git a/scripts/restore b/scripts/restore index a5d42d6..46910e1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -83,13 +83,22 @@ chmod -R o-rwx "$data_path" chown -R $app:www-data "$data_path" #================================================= -# RESTORE THE MYSQL DATABASE +# REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Restoring the MySQL database..." --weight=6 +ynh_script_progression --message="Reinstalling dependencies..." --weight=10 -db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd) -ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd -ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql +# Define and install dependencies +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies + +#================================================= +# RESTORE THE DATABASE +#================================================= +ynh_script_progression --message="Restoring the database..." --weight=6 + +db_pwd=$(ynh_app_setting_get --app=$app --key=psqlpwd) +ynh_psql_test_if_first_run +ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd +ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name #================================================= # RESTORE USER RIGHTS diff --git a/scripts/upgrade b/scripts/upgrade index 1b5bdd2..a0befdd 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -158,6 +158,13 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." - # Create a dedicated NGINX config ynh_add_nginx_config +#================================================= +# UPGRADE DEPENDENCIES +#================================================= +ynh_script_progression --message="Upgrading dependencies..." --weight=10 + +ynh_exec_warn_less ynh_install_app_dependencies $pkg_dependencies + #================================================= # SETUP SYSTEMD #=================================================