From 32e810658f24439db0553bb9e4e78964697c6a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:39:50 +0100 Subject: [PATCH] cleaning --- doc/ADMIN.md | 2 +- doc/ADMIN_fr.md | 2 +- manifest.toml | 2 +- scripts/change_url | 2 +- scripts/install | 43 +++++++++++++++---------------------------- scripts/remove | 20 +------------------- scripts/restore | 32 +++++--------------------------- 7 files changed, 25 insertions(+), 78 deletions(-) diff --git a/doc/ADMIN.md b/doc/ADMIN.md index e974bf9..9722dc3 100644 --- a/doc/ADMIN.md +++ b/doc/ADMIN.md @@ -1 +1 @@ -You can configure CodiMD by editing this file `/var/www/codimd/config.json` using the [documentation](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) +You can configure CodiMD by editing this file `__INSTALL_DIR__/config.json` using the [documentation](https://hackmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) diff --git a/doc/ADMIN_fr.md b/doc/ADMIN_fr.md index 0ac335e..1b2cf9d 100644 --- a/doc/ADMIN_fr.md +++ b/doc/ADMIN_fr.md @@ -1 +1 @@ -Vous pouvez configurer CodiMD en éditant ce fichier `/var/www/codimd/config.json` en utilisant la [documentation](https://hakmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) +Vous pouvez configurer CodiMD en éditant ce fichier `__INSTALL_DIR__/config.json` en utilisant la [documentation](https://hakmd.io/c/codimd-documentation/%2Fs%2Fcodimd-configuration) diff --git a/manifest.toml b/manifest.toml index 66b217b..bfa721f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "CodiMD" description.en = "Collaborative editor to work on notes written in Markdown" description.fr = "Éditeur collaboratif pour travailler sur des notes en Markdown" -version = "2.4.2~ynh2" +version = "2.4.2~ynh3" maintainers = ["eric_G"] diff --git a/scripts/change_url b/scripts/change_url index 9e8049d..4922e49 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -31,7 +31,7 @@ ynh_change_url_nginx_config path=${path:1} domain=new_domain -ynh_add_config --template="../conf/config.json.example" --destination="$install_dir/config.json" +ynh_add_config --template="config.json.example" --destination="$install_dir/config.json" #================================================= # GENERIC FINALISATION diff --git a/scripts/install b/scripts/install index 0545ad8..513b473 100644 --- a/scripts/install +++ b/scripts/install @@ -22,7 +22,6 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= ynh_script_progression --message="Setting up source files..." --weight=2 -# Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir=$install_dir chmod -R o-rwx "$install_dir" @@ -34,9 +33,23 @@ chmod +x $install_dir/app.js #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=2 -# Create a dedicated NGINX config ynh_add_nginx_config +ynh_add_systemd_config + +yunohost service add $app --description="Collaborative Markdown notes" --log="/var/log/$app/$app.log" + +#================================================= +# ADD A CONFIGURATION +#================================================= +ynh_script_progression --message="Modifying a config file..." --weight=1 + +ynh_add_config --template="config.json.example" --destination="$install_dir/config.json" +ynh_add_config --template=".sequelizerc.example" --destination="$install_dir/.sequelizerc" + +chmod 600 $install_dir/config.json +chmod 600 $install_dir/.sequelizerc + #================================================= # SPECIFIC SETUP #================================================= @@ -50,32 +63,6 @@ pushd $install_dir ynh_exec_warn_less ynh_exec_as $app env $ynh_node_load_PATH $ynh_npm run build popd -#================================================= -# ADD A CONFIGURATION -#================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 - -ynh_add_config --template="../conf/config.json.example" --destination="$install_dir/config.json" -ynh_add_config --template="../conf/.sequelizerc.example" --destination="$install_dir/.sequelizerc" - -chmod 600 $install_dir/config.json -chmod 600 $install_dir/.sequelizerc - -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 - -# Create a dedicated systemd config -ynh_add_systemd_config - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 - -yunohost service add $app --description="Collaborative Markdown notes" --log="/var/log/$app/$app.log" - #================================================= # START SYSTEMD SERVICE #================================================= diff --git a/scripts/remove b/scripts/remove index a814340..64802ec 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,36 +14,18 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= +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 then ynh_script_progression --message="Removing $app service..." --weight=1 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 NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=5 - -# Remove the dedicated NGINX config ynh_remove_nginx_config -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies ynh_remove_nodejs #================================================= diff --git a/scripts/restore b/scripts/restore index e0dcdda..d3361ec 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,19 +6,9 @@ # IMPORT GENERIC HELPERS #================================================= -# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RESTORE THE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the NGINX configuration..." - -ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" - #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -26,7 +16,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" - chmod -R o-rwx "$install_dir" chown -R $app:www-data "$install_dir" @@ -37,7 +26,6 @@ chown -R $app:www-data "$install_dir" #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=7 -# Install Nodejs ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= @@ -45,37 +33,27 @@ ynh_exec_warn_less ynh_install_nodejs --nodejs_version=$nodejs_version #================================================= 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 #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=5 +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" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app --description="Collaborative Markdown notes" --log="/var/log/$app/$app.log" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +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="HTTP Server listening" -#================================================= -# GENERIC FINALIZATION -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - ynh_systemd_action --service_name=nginx --action=reload #=================================================