From 2320a017833f5f9f40fa27d99b4683afe93998cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Tue, 14 Nov 2023 11:38:04 +0100 Subject: [PATCH] cleaning --- scripts/install | 22 ++++++++++++---------- scripts/remove | 8 -------- scripts/restore | 9 +-------- scripts/upgrade | 4 ++-- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/scripts/install b/scripts/install index 16b2ec0..2244860 100644 --- a/scripts/install +++ b/scripts/install @@ -16,17 +16,7 @@ ynh_script_progression --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs -ynh_install_mongo -#================================================= -# CREATE A MONGODB DATABASE -#================================================= -ynh_script_progression --message="Creating a MongoDB database..." - -db_name=$(ynh_sanitize_dbid --db_name=$app) -db_user=$db_name -ynh_app_setting_set --app=$app --key=db_name --value=$db_name -ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -39,6 +29,18 @@ ynh_setup_source --dest_dir="$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" +#================================================= +# CREATE A MONGODB DATABASE +#================================================= +ynh_script_progression --message="Creating a MongoDB database..." + +db_name=$(ynh_sanitize_dbid --db_name=$app) +db_user=$db_name +ynh_app_setting_set --app=$app --key=db_name --value=$db_name + +ynh_install_mongo +ynh_mongo_setup_db --db_user=$db_user --db_name=$db_name + #================================================= # NGINX CONFIGURATION #================================================= diff --git a/scripts/remove b/scripts/remove index 8a5c2cd..26100a7 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,14 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name - #================================================= # STANDARD REMOVE #================================================= diff --git a/scripts/restore b/scripts/restore index 2de3d09..e9321d1 100644 --- a/scripts/restore +++ b/scripts/restore @@ -29,13 +29,13 @@ ynh_script_progression --message="Reinstalling dependencies..." # Define and install dependencies ynh_install_nodejs --nodejs_version=$nodejs_version ynh_use_nodejs -ynh_install_mongo #================================================= # RESTORE THE MONGODB DATABASE #================================================= ynh_script_progression --message="Restoring the MongoDB database..." +ynh_install_mongo ynh_mongo_restore_db --database="$db_name" < ./dump.bson #================================================= @@ -61,13 +61,6 @@ if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then sleep 60 fi -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." - ynh_systemd_action --service_name=nginx --action=reload #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fb95938..c5143ba 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,6 +9,8 @@ source _common.sh source /usr/share/yunohost/helpers +main_domain=$(cat /etc/yunohost/current_host) + #================================================= # CHECK VERSION #================================================= @@ -82,8 +84,6 @@ yunohost service add $app --description="Wekan daemon" --log="/var/log/$app/$app #================================================= ynh_script_progression --message="Updating a configuration file..." -main_domain=$(cat /etc/yunohost/current_host) - ynh_add_config --template=".env" --destination="$install_dir/.env" chmod 400 "$install_dir/.env"