From 684c17dd0ca6845c84919e64ca43982ef1b172f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Fri, 27 Oct 2023 09:20:57 +0200 Subject: [PATCH] cleaning --- manifest.toml | 4 ++-- scripts/install | 37 +++++++++++++++---------------------- scripts/remove | 25 +++---------------------- scripts/restore | 14 +++++++++----- scripts/upgrade | 5 ++--- 5 files changed, 31 insertions(+), 54 deletions(-) diff --git a/manifest.toml b/manifest.toml index 464c2d7..2b4a8bc 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Vikunja" description.en = "Self-hosted To-Do list application" description.fr = "Application de liste de tâches auto-hébergée" -version = "0.21.0~ynh4" +version = "0.21.0~ynh5" maintainers = ["eric_G"] @@ -41,7 +41,7 @@ ram.runtime = "50M" ask.fr = "Choisissez la langue de l'application" type = "select" choices = ["de", "en", "es", "fa", "fr", "it", "lt", "nl", "pl", "pt"] - default = "en" + default = "fr" [resources] diff --git a/scripts/install b/scripts/install index cd72d20..30293fd 100644 --- a/scripts/install +++ b/scripts/install @@ -15,6 +15,8 @@ source /usr/share/yunohost/helpers timezone="$(cat /etc/timezone)" secret=$(ynh_string_random --length=32) +redis_db=$(ynh_redis_get_free_db) +backend_path=/opt/$app set_motd="" enable_registration="true" @@ -26,16 +28,11 @@ enable_userdeletion="true" maxavatarsize=1024 maxitemsperpage=50 -#================================================= -# CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS -#================================================= - -backend_path=/opt/$app - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= +ynh_app_setting_set --app=$app --key=backend_path --value=$backend_path ynh_app_setting_set --app=$app --key=set_motd --value=$set_motd ynh_app_setting_set --app=$app --key=enable_registration --value=$enable_registration ynh_app_setting_set --app=$app --key=enable_linksharing --value=$enable_linksharing @@ -54,7 +51,6 @@ ynh_script_progression --message="Setting up frontend..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$install_dir" --source_id="front" -chmod 750 "$install_dir" chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -63,8 +59,6 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Setting up backend..." --weight=1 -ynh_app_setting_set --app=$app --key=backend_path --value=$backend_path - # Download, check integrity, uncompress and patch the source from app.src mkdir -p "$backend_path" mkdir -p "$backend_path/files" @@ -77,20 +71,9 @@ chmod +x "$backend_path/vikunja" chown -R $app:www-data "$backend_path/files" #================================================= -# ADD A CONFIGURATION +# SYSTEM CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 - -redis_db=$(ynh_redis_get_free_db) -ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml" - -chmod 400 "$backend_path/config.yml" -chown $app:$app "$backend_path/config.yml" - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression --message="Adding system configurations related to $app..." --weight=1 ynh_add_nginx_config @@ -98,6 +81,16 @@ ynh_add_systemd_config yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log" +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Adding a configuration file..." --weight=1 + +ynh_add_config --template="config.yml" --destination="$backend_path/config.yml" + +chmod 400 "$backend_path/config.yml" +chown $app:$app "$backend_path/config.yml" + #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index 31c3e17..0e09476 100644 --- a/scripts/remove +++ b/scripts/remove @@ -10,10 +10,11 @@ source _common.sh source /usr/share/yunohost/helpers #================================================= -# STANDARD REMOVE +# REMOVE SYSTEM CONFIGURATIONS #================================================= -# REMOVE SERVICE INTEGRATION IN YUNOHOST +# REMOVE SYSTEMD SERVICE #================================================= +ynh_script_progression --message="Removing system configurations related to $app..." --weight=1 # Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status $app >/dev/null @@ -22,34 +23,14 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE THE REDIS DATABASE -#================================================= -ynh_script_progression --message="Removing the redis database..." - ynh_redis_remove_db "$redis_db" -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing $app main directory..." --weight=6 - # Remove backend ynh_secure_remove --file="$backend_path" -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - # Remove the dedicated NGINX config ynh_remove_nginx_config diff --git a/scripts/restore b/scripts/restore index e999a4d..8e89323 100644 --- a/scripts/restore +++ b/scripts/restore @@ -30,12 +30,14 @@ chown -R $app:www-data "$backend_path/files" #================================================= ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=6 -ynh_psql_execute_file_as_root --file="./db.sql" --database=$db_name +ynh_psql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql #================================================= -# RESTORE SYSTEMD +# RESTORE SYSTEM CONFIGURATIONS #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 +# RESTORE THE PHP-FPM CONFIGURATION +#================================================= +ynh_script_progression --message="Restoring system configurations related to $app..." --weight=1 ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" @@ -45,9 +47,11 @@ systemctl enable $app.service --quiet yunohost service add $app --description="Self-hosted To-Do list application" --log="/var/log/$app/$app.log" #================================================= -# START SYSTEMD SERVICE +# GENERIC FINALIZATION #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +# RELOAD NGINX AND PHP-FPM OR THE APP SERVICE +#================================================= +ynh_script_progression --message="Reloading NGINX web server and $app's service..." --weight=1 ynh_systemd_action --service_name=$app --action=start --log_path=systemd --line_match="server started on" diff --git a/scripts/upgrade b/scripts/upgrade index 97abbec..69bd6b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -15,6 +15,7 @@ source /usr/share/yunohost/helpers timezone="$(cat /etc/timezone)" secret=$(ynh_string_random --length=32) +redis_db=$(ynh_redis_get_free_db) #================================================= # CHECK VERSION @@ -121,8 +122,7 @@ chown -R $app:www-data "$backend_path/files" #================================================= ynh_script_progression --message="Upgrading a configuration file..." --weight=1 -redis_db=$(ynh_redis_get_free_db) -ynh_add_config --template="../conf/config.yml" --destination="$backend_path/config.yml" +ynh_add_config --template="config.yml" --destination="$backend_path/config.yml" chmod 400 "$backend_path/config.yml" chown $app:$app "$backend_path/config.yml" @@ -132,7 +132,6 @@ chown $app:$app "$backend_path/config.yml" #================================================= ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=2 -# Create a dedicated NGINX config ynh_add_nginx_config ynh_add_systemd_config