From 1a7800facf28ae34e6314994a20279f6c70a55f7 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Fri, 3 Mar 2023 15:00:42 +0100 Subject: [PATCH] - improve config panel - fix backup script for no virtualisation - improve hook regen_conf --- config_panel.toml | 11 +++++++++++ hooks/conf_regen | 14 ++++++++++---- manifest.json | 2 +- scripts/config | 34 +++++++++++++++++++++++++++++++++- scripts/install | 2 +- 5 files changed, 56 insertions(+), 7 deletions(-) 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/hooks/conf_regen b/hooks/conf_regen index ebfcbf5..d49fbaf 100644 --- a/hooks/conf_regen +++ b/hooks/conf_regen @@ -2,9 +2,15 @@ source /usr/share/yunohost/helpers +garage_domains=$(yunohost app list --json | jq '.apps[] | select(.id | test("garage*")) | .domain_path') -action=$1 -domain=__DOMAIN__ +for domain in $garage_domains; +do + domain=${domain//\"/} + if [[ "$domain" =~ "/" ]] + then + domain=${domain/\//} + ynh_replace_special_string --match_string="server_name $domain;" --replace_string="server_name $domain *.$> + fi +done -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" diff --git a/manifest.json b/manifest.json index b6939f7..0f70130 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "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/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..cb5e194 100755 --- a/scripts/install +++ b/scripts/install @@ -202,7 +202,7 @@ ynh_script_progression --message="Configuring NGINX web server..." --weight=1 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_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