From 935802384d2a6a33c0b2467ed9812a73b8d69121 Mon Sep 17 00:00:00 2001 From: oiseauroch <5622590+oiseauroch@users.noreply.github.com> Date: Wed, 26 Apr 2023 13:02:44 +0000 Subject: [PATCH] Testing improve garage package (#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * - improve config panel * add regen conf --------- Co-authored-by: oiseauroch Co-authored-by: yunohost-bot Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> --- README.md | 8 ++--- README_fr.md | 8 ++--- config_panel.toml | 11 ++++++ manifest.json | 4 +-- scripts/backup | 9 +++++ scripts/config | 34 ++++++++++++++++++- scripts/install | 22 +++++++----- scripts/remove | 8 +++++ scripts/restore | 6 +++- .../hooks/conf_regen/98-nginx_garage | 8 +++-- 10 files changed, 95 insertions(+), 23 deletions(-) rename hooks/conf_regen => sources/hooks/conf_regen/98-nginx_garage (82%) diff --git a/README.md b/README.md index b9abfb9..3d2a23c 100644 --- a/README.md +++ b/README.md @@ -3,15 +3,15 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app It shall NOT be edited by hand. --> -# garage_ynh for YunoHost +# Garage for YunoHost [![Integration level](https://dash.yunohost.org/integration/garage.svg)](https://dash.yunohost.org/appci/app/garage) ![Working status](https://ci-apps.yunohost.org/ci/badges/garage.status.svg) ![Maintenance status](https://ci-apps.yunohost.org/ci/badges/garage.maintain.svg) -[![Install garage_ynh with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=garage) +[![Install Garage with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=garage) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install garage_ynh quickly and simply on a YunoHost server. +> *This package allows you to install Garage quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview @@ -35,7 +35,7 @@ Garage is designed for storage clusters composed of nodes running at different p - K2V API (experimental) -**Shipped version:** 0.8.0~ynh3 +**Shipped version:** 0.8.0~ynh4 ## Disclaimers / important information * Limitations : diff --git a/README_fr.md b/README_fr.md index 2f74e15..b4515aa 100644 --- a/README_fr.md +++ b/README_fr.md @@ -3,15 +3,15 @@ N.B.: This README was automatically generated by https://github.com/YunoHost/app It shall NOT be edited by hand. --> -# garage_ynh pour YunoHost +# Garage pour YunoHost [![Niveau d’intégration](https://dash.yunohost.org/integration/garage.svg)](https://dash.yunohost.org/appci/app/garage) ![Statut du fonctionnement](https://ci-apps.yunohost.org/ci/badges/garage.status.svg) ![Statut de maintenance](https://ci-apps.yunohost.org/ci/badges/garage.maintain.svg) -[![Installer garage_ynh avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=garage) +[![Installer Garage avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=garage) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d’installer garage_ynh rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d’installer Garage rapidement et simplement sur un serveur YunoHost. Si vous n’avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l’installer et en profiter.* ## Vue d’ensemble @@ -35,7 +35,7 @@ Garage is designed for storage clusters composed of nodes running at different p - K2V API (experimental) -**Version incluse :** 0.8.0~ynh3 +**Version incluse :** 0.8.0~ynh4 ## Avertissements / informations importantes * Limitations : diff --git a/config_panel.toml b/config_panel.toml index 1357a9d..882eb1d 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -1,6 +1,17 @@ version = "1.0" + + [main] + [main.infos] + name = "Garage cluster informations" + + [main.infos.node] + type = "alert" + + [main.infos.status] + type = "alert" + [main.garage_conf] name = "Garage configuration" diff --git a/manifest.json b/manifest.json index b6939f7..5a4a680 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,12 @@ { - "name": "garage_ynh", + "name": "Garage", "id": "garage", "packaging_format": 1, "description": { "en": "S3 storage", "fr": "stockage S3" }, - "version": "0.8.0~ynh3", + "version": "0.8.0~ynh4", "url": "https://garagehq.deuxfleurs.fr/", "upstream": { "license": "AGPL-3.0-only", diff --git a/scripts/backup b/scripts/backup index 7f54697..049b7d3 100755 --- a/scripts/backup +++ b/scripts/backup @@ -66,6 +66,7 @@ ynh_backup --src_path="$final_path" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" + #================================================= # SPECIFIC BACKUP #================================================= @@ -74,6 +75,12 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/logrotate.d/$app" +#================================================= +# BACKUP HOOK +#================================================= + +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" + #================================================= # BACKUP SYSTEMD #================================================= @@ -81,6 +88,8 @@ ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/systemd/system/$app.service" +ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/config b/scripts/config index 78e042c..dd482d3 100644 --- a/scripts/config +++ b/scripts/config @@ -18,7 +18,10 @@ final_path=$(ynh_app_setting_get $app final_path) node_id=$(ynh_app_setting_get $app node_id) virtualisation=$(ynh_app_setting_get $app virtualisation) datadir=$(ynh_app_setting_get $app datadir) -nbd_index=$(cat $datadir/nbd_index) +if [ "$virtualisation" = "true" ] +then + nbd_index=$(cat $datadir/nbd_index) +fi command="$final_path/garage -c $final_path/garage.toml" get__weight() { @@ -64,6 +67,35 @@ set__bootstrap_peers() { ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers } +get__node() { +cat << EOF +ask: + en: "**Node Id** : $($command node id -q) \n + *This id is a sensitive information and should not be shared with anyone else than other nodes of the cluster*" +style: "info" +EOF +} + +get__status() { +status=$($command status 2> /dev/null | sed -E 's/([a-z0-9]{16})/\n**\1**/g') +cat << EOF +ask: + en: "**Current garage layout**: \n +$status" +EOF + +if [[ "$(echo \"$status\" | grep \"FAILED NODES\")" ]] || [[ "$(echo \"$status\" | grep 'garage layout show')" ]] +then + cat << EOF +style: "danger" +EOF +else + cat << EOF +style: "success" +EOF +fi +} + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/install b/scripts/install index 0d5bd16..491d206 100755 --- a/scripts/install +++ b/scripts/install @@ -201,14 +201,6 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config -#add wildcard subdomain -ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" -ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" -#================================================= -# SPECIFIC SETUP -#================================================= -# ... -#================================================= #================================================= # ADD A CONFIGURATION @@ -292,6 +284,20 @@ then VIRTUALISATION=true $final_path/umount_disk.sh fi +#================================================= +# ADD REGEN-CONF HOOK +#================================================= +ynh_script_progression --message="adding regen-conf hook..." --weight=1 + + ynh_add_config --template="../sources/hooks/conf_regen/98-nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" +#cp -R ../sources/hooks/conf_regen/98-nginx_garage /usr/share/yunohost/hooks/conf_regen/95-nginx_$app + + +ynh_systemd_action --service_name=nginx --action="reload" + +yunohost tools regen-conf nginx + + #================================================= # SETUP SYSTEMD #================================================= diff --git a/scripts/remove b/scripts/remove index 4058727..1e46c73 100755 --- a/scripts/remove +++ b/scripts/remove @@ -96,6 +96,10 @@ ynh_secure_remove --file="$final_path" ynh_script_progression --message="Removing app data directory..." --weight=1 ynh_secure_remove --file="$datadir" +#================================================= +# REMOVE NGINX HOOK +#================================================= + #================================================= # REMOVE NGINX CONFIGURATION #================================================= @@ -147,6 +151,10 @@ ynh_script_progression --message="Removing the dedicated system user..." --weig # Delete a system user ynh_system_user_delete --username=$app +ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" +yunohost tools regen-conf nginx +ynh_systemd_action --service_name=nginx --action="reload" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/restore b/scripts/restore index c41fd10..70607ab 100755 --- a/scripts/restore +++ b/scripts/restore @@ -115,7 +115,11 @@ ynh_script_progression --message="Restoring the NGINX web server configuration.. ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #add wildcard subdomain -ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" + + +ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" +yunohost tools regen-conf nginx +ynh_systemd_action --service_name=nginx --action="reload" #================================================= diff --git a/hooks/conf_regen b/sources/hooks/conf_regen/98-nginx_garage similarity index 82% rename from hooks/conf_regen rename to sources/hooks/conf_regen/98-nginx_garage index ebfcbf5..a974512 100644 --- a/hooks/conf_regen +++ b/sources/hooks/conf_regen/98-nginx_garage @@ -1,10 +1,12 @@ #!/bin/bash -source /usr/share/yunohost/helpers - - action=$1 +pending_dir=$4 domain=__DOMAIN__ +app=__APP__ + +[[ "$action" == "pre" ]] || exit 0 +source /usr/share/yunohost/helpers ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf"