From 7b0b576f1a59724274263c16a1cc49b4ad324dbd Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 21 Feb 2023 11:11:17 +0100 Subject: [PATCH 01/88] add delay for node id --- scripts/install | 8 +++++++- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index e512b27..f28c01d 100755 --- a/scripts/install +++ b/scripts/install @@ -377,7 +377,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" #================================================= @@ -405,6 +405,12 @@ ynh_script_progression --message="Configuring garage..." --weight=1 garage_command="$final_path/garage -c $final_path/garage.toml" node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) +# sometimes server need some time to start +if [ -n "$node_id" ] +then + sleep 5 + node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) +fi ynh_app_setting_set --app=$app --key=node_id --value=$node_id diff --git a/scripts/restore b/scripts/restore index 2897727..13e0723 100755 --- a/scripts/restore +++ b/scripts/restore @@ -148,7 +148,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 #recreate log folder mkdir /var/log/$app -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" #================================================= # RECREATE CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 20c7b2a..c58c054 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,7 +185,7 @@ yunohost service add --needs_exposed_ports $port --description="s3 storage" --lo #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" #================================================= # RELOAD NGINX From 86541438bdad68df1e265865c93f76085d18d6a0 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Tue, 21 Feb 2023 10:11:38 +0000 Subject: [PATCH 02/88] Auto-update README --- README.md | 1 + README_fr.md | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 180cfe2..1a5eccd 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # garage_ynh 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) *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index 654bba3..7324270 100644 --- a/README_fr.md +++ b/README_fr.md @@ -6,6 +6,7 @@ It shall NOT be edited by hand. # garage_ynh 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) *[Read this readme in english.](./README.md)* From 85b629b5fcfac4cc0fe6998192eaecb38be36483 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 21 Feb 2023 11:50:47 +0100 Subject: [PATCH 03/88] revert line_match --- manifest.json | 2 +- scripts/install | 3 +-- scripts/restore | 3 +-- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/manifest.json b/manifest.json index b87e0bc..e1a3acd 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "S3 storage", "fr": "stockage S3" }, - "version": "0.8.0~ynh1", + "version": "0.8.0~ynh2", "url": "https://garagehq.deuxfleurs.fr/", "upstream": { "license": "AGPL-3.0-only", diff --git a/scripts/install b/scripts/install index f28c01d..a209175 100755 --- a/scripts/install +++ b/scripts/install @@ -377,8 +377,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" - +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # SETUP SSOWAT diff --git a/scripts/restore b/scripts/restore index 13e0723..c41fd10 100755 --- a/scripts/restore +++ b/scripts/restore @@ -148,8 +148,7 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 #recreate log folder mkdir /var/log/$app -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" - +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RECREATE CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index c58c054..20c7b2a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,7 +185,7 @@ yunohost service add --needs_exposed_ports $port --description="s3 storage" --lo #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" --line_match="INFO netapp::netapp: Listening on" +ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" #================================================= # RELOAD NGINX From b8b788372f7cd866e8dcf359e1461b64cbf08115 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Wed, 22 Feb 2023 16:03:01 +0100 Subject: [PATCH 04/88] add message for long configuration add delay for node id --- scripts/install | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index a209175..0b39c97 100755 --- a/scripts/install +++ b/scripts/install @@ -253,8 +253,11 @@ chown $app:$app "$final_path/garage.toml" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --weight=1 - +ynh_script_progression --message="Creating a data directory..." --weight=5 +if [ "$virtualisation" = "true" ] +then + ynh_print_warn --message="This may take time regarding disk size…" +fi ### Use these lines if you need to create a directory to store "persistent files" for the application. ### Usually this directory is used to store uploaded files or any file that won't be updated during ### an upgrade and that won't be deleted during app removal unless "--purge" option is used. @@ -405,11 +408,15 @@ garage_command="$final_path/garage -c $final_path/garage.toml" node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) # sometimes server need some time to start -if [ -n "$node_id" ] -then - sleep 5 +until [ -n "$node_id" ] ; do + i=$(( i + 1 )) + if [ $i -gt 30 ] + then + ynh_die --message="unable to get node id" + fi + sleep 1 node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) -fi + done ynh_app_setting_set --app=$app --key=node_id --value=$node_id From 1828687c094482be6fb16bbee58a78152b17541a Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Wed, 22 Feb 2023 17:04:47 +0100 Subject: [PATCH 05/88] improve node_id detection --- scripts/install | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 232d760..9d075df 100755 --- a/scripts/install +++ b/scripts/install @@ -406,9 +406,8 @@ ynh_script_progression --message="Configuring garage..." --weight=1 garage_command="$final_path/garage -c $final_path/garage.toml" -node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) # sometimes server need some time to start -until [ -n "$node_id" ] ; do +until [ "" = "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do i=$(( i + 1 )) if [ $i -gt 30 ] then From 4c7642802604dc5434f06765542f757a93e4f289 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Wed, 22 Feb 2023 20:55:54 +0100 Subject: [PATCH 06/88] fix wrong weight update --- conf/mount_disk.sh | 3 +++ scripts/config | 29 ++++++++++++++--------------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index e22bdf4..a97bdd4 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -17,5 +17,8 @@ then mkfs.ext4 /dev/nbd$i fi mkdir -p $datadir/data + chown __APP__:__APP__ $datadir/data mount /dev/nbd$i $datadir/data/ fi + + diff --git a/scripts/config b/scripts/config index affce1f..78e042c 100644 --- a/scripts/config +++ b/scripts/config @@ -18,7 +18,7 @@ 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=$(ynh_app_setting_get $app nbd_index) +nbd_index=$(cat $datadir/nbd_index) command="$final_path/garage -c $final_path/garage.toml" get__weight() { @@ -28,26 +28,24 @@ get__weight() { set__weight() { if [ "$virtualisation" = "true" ] then - systemctl stop $YNH_APP_INSTANCE_NAME - old_weight="$ynh_app_setting_get --app=$app --key=weight" - if [ $old_weight -le $weight } + systemctl stop $app + old_weight="$(ynh_app_setting_get --app=$app --key=weight)" + if [ $old_weight -le $weight ] then - $final_path/umount_disk.sh $nbd_index - qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG - qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage.qcow2 - e2fsck -f /dev/nbd$nbd_index + qemu-img resize $datadir/garage_data.qcow2 "$weight"G + qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage_data.qcow2 + e2fsck -f -y /dev/nbd$nbd_index resize2fs /dev/nbd$nbd_index - mount /dev/nbd$nbd_index $datadir/data/ + qemu-nbd --disconnect /dev/nbd$nbd_index else - umount /dev/nbd$nbd_index - e2fsck -f /dev/nbd$nbd_index + e2fsck -f -y /dev/nbd0 resize2fs /dev/nbd$nbd_index $weightG qemu-nbd --disconnect /dev/nbd$nbd_index - qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG - $nbd_index=$(final_path/mount_disk.sh false) - ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index + qemu-img resize --shrink $datadir/garage_data.qcow2 "$weight"G fi - systemctl start $YNH_APP_INSTANCE_NAME + $final_path/umount_disk.sh + systemctl start $app + sleep 3 fi $command layout assign $node_id -c $weight 2>/dev/null apply_layout "$command" @@ -55,6 +53,7 @@ set__weight() { } + get__bootstrap_peers() { ynh_app_setting_get --app=$app --key=bootstrap_peers } From 1f9f8ca267185d353f76fbb37cb46e219af8222b Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Thu, 23 Feb 2023 10:18:43 +0100 Subject: [PATCH 07/88] update version and doc --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index e1a3acd..b6939f7 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "S3 storage", "fr": "stockage S3" }, - "version": "0.8.0~ynh2", + "version": "0.8.0~ynh3", "url": "https://garagehq.deuxfleurs.fr/", "upstream": { "license": "AGPL-3.0-only", From beafedeba49237bb01d50e72f51b84e29dc5a0ea Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Thu, 23 Feb 2023 09:18:56 +0000 Subject: [PATCH 08/88] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index df41a66..6ac9388 100644 --- a/README.md +++ b/README.md @@ -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~ynh2 +**Shipped version:** 0.8.0~ynh3 ## Disclaimers / important information * Limitations : diff --git a/README_fr.md b/README_fr.md index 31dc3fe..12b1d17 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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~ynh2 +**Version incluse :** 0.8.0~ynh3 ## Avertissements / informations importantes * Limitations : From e433985ca617bbb05d1c31d32a5a0130861830e6 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Fri, 24 Feb 2023 11:00:56 +0100 Subject: [PATCH 09/88] remove unused ip value fix i not defined --- doc/DISCLAIMER.md | 1 + scripts/_common.sh | 3 --- scripts/install | 5 +---- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index 822ccb4..b495b5b 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -1,5 +1,6 @@ * Limitations : * This application is not usable if you're not part of a cluster with minimun 3 other nodes + * If you are behind a nat and use upnp to configure your port redirection, you may need to add peers via config panel instead of during installation and/or create a permanent redirection in your router/box * infos you should be aware of: * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. diff --git a/scripts/_common.sh b/scripts/_common.sh index 3e0c238..bc68cc1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -12,9 +12,6 @@ pkg_dependencies_virtualisation="qemu-utils e2fsprogs" GARAGE_VERSION="0.8.0" -get_ip() { - curl ip.me -} # inspired by restic helper install_garage () { architecture=$(uname -m) diff --git a/scripts/install b/scripts/install index 9d075df..52b1c14 100755 --- a/scripts/install +++ b/scripts/install @@ -24,10 +24,6 @@ ynh_abort_if_errors # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -#port mandatory for garage -ip=$(get_ip) - - domain=$YNH_APP_ARG_DOMAIN rpc_secret=$YNH_APP_ARG_RPC_SECRET bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS @@ -406,6 +402,7 @@ ynh_script_progression --message="Configuring garage..." --weight=1 garage_command="$final_path/garage -c $final_path/garage.toml" +i=0 # sometimes server need some time to start until [ "" = "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do i=$(( i + 1 )) From 4e175088b8b84ee75b0b444de95d5f58576bb0fd Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Fri, 24 Feb 2023 12:32:03 +0100 Subject: [PATCH 10/88] fix script --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 52b1c14..0d5bd16 100755 --- a/scripts/install +++ b/scripts/install @@ -404,15 +404,15 @@ garage_command="$final_path/garage -c $final_path/garage.toml" i=0 # sometimes server need some time to start -until [ "" = "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do +until [ "" != "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do i=$(( i + 1 )) if [ $i -gt 30 ] then ynh_die --message="unable to get node id" fi sleep 1 - node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) done +node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) ynh_app_setting_set --app=$app --key=node_id --value=$node_id From 1a7800facf28ae34e6314994a20279f6c70a55f7 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Fri, 3 Mar 2023 15:00:42 +0100 Subject: [PATCH 11/88] - 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 From d54595c39ac2b5fc65ab27f811740058ff82d6ec Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Fri, 3 Mar 2023 14:03:03 +0000 Subject: [PATCH 12/88] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9abfb9..6f37d60 100644 --- a/README.md +++ b/README.md @@ -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..ce8982e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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 : From 571439b31ba7f05dc55aab401fb1dc4fb90392d2 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Fri, 17 Mar 2023 09:57:02 +0100 Subject: [PATCH 13/88] change hook mechanism --- hooks/conf_regen | 16 ---------------- scripts/backup | 9 +++++++++ scripts/install | 21 +++++++++++++-------- scripts/remove | 8 ++++++++ scripts/restore | 6 +++++- sources/hooks/conf_regen/98-nginx_garage | 12 ++++++++++++ 6 files changed, 47 insertions(+), 25 deletions(-) delete mode 100644 hooks/conf_regen create mode 100644 sources/hooks/conf_regen/98-nginx_garage diff --git a/hooks/conf_regen b/hooks/conf_regen deleted file mode 100644 index d49fbaf..0000000 --- a/hooks/conf_regen +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -source /usr/share/yunohost/helpers - -garage_domains=$(yunohost app list --json | jq '.apps[] | select(.id | test("garage*")) | .domain_path') - -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 - 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/install b/scripts/install index cb5e194..53a2c5b 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,19 @@ 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" + + + #================================================= # 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/sources/hooks/conf_regen/98-nginx_garage b/sources/hooks/conf_regen/98-nginx_garage new file mode 100644 index 0000000..a974512 --- /dev/null +++ b/sources/hooks/conf_regen/98-nginx_garage @@ -0,0 +1,12 @@ +#!/bin/bash + +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" From 6b57667847fd4601b7d4f12248dd9264d110c276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 29 Mar 2023 11:05:33 +0200 Subject: [PATCH 14/88] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 0f70130..5a4a680 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "name": "garage_ynh", + "name": "Garage", "id": "garage", "packaging_format": 1, "description": { From 8db3d0cafb5bcd8f51df8a206b12787b9aa735ec Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Wed, 29 Mar 2023 09:05:39 +0000 Subject: [PATCH 15/88] Auto-update README --- README.md | 6 +++--- README_fr.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6f37d60..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 diff --git a/README_fr.md b/README_fr.md index ce8982e..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 From 7bbf99514ce4f3aa6adb6096d9b6dad506125c40 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 11 Apr 2023 15:53:58 +0200 Subject: [PATCH 16/88] add regen conf --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 53a2c5b..491d206 100755 --- a/scripts/install +++ b/scripts/install @@ -295,6 +295,7 @@ ynh_script_progression --message="adding regen-conf hook..." --weight=1 ynh_systemd_action --service_name=nginx --action="reload" +yunohost tools regen-conf nginx #================================================= From 4b89c48616809c9862cf1ca87edaf802f78a0851 Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 23 Jul 2023 20:51:12 +0200 Subject: [PATCH 17/88] v0.8.2 (#10) * v0.8.2 https://git.deuxfleurs.fr/Deuxfleurs/garage/releases/tag/v0.8.2 --- manifest.json | 2 +- scripts/_common.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index 5a4a680..78d9510 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "S3 storage", "fr": "stockage S3" }, - "version": "0.8.0~ynh4", + "version": "0.8.2~ynh1", "url": "https://garagehq.deuxfleurs.fr/", "upstream": { "license": "AGPL-3.0-only", diff --git a/scripts/_common.sh b/scripts/_common.sh index bc68cc1..494a560 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,7 +10,7 @@ pkg_dependencies_virtualisation="qemu-utils e2fsprogs" #================================================= -GARAGE_VERSION="0.8.0" +GARAGE_VERSION="0.8.2" # inspired by restic helper install_garage () { From 985d05affbf1c8125602bc0d2a488665a3f9274d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 23 Jul 2023 18:51:16 +0000 Subject: [PATCH 18/88] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3d2a23c..fefc08c 100644 --- a/README.md +++ b/README.md @@ -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~ynh4 +**Shipped version:** 0.8.2~ynh1 ## Disclaimers / important information * Limitations : diff --git a/README_fr.md b/README_fr.md index b4515aa..0607b67 100644 --- a/README_fr.md +++ b/README_fr.md @@ -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~ynh4 +**Version incluse :** 0.8.2~ynh1 ## Avertissements / informations importantes * Limitations : From 87b89e1d99439f528ae8627235927528087c5e68 Mon Sep 17 00:00:00 2001 From: lapineige Date: Sun, 23 Jul 2023 21:07:49 +0200 Subject: [PATCH 19/88] Explain how to use the command line (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * v2 * Explain how to use the command line Require packaging v2, I will not do it for v1 as it's more complex and not that useful. --------- Co-authored-by: Éric Gaspar <46165813+ericgaspar@users.noreply.github.com> Co-authored-by: oiseauroch <5622590+oiseauroch@users.noreply.github.com> --- conf/garage.toml | 4 +- conf/mount_disk.sh | 12 +- conf/nginx.conf | 6 +- conf/systemd.service | 10 +- conf/umount_disk.sh | 4 +- config_panel.toml | 2 - doc/DISCLAIMER.md | 4 + manifest.toml | 83 ++++++++++++++ scripts/backup | 35 +----- scripts/change_url | 95 +--------------- scripts/install | 265 +++---------------------------------------- scripts/remove | 47 +------- scripts/restore | 75 ++---------- scripts/upgrade | 104 +---------------- 14 files changed, 143 insertions(+), 603 deletions(-) create mode 100644 manifest.toml diff --git a/conf/garage.toml b/conf/garage.toml index 4c6798d..9d84248 100644 --- a/conf/garage.toml +++ b/conf/garage.toml @@ -1,5 +1,5 @@ -metadata_dir = "/opt/yunohost/__APP__/metadata" -data_dir = "__DATADIR__/data" +metadata_dir = "__DATA_DIR__/metadata" +data_dir = "__DATA_DIR__/data" block_size = 1048576 block_manager_background_tranquility = 2 diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index a97bdd4..c42ae46 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -1,24 +1,24 @@ #!/bin/bash if [ "$VIRTUALISATION" = "true" ] then - datadir=__DATADIR__ + data_dir=__DATA_DIR__ format=$1 i=0 while fdisk -l /dev/nbd$i 1> /dev/null 2> /dev/null do i=$(( i + 1 )) done - echo $i > $datadir/nbd_index + echo $i > $data_dir/nbd_index modprobe nbd max_part=$(( i + 1 )) - qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2 + qemu-nbd --connect /dev/nbd$i $data_dir/garage_data.qcow2 if [[ "$format" = "true" ]] then echo "formatting /dev/nbd$i" mkfs.ext4 /dev/nbd$i fi - mkdir -p $datadir/data - chown __APP__:__APP__ $datadir/data - mount /dev/nbd$i $datadir/data/ + mkdir -p $data_dir/data + chown __APP__:__APP__ $data_dir/data + mount /dev/nbd$i $data_dir/data/ fi diff --git a/conf/nginx.conf b/conf/nginx.conf index c69565e..270f18a 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,5 +1,7 @@ -location / { - proxy_pass http://localhost:__PORT_API__; +#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent; +location __PATH__/ { + + proxy_pass http://127.0.0.1:__PORT_API__; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; } diff --git a/conf/systemd.service b/conf/systemd.service index e170983..0e2106c 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -1,15 +1,15 @@ [Unit] -Description=Garage Data Store +Description=Garage: Data Store After=network-online.target Wants=network-online.target [Service] User=__APP__ Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1' -ExecStartPre=+__FINALPATH__/mount_disk.sh -ExecStart=__FINALPATH__/garage -c __FINALPATH__/garage.toml server -ExecStopPost=+__FINALPATH__/umount_disk.sh -WorkingDirectory=__FINALPATH__/ +ExecStartPre=+__INSTALL_DIR__/mount_disk.sh +ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server +ExecStopPost=+__INSTALL_DIR__/umount_disk.sh +WorkingDirectory=__INSTALL_DIR__/ StandardOutput=append:/var/log/__APP__/__APP__.log StandardError=inherit diff --git a/conf/umount_disk.sh b/conf/umount_disk.sh index c5a69ce..7222ef0 100755 --- a/conf/umount_disk.sh +++ b/conf/umount_disk.sh @@ -1,8 +1,8 @@ #!/bin/bash if [ "$VIRTUALISATION" = "true" ] then - datadir=__DATADIR__ - nbd=$(cat $datadir/nbd_index) + data_dir=__DATA_DIR__ + nbd=$(cat $data_dir/nbd_index) umount /dev/nbd$nbd qemu-nbd --disconnect /dev/nbd$nbd fi diff --git a/config_panel.toml b/config_panel.toml index 882eb1d..9375c6b 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -12,11 +12,9 @@ version = "1.0" [main.infos.status] type = "alert" - [main.garage_conf] name = "Garage configuration" - [main.garage_conf.weight] ask = "allocated space (Gio)" help = "This value is doubled used by yunohost. It set the weight of the garage node and if virtualisation is enabled, it create a virtual disk with the same size" diff --git a/doc/DISCLAIMER.md b/doc/DISCLAIMER.md index b495b5b..152ab53 100644 --- a/doc/DISCLAIMER.md +++ b/doc/DISCLAIMER.md @@ -6,3 +6,7 @@ * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. * This application consider that the weight of the node is the size reserved to garage in G * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. + +# How to run commands for Garage +1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. +2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. diff --git a/manifest.toml b/manifest.toml new file mode 100644 index 0000000..8607767 --- /dev/null +++ b/manifest.toml @@ -0,0 +1,83 @@ +packaging_format = 2 + +id = "garage" +name = "Garage" +description.en = "S3 storage" +description.fr = "stockage S3" + +version = "0.8.2~ynh1" + +maintainers = ["oiseauroch"] + +[upstream] +license = "AGPL-3.0-only" +website = "https://garagehq.deuxfleurs.fr/" +admindoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/" +userdoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/" +code = "https://git.deuxfleurs.fr/Deuxfleurs/garage" + +[integration] +yunohost = ">= 1.1.18" +architectures = "all" +multi_instance = true +ldap = false +sso = false +disk = "50M" +ram.build = "50M" +ram.runtime = "50M" + +[install] + [install.domain] + type = "domain" + full_domain = true + + [install.rpc_secret] + ask.en = "UUID of the network (rpc-secret) " + ask.fr = "UUID de l'ilot (rpc-secret)" + type = "string" + optional = true + example = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec" + + [install.bootstrap_peers] + ask.en = "friend server id" + ask.fr = "serveur ami" + type = "string" + example = "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@127.0.0.1:3901" + optional = true + + [install.weight] + ask.en = "number of G to allow" + ask.fr = "nombre de G à allouer" + type = "string" + +[resources] + + [resources.sources] + + [resources.sources.main] + in_subdir = false + amd64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage" + amd64.sha256 = "c15aa223b0fffb856c6e16276d1e77b0e94eb783a26eaeb7de80324f7c8b23c5" + arm64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/aarch64-unknown-linux-musl/garage" + amd64.sha256 = "9c419d47e87ac254a96cda6476e3c5c9102a9a2ea1ec1dc65d338bb46e415d78" + i386.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/i686-unknown-linux-musl/garage" + i386.sha256 = "a733fcd9b0a0f6271960f0d65978b8a8474317fa41325595aa4825764b71f089" + armhf.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/armv6l-unknown-linux-musleabihf/garage" + armhf.sha256 = "1eb79aa8fff6c00bd1dd5da53dedd04685fe28b3402476a3b10b1b66aa10f80a" + + [resources.ports] + main.default = 4000 + main.exposed = "TCP" + api.default = 5000 + + [resources.system_user] + + [resources.install_dir] + + [resources.data_dir] + + [resources.permissions] + main.url = "/" + + [resources.apt] + packages = "qemu-utils e2fsprogs" diff --git a/scripts/backup b/scripts/backup index 049b7d3..3f1e253 100755 --- a/scripts/backup +++ b/scripts/backup @@ -10,33 +10,6 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_print_info --message="Loading installation settings..." - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret) -port_api=$(ynh_app_setting_get --app=$app --key=port_api) -port_web=$(ynh_app_setting_get --app=$app --key=port_web) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers) - -final_path=/opt/yunohost/$app #================================================= # DECLARE DATA AND CONF FILES TO BACKUP #================================================= @@ -51,13 +24,7 @@ ynh_print_info --message="Declaring files to be backed up..." # BACKUP THE APP MAIN DIR #================================================= -ynh_backup --src_path="$final_path" - -#================================================= -# BACKUP THE DATA DIR -#================================================= - -#ynh_backup --src_path="$datadir/data" --is_big +ynh_backup --src_path="$install_dir" #================================================= # BACKUP THE NGINX CONFIGURATION diff --git a/scripts/change_url b/scripts/change_url index 495b7eb..f5ff536 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -9,64 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# RETRIEVE ARGUMENTS -#================================================= - -old_domain=$YNH_APP_OLD_DOMAIN -old_path=$YNH_APP_OLD_PATH - -new_domain=$YNH_APP_NEW_DOMAIN -new_path=$YNH_APP_NEW_PATH - -app=$YNH_APP_INSTANCE_NAME - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --time --weight=1 - -# Needed for helper "ynh_add_nginx_config" -final_path=$(ynh_app_setting_get --app=$app --key=final_path) - -# Add settings here as needed by your application -#db_name=$(ynh_app_setting_get --app=$app --key=db_name) -#db_user=$db_name -#db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) - -#================================================= -# BACKUP BEFORE CHANGE URL THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before changing its URL (may take a while)..." --time --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Remove the new domain config file, the remove script won't do it as it doesn't know yet its location. - ynh_secure_remove --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" - - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# CHECK WHICH PARTS SHOULD BE CHANGED -#================================================= - -change_domain=0 -if [ "$old_domain" != "$new_domain" ] -then - change_domain=1 -fi - -change_path=0 -if [ "$old_path" != "$new_path" ] -then - change_path=1 -fi - #================================================= # STANDARD MODIFICATIONS #================================================= @@ -81,35 +23,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 -nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf - -# Change the path in the NGINX config file -if [ $change_path -eq 1 ] -then - # Make a backup of the original NGINX config file if modified - ynh_backup_if_checksum_is_different --file="$nginx_conf_path" - # Set global variables for NGINX helper - domain="$old_domain" - path_url="$new_path" - # Create a dedicated NGINX config - ynh_add_nginx_config -fi - -# Change the domain for NGINX -if [ $change_domain -eq 1 ] -then - # Delete file checksum for the old conf file location - ynh_delete_file_checksum --file="$nginx_conf_path" - mv $nginx_conf_path /etc/nginx/conf.d/$new_domain.d/$app.conf - # Store file checksum for the new config file location - ynh_store_file_checksum --file="/etc/nginx/conf.d/$new_domain.d/$app.conf" -fi - -#================================================= -# SPECIFIC MODIFICATIONS -#================================================= -# ... -#================================================= +ynh_change_url_nginx_config #================================================= # GENERIC FINALISATION @@ -120,13 +34,6 @@ ynh_script_progression --message="Starting a systemd service..." --time --weight ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --time --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/install b/scripts/install index 491d206..2151322 100755 --- a/scripts/install +++ b/scripts/install @@ -9,57 +9,9 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - ### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# RETRIEVE ARGUMENTS FROM THE MANIFEST -#================================================= - -domain=$YNH_APP_ARG_DOMAIN -rpc_secret=$YNH_APP_ARG_RPC_SECRET -bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS -datadir=$YNH_APP_ARG_DATADIR -weight=$YNH_APP_ARG_WEIGHT - - -### If it's a multi-instance app, meaning it can be installed several times independently -### The id of the app as stated in the manifest is available as $YNH_APP_ID -### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2"...) -### The app instance name is available as $YNH_APP_INSTANCE_NAME -### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample -### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2 -### - ynhexample__{N} for the subsequent installations, with N=3,4... -### The app instance name is probably what interests you most, since this is -### guaranteed to be unique. This is a good unique identifier to define installation path, -### db names... -app=$YNH_APP_INSTANCE_NAME - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -### About --weight and -### ynh_script_progression will show to your final users the progression of each scripts. -### In order to do that, --weight will represent the relative time of execution compared to the other steps in the script. -### is a packager option, it will show you the execution time since the previous call. -### This option should be removed before releasing your app. -### Use the execution time, given by , to estimate the weight of a step. -### A common way to do it is to set a weight equal to the execution time in second +1. -### The execution time is given for the duration since the previous call. So the weight should be applied to this previous call. -ynh_script_progression --message="Validating installation parameters..." --weight=1 - -### If the app uses NGINX as web server (written in HTML/PHP in most cases), the final path should be "/var/www/$app". -### If the app provides an internal web server (or uses another application server such as uWSGI), the final path should be "/opt/yunohost/$app" -final_path=/opt/yunohost/$app -test ! -e "$final_path" || ynh_die --message="This path already contains a folder" if [[ -n "$rpc_secret" ]] then @@ -72,14 +24,6 @@ then echo "$bootstrap_peers" | grep -E '[0-9a-f]{64}@((\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}):[0-9]{1,4}' || ynh_die --message="friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:1234 or 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@example.tld:1234" fi -if [ "$datadir" = "/home/yunohost.app/__APP_NAME__/data" ] -then - datadir="/home/yunohost.app/$app/data" -fi - -# Register (book) web path -ynh_webpath_register --app=$app --domain=$domain --path_url="/" - #================================================= # LOOKING FOR VIRTUALISATION #================================================= @@ -104,159 +48,61 @@ ynh_app_setting_set --app=$app --key=virtualisation --value=$virtualisation #================================================= ynh_script_progression --message="Storing installation settings..." --weight=1 -ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret -ynh_app_setting_set --app=$app --key=datadir --value=$datadir ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers ynh_app_setting_set --app=$app --key=weight --value=$weight - -#================================================= -# STANDARD MODIFICATIONS -#================================================= -# FIND AND OPEN A PORT -#================================================= -ynh_script_progression --message="Finding available ports..." --weight=1 - -### Use these lines if you have to open a port for the application -### `ynh_find_port` will find the first available port starting from the given port. -### If you're not using these lines: -### - Remove the section "CLOSE A PORT" in the remove script - -# Find an available port - -port=$(ynh_find_port --port=4000) -ynh_app_setting_set --app=$app --key=port --value=$port -port_api=$(ynh_find_port --port=5000) -ynh_app_setting_set --app=$app --key=port_api --value=$port_api - - -# Optional: Expose this port publicly -# (N.B.: you only need to do this if the app actually needs to expose the port publicly. -# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !) - -# Open the port - ynh_script_progression --message="Configuring firewall..." --weight=1 - ynh_exec_warn_less yunohost firewall allow TCP $port - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=1 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script if [ "$virtualisation" = "true" ] then ynh_install_app_dependencies $pkg_dependencies_virtualisation fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." --weight=1 - -# Create a system user -ynh_system_user_create --username=$app --home_dir="$final_path" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -### `ynh_setup_source` is used to install an app from a zip or tar.gz file, -### downloaded from an upstream source, like a git repository. -### `ynh_setup_source` use the file conf/app.src - -mkdir -p $final_path -ynh_app_setting_set --app=$app --key=final_path --value=$final_path - -# Download, check integrity, uncompress and patch the source from app.src -pushd $final_path - install_garage -popd - -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +ynh_setup_source --dest_dir="$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" +chmod +x $install_dir/garage #================================================= # NGINX CONFIGURATION #================================================= ynh_script_progression --message="Configuring NGINX web server..." --weight=1 -### `ynh_add_nginx_config` will use the file conf/nginx.conf - # Create a dedicated NGINX config ynh_add_nginx_config - #================================================= # ADD A CONFIGURATION #================================================= ynh_script_progression --message="Adding a configuration file..." --weight=1 -### You can add specific configuration files. -### -### Typically, put your template conf file in ../conf/your_config_file -### The template may contain strings such as __FOO__ or __FOO_BAR__, -### which will automatically be replaced by the values of $foo and $foo_bar -### -### ynh_add_config will also keep track of the config file's checksum, -### which later during upgrade may allow to automatically backup the config file -### if it's found that the file was manually modified -### -### Check the documentation of `ynh_add_config` for more info. - - ynh_add_config --template="mount_disk.sh" --destination="$final_path/mount_disk.sh" - ynh_add_config --template="umount_disk.sh" --destination="$final_path/umount_disk.sh" - ynh_add_config --template="garage.toml" --destination="$final_path/garage.toml" - chmod +x "$final_path/mount_disk.sh" "$final_path/umount_disk.sh" - -# FIXME: this should be handled by the core in the future -# You may need to use chmod 600 instead of 400, -# for example if the app is expected to be able to modify its own config -chmod 600 "$final_path/garage.toml" -chown $app:$app "$final_path/garage.toml" - -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" +ynh_add_config --template="mount_disk.sh" --destination="$install_dir/mount_disk.sh" +ynh_add_config --template="umount_disk.sh" --destination="$install_dir/umount_disk.sh" +ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" +chmod +x "$install_dir/mount_disk.sh" "$install_dir/umount_disk.sh" +chmod 600 "$install_dir/garage.toml" +chown $app:$app "$install_dir/garage.toml" #================================================= # CREATE DATA DIRECTORY #================================================= ynh_script_progression --message="Creating a data directory..." --weight=5 + if [ "$virtualisation" = "true" ] then ynh_print_warn --message="This may take time regarding disk size…" fi -### Use these lines if you need to create a directory to store "persistent files" for the application. -### Usually this directory is used to store uploaded files or any file that won't be updated during -### an upgrade and that won't be deleted during app removal unless "--purge" option is used. -### If you're not using these lines: -### - Remove the section "BACKUP THE DATA DIR" in the backup script -### - Remove the section "RESTORE THE DATA DIRECTORY" in the restore script -### - As well as the section "REMOVE DATA DIR" in the remove script - -ynh_app_setting_set --app=$app --key=datadir --value=$datadir - -mkdir -p $datadir/data #================================================= # create data partition @@ -265,23 +111,14 @@ mkdir -p $datadir/data if [ "$virtualisation" = "true" ] then # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. - qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G - VIRTUALISATION=true $final_path/mount_disk.sh true + qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G + VIRTUALISATION=true $install_dir/mount_disk.sh true fi -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:$app "$datadir" if [ "$virtualisation" = "true" ] then - VIRTUALISATION=true $final_path/umount_disk.sh + VIRTUALISATION=true $install_dir/umount_disk.sh fi #================================================= @@ -292,28 +129,15 @@ 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 #================================================= ynh_script_progression --message="Configuring a systemd service..." --weight=1 -### `ynh_systemd_config` is used to configure a systemd script for an app. -### It can be used for apps that use sysvinit (with adaptation) or systemd. -### Have a look at the app to be sure this app needs a systemd script. -### `ynh_systemd_config` will use the file conf/systemd.service -### If you're not using these lines: -### - You can remove those files in conf/. -### - Remove the section "BACKUP SYSTEMD" in the backup script -### - Remove also the section "STOP AND REMOVE SERVICE" in the remove script -### - As well as the section "RESTORE SYSTEMD" in the restore script -### - And the section "SETUP SYSTEMD" in the upgrade script - # Create a dedicated systemd config ynh_add_systemd_config @@ -324,14 +148,6 @@ ynh_add_systemd_config #================================================= ynh_script_progression --message="Configuring log rotation..." --weight=1 -### `ynh_use_logrotate` is used to configure a logrotate configuration for the logs of this app. -### Use this helper only if there is effectively a log file for this app. -### If you're not using this helper: -### - Remove the section "BACKUP LOGROTATE" in the backup script -### - Remove also the section "REMOVE LOGROTATE CONFIGURATION" in the remove script -### - As well as the section "RESTORE THE LOGROTATE CONFIGURATION" in the restore script -### - And the section "SETUP LOGROTATE" in the upgrade script - # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -340,73 +156,22 @@ ynh_use_logrotate #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 -### `yunohost service add` integrates a service in YunoHost. It then gets -### displayed in the admin interface and through the others `yunohost service` commands. -### (N.B.: this line only makes sense if the app adds a service to the system!) -### If you're not using these lines: -### - You can remove these files in conf/. -### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script -### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script -### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script - yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app -### Additional options starting with 3.8: -### -### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed -### which will then be checked by YunoHost's diagnosis system -### (N.B. DO NOT USE THIS is the port is only internal!!!) -### -### --test_status "some command" a custom command to check the status of the service -### (only relevant if 'systemctl status' doesn't do a good job) -### -### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service -### -### Re-calling 'yunohost service add' during the upgrade script is the right way -### to proceed if you later realize that you need to enable some flags that -### weren't enabled on old installs (be careful it'll override the existing -### service though so you should re-provide all relevant flags when doing so) - - #================================================= # START SYSTEMD SERVICE #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -### `ynh_systemd_action` is used to start a systemd service for an app. -### Only needed if you have configure a systemd service -### If you're not using these lines: -### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script -### - As well as the section "START SYSTEMD SERVICE" in the restore script -### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script -### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script - # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# SETUP SSOWAT -#================================================= -ynh_script_progression --message="Configuring permissions..." --weight=1 - - # Everyone can access the app. - # The "main" permission is automatically created before the install script. - ynh_permission_update --permission="main" --add="visitors" - -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - - #================================================= # CONFIGURE GARAGE #================================================= ynh_script_progression --message="Configuring garage..." --weight=1 -garage_command="$final_path/garage -c $final_path/garage.toml" +garage_command="$install_dir/garage -c $install_dir/garage.toml" i=0 # sometimes server need some time to start diff --git a/scripts/remove b/scripts/remove index 1e46c73..0c1407f 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,30 +12,18 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret) -port_api=$(ynh_app_setting_get --app=$app --key=port_api) -port_web=$(ynh_app_setting_get --app=$app --key=port_web) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers) -node_id=$(ynh_app_setting_get --app=$app --key=node_id) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation) if [ "$virtualisation" = "true" ] then export VIRTUALISTATION=true fi + #================================================= # REMOVE NODE CONFIGURATION #================================================= -$final_path/garage -c $final_path/garage.toml layout remove "$node_id" +$install_dir/garage -c $install_dir/garage.toml layout remove "$node_id" -apply_layout "$final_path/garage -c $final_path/garage.toml " +apply_layout "$install_dir/garage -c $install_dir/garage.toml " if [ $? -ne 0 ] then ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough" @@ -80,21 +68,8 @@ then ynh_script_progression --message="umount virtual disk..." --weight=1 # Remove the app directory securely - $final_path/umount_disk.sh + $install_dir/umount_disk.sh fi -#================================================= -# REMOVE APP MAIN DIR -#================================================= -ynh_script_progression --message="Removing app main directory..." --weight=1 - -# Remove the app directory securely -ynh_secure_remove --file="$final_path" - -#================================================= -# REMOVE DATA DIR -#================================================= -ynh_script_progression --message="Removing app data directory..." --weight=1 -ynh_secure_remove --file="$datadir" #================================================= # REMOVE NGINX HOOK @@ -112,13 +87,6 @@ ynh_remove_nginx_config ynh_replace_string --replace_string="server_name $domain" --match_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" -#================================================= -# REMOVE DEPENDENCIES -#================================================= -ynh_script_progression --message="Removing dependencies..." --weight=1 - -# Remove metapackage and its dependencies -ynh_remove_app_dependencies #================================================= # CLOSE A PORT @@ -130,7 +98,6 @@ then ynh_exec_warn_less yunohost firewall disallow TCP $port fi - #================================================= # SPECIFIC REMOVE #================================================= @@ -144,12 +111,6 @@ ynh_secure_remove --file="/var/log/$app" #================================================= # GENERIC FINALIZATION #================================================= -# REMOVE DEDICATED USER -#================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=1 - -# 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 diff --git a/scripts/restore b/scripts/restore index 70607ab..809871e 100755 --- a/scripts/restore +++ b/scripts/restore @@ -10,74 +10,23 @@ source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers -#================================================= -# MANAGE SCRIPT FAILURE -#================================================= - -ynh_clean_setup () { - #### Remove this function if there's nothing to clean before calling the remove script. - true -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation) -bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers) -port=$(ynh_app_setting_get --app=$app --key=port) -node_id=$(ynh_app_setting_get --app=$app --key=node_id) -weight=$(ynh_app_setting_get --app=$app --key=weight) - -#================================================= -# CHECK IF THE APP CAN BE RESTORED -#================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=1 - -test ! -d $final_path \ - || ynh_die --message="There is already a directory: $final_path " - -#================================================= -# STANDARD RESTORATION STEPS -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=1 - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # RESTORE THE APP MAIN DIR #================================================= ynh_script_progression --message="Restoring the app main directory..." --weight=1 -ynh_restore_file --origin_path="$final_path" +ynh_restore_file --origin_path="$install_dir" -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= ynh_script_progression --message="Restoring the data directory..." --weight=1 -mkdir -p "$datadir/data" +mkdir -p "$data_dir/data" if [ "$virtualisation" = "true" ] then @@ -85,8 +34,8 @@ then # Define and install dependencies ynh_install_app_dependencies $pkg_dependencies_virtualisation # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. - qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G - $final_path/mount_disk.sh true + qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G + $install_dir/mount_disk.sh true fi @@ -96,9 +45,9 @@ fi # files in some cases. # But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - # this will be treated as a security issue. -chmod 750 "$datadir" -chmod -R o-rwx "$datadir" -chown -R $app:$app "$datadir" +chmod 750 "$data_dir" +chmod -R o-rwx "$data_dir" +chown -R $app:$app "$data_dir" #================================================= # SPECIFIC RESTORATION @@ -116,12 +65,10 @@ 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_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" - #================================================= # RESTORE SYSTEMD #================================================= @@ -159,7 +106,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap sleep 2 -garage_command="$final_path/garage -c $final_path/garage.toml" +garage_command="$install_dir/garage -c $install_dir/garage.toml" # define node $garage_command layout assign $node_id -z $domain -c $weight -t $domain diff --git a/scripts/upgrade b/scripts/upgrade index 20c7b2a..663ee9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,22 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= -ynh_script_progression --message="Loading installation settings..." --weight=1 - -app=$YNH_APP_INSTANCE_NAME - -domain=$(ynh_app_setting_get --app=$app --key=domain) -port=$(ynh_app_setting_get --app=$app --key=port) -rpc_secret=$(ynh_app_setting_get --app=$app --key=rpc_secret) -port_api=$(ynh_app_setting_get --app=$app --key=port_api) -port_web=$(ynh_app_setting_get --app=$app --key=port_web) -datadir=$(ynh_app_setting_get --app=$app --key=datadir) -bootstrap_peers=$(ynh_app_setting_get --app=$app --key=bootstrap_peers) -final_path=$(ynh_app_setting_get --app=$app --key=final_path) -virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation) if [ "$virtualisation" = "true" ] ; then @@ -32,32 +16,13 @@ then else virt_protection="#" fi + #================================================= # CHECK VERSION #================================================= -### This helper will compare the version of the currently installed app and the version of the upstream package. -### $upgrade_type can have 2 different values -### - UPGRADE_APP if the upstream app version has changed -### - UPGRADE_PACKAGE if only the YunoHost package has changed -### ynh_check_app_version_changed will stop the upgrade if the app is up to date. -### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do. upgrade_type=$(ynh_check_app_version_changed) -#================================================= -# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP -#================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=1 - -# Backup the current version of the app -ynh_backup_before_upgrade -ynh_clean_setup () { - # Restore it if the upgrade fails - ynh_restore_upgradebackup -} -# Exit if an error occurs during the execution of the script -ynh_abort_if_errors - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -67,42 +32,16 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -#================================================= -# ENSURE DOWNWARD COMPATIBILITY -#================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 - - -# Create a permission if needed -if ! ynh_permission_exists --permission="api"; then - ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --show_tile="false" --protected="true" -fi - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_script_progression --message="Installing dependencies..." --weight=1 -### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package. -### Those deb packages will be installed as dependencies of this package. -### If you're not using this helper: -### - Remove the section "REMOVE DEPENDENCIES" in the remove script -### - Remove the variable "pkg_dependencies" in _common.sh -### - As well as the section "REINSTALL DEPENDENCIES" in the restore script -### - And the section "UPGRADE DEPENDENCIES" in the upgrade script if [ "$virtualisation" = "true" ] then ynh_install_app_dependencies $pkg_dependencies_virtualisation fi -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1 - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir="$final_path" - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -112,21 +51,14 @@ then ynh_script_progression --message="Upgrading source files..." --weight=1 # Download, check integrity, uncompress and patch the source from app.src - pushd $final_path + pushd $install_dir install_garage popd fi -# FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$final_path" -chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" - +chmod 750 "$install_dir" +chmod -R o-rwx "$install_dir" +chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION @@ -136,25 +68,6 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config -#================================================= -# SPECIFIC UPGRADE -#================================================= -# ... -#================================================= - -#================================================= -# UPDATE A CONFIG FILE -#================================================= -ynh_script_progression --message="Updating a configuration file..." --weight=1 - - -### For more complex cases where you want to replace stuff using regexes, -### you shoud rely on ynh_replace_string (which is basically a wrapper for sed) -### When doing so, you also need to manually call ynh_store_file_checksum -### -### ynh_replace_string --match_string="match_string" --replace_string="replace_string" --target_file="$final_path/some_config_file" -### ynh_store_file_checksum --file="$final_path/some_config_file" - #================================================= # SETUP SYSTEMD #================================================= @@ -187,13 +100,6 @@ ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" -#================================================= -# RELOAD NGINX -#================================================= -ynh_script_progression --message="Reloading NGINX web server..." --weight=1 - -ynh_systemd_action --service_name=nginx --action=reload - #================================================= # END OF SCRIPT #================================================= From d3f251fd8339f4687f1d4fb179784a81c07bed57 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 23 Jul 2023 19:07:53 +0000 Subject: [PATCH 20/88] Auto-update README --- README.md | 4 ++++ README_fr.md | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index fefc08c..f178ee2 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,10 @@ Garage is designed for storage clusters composed of nodes running at different p * This application consider that the weight of the node is the size reserved to garage in G * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. +# How to run commands for Garage +1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. +2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. + ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index 0607b67..e243ef7 100644 --- a/README_fr.md +++ b/README_fr.md @@ -47,6 +47,10 @@ Garage is designed for storage clusters composed of nodes running at different p * This application consider that the weight of the node is the size reserved to garage in G * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. +# How to run commands for Garage +1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. +2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. + ## Documentations et ressources * Site officiel de l’app : From f11c7b2e9ec0209bab2ba0c4095de664b44c316c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 24 Jul 2023 22:16:42 +0200 Subject: [PATCH 21/88] manifest: typos ... --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index 8607767..443bb48 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,7 +17,7 @@ userdoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/" code = "https://git.deuxfleurs.fr/Deuxfleurs/garage" [integration] -yunohost = ">= 1.1.18" +yunohost = ">= 11.1.18" architectures = "all" multi_instance = true ldap = false @@ -59,7 +59,7 @@ ram.runtime = "50M" amd64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage" amd64.sha256 = "c15aa223b0fffb856c6e16276d1e77b0e94eb783a26eaeb7de80324f7c8b23c5" arm64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/aarch64-unknown-linux-musl/garage" - amd64.sha256 = "9c419d47e87ac254a96cda6476e3c5c9102a9a2ea1ec1dc65d338bb46e415d78" + arm64.sha256 = "9c419d47e87ac254a96cda6476e3c5c9102a9a2ea1ec1dc65d338bb46e415d78" i386.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/i686-unknown-linux-musl/garage" i386.sha256 = "a733fcd9b0a0f6271960f0d65978b8a8474317fa41325595aa4825764b71f089" armhf.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/armv6l-unknown-linux-musleabihf/garage" From 3103ccefab8b19d104d5e98d22a76bea6a17ff00 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 24 Jul 2023 22:20:49 +0200 Subject: [PATCH 22/88] Manifest.json not needed anymore... --- manifest.json | 74 --------------------------------------------------- 1 file changed, 74 deletions(-) delete mode 100644 manifest.json diff --git a/manifest.json b/manifest.json deleted file mode 100644 index 78d9510..0000000 --- a/manifest.json +++ /dev/null @@ -1,74 +0,0 @@ -{ - "name": "Garage", - "id": "garage", - "packaging_format": 1, - "description": { - "en": "S3 storage", - "fr": "stockage S3" - }, - "version": "0.8.2~ynh1", - "url": "https://garagehq.deuxfleurs.fr/", - "upstream": { - "license": "AGPL-3.0-only", - "website": "https://garagehq.deuxfleurs.fr/", - "admindoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/", - "userdoc": "https://garagehq.deuxfleurs.fr/documentation/quick-start/", - "code": "https://git.deuxfleurs.fr/Deuxfleurs/garage" - }, - "services": [], - "license": "AGPL-3.0-only", - "maintainer": { - "name": "oiseauroch", - "email": "tobias.ollive@oiseauroch.fr." - }, - "requirements": { - "yunohost": ">= 4.3.0" - }, - "multi_instance": true, - "arguments": { - "install": [ - { - "name": "domain", - "type": "domain" - }, - { - "name":"rpc_secret", - "type":"string", - "ask": { - "en": "UUID of the network (rpc-secret) ", - "fr": "UUID de l'ilot (rpc-secret)" - }, - "optional": true, - "example": "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec" - }, - { - "name": "bootstrap_peers", - "type": "string", - "example": "1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@127.0.0.1:3901", - "optional": true, - "ask": { - "en": "friend server id", - "fr": "serveur ami" - } - }, - { - "name": "weight", - "type": "string", - "ask": { - "en": "number of G to allow", - "fr": "nombre de G à allouer" - } - }, - { - "name": "datadir", - "type": "string", - "default": "/home/yunohost.app/__APP_NAME__/data", - "exemple": "/opt/yunohost/garage/data", - "ask" : { - "en" : "data location", - "fr": "dossier de stockage des données" - } - } - ] - } -} From 2d606f0a2f34e8d1380fed9760ce5f04889470de Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sun, 30 Jul 2023 14:28:20 +0200 Subject: [PATCH 23/88] use systemd-detect-virt --- scripts/_common.sh | 14 ++++++++++++++ scripts/config | 1 - scripts/install | 19 ------------------- scripts/upgrade | 1 - 4 files changed, 14 insertions(+), 21 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 494a560..ec9aa5c 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,6 +9,20 @@ pkg_dependencies_virtualisation="qemu-utils e2fsprogs" # PERSONAL HELPERS #================================================= +systemd-detect-virt -c -q +if [ $? ] +then #system is inside a container, + export VIRTUALISATION=true + virtualisation=true + # comment systemd isolation to allow mount disk + virt_protection="#" +else + virtualisation=false + export VIRTUALISATION=false + # uncomment systemd isolation + virt_protection="" +fi + GARAGE_VERSION="0.8.2" diff --git a/scripts/config b/scripts/config index dd482d3..a39681c 100644 --- a/scripts/config +++ b/scripts/config @@ -16,7 +16,6 @@ ynh_abort_if_errors 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) if [ "$virtualisation" = "true" ] then diff --git a/scripts/install b/scripts/install index 2151322..99247b2 100755 --- a/scripts/install +++ b/scripts/install @@ -24,25 +24,6 @@ then echo "$bootstrap_peers" | grep -E '[0-9a-f]{64}@((\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}|([a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]\.)+[a-zA-Z]{2,}):[0-9]{1,4}' || ynh_die --message="friend server id must have id with the following form : 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@192.168.1.1:1234 or 1799bccfd7411eddcf9ebd316bc1f5287ad12a68094e1c6ac6abde7e6feae1ec@example.tld:1234" fi -#================================================= -# LOOKING FOR VIRTUALISATION -#================================================= -ynh_script_progression --message="Checking virtualisation availability…" --weight=1 - -if [ "$(which modprobe)" = "" ] -then - virtualisation=false - export VIRTUALISATION=false - # uncomment systemd isolation - virt_protection="" -else - export VIRTUALISATION=true - virtualisation=true - # comment systemd isolation to allow mount disk - virt_protection="#" -fi -ynh_app_setting_set --app=$app --key=virtualisation --value=$virtualisation - #================================================= # STORE SETTINGS FROM MANIFEST #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 663ee9c..bd32ef9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers - if [ "$virtualisation" = "true" ] ; then virt_protection="" From f237ed38ac0fea27c31f3aaffc465d19875d7417 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sun, 30 Jul 2023 14:51:43 +0200 Subject: [PATCH 24/88] change virtualisation helper --- manifest.toml | 6 ++++-- scripts/_common.sh | 26 -------------------------- scripts/install | 13 ------------- scripts/restore | 4 ---- scripts/upgrade | 38 ++++++++++++++------------------------ 5 files changed, 18 insertions(+), 69 deletions(-) diff --git a/manifest.toml b/manifest.toml index 443bb48..fd13edd 100644 --- a/manifest.toml +++ b/manifest.toml @@ -48,7 +48,7 @@ ram.runtime = "50M" [install.weight] ask.en = "number of G to allow" ask.fr = "nombre de G à allouer" - type = "string" + type = "number" [resources] @@ -80,4 +80,6 @@ ram.runtime = "50M" main.url = "/" [resources.apt] - packages = "qemu-utils e2fsprogs" + packages_from_raw_bash = """ + systemd-detect-virt -q -c && apt install qemu-utils e2fsprogs + """ diff --git a/scripts/_common.sh b/scripts/_common.sh index ec9aa5c..668cfa3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,32 +26,6 @@ fi GARAGE_VERSION="0.8.2" -# inspired by restic helper -install_garage () { - architecture=$(uname -m) - arch='' - case $architecture in - i386|i686) - arch="i686" - ;; - x86_64) - arch=x86_64 - ;; - armv*) - arch=armv6l - ;; - aarch64) - arch=aarch64 - ;; - *) - echo - ynh_die --message="Unsupported architecture \"$architecture\"" - ;; - esac - wget https://garagehq.deuxfleurs.fr/_releases/v$GARAGE_VERSION/$arch-unknown-linux-musl/garage -O garage 2>&1 >/dev/null - chmod +x garage -} - garage_connect() { local command="$1" local peer="$2" diff --git a/scripts/install b/scripts/install index 99247b2..955446f 100755 --- a/scripts/install +++ b/scripts/install @@ -33,25 +33,12 @@ ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers ynh_app_setting_set --app=$app --key=weight --value=$weight -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -if [ "$virtualisation" = "true" ] -then - ynh_install_app_dependencies $pkg_dependencies_virtualisation -fi #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= ynh_script_progression --message="Setting up source files..." --weight=1 -ynh_setup_source --dest_dir="$install_dir" - -chmod -R o-rwx "$install_dir" -chown -R $app:$app "$install_dir" chmod +x $install_dir/garage #================================================= diff --git a/scripts/restore b/scripts/restore index 809871e..84f975b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -17,8 +17,6 @@ ynh_script_progression --message="Restoring the app main directory..." --weight ynh_restore_file --origin_path="$install_dir" -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" chown -R $app:$app "$install_dir" #================================================= @@ -31,8 +29,6 @@ mkdir -p "$data_dir/data" if [ "$virtualisation" = "true" ] then export VIRTUALISATION=true - # Define and install dependencies - ynh_install_app_dependencies $pkg_dependencies_virtualisation # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G $install_dir/mount_disk.sh true diff --git a/scripts/upgrade b/scripts/upgrade index bd32ef9..1943280 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,13 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -if [ "$virtualisation" = "true" ] ; -then - virt_protection="" -else - virt_protection="#" -fi - #================================================= # CHECK VERSION #================================================= @@ -31,16 +24,6 @@ ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" -#================================================= -# INSTALL DEPENDENCIES -#================================================= -ynh_script_progression --message="Installing dependencies..." --weight=1 - -if [ "$virtualisation" = "true" ] -then - ynh_install_app_dependencies $pkg_dependencies_virtualisation -fi - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -48,15 +31,10 @@ fi if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 - - # Download, check integrity, uncompress and patch the source from app.src - pushd $install_dir - install_garage - popd + ynh_setup_source --dest_dir="$install_dir" fi -chmod 750 "$install_dir" -chmod -R o-rwx "$install_dir" +chmod +x $install_dir/garage chown -R $app:$app "$install_dir" #================================================= @@ -85,6 +63,18 @@ ynh_script_progression --message="Upgrading logrotate configuration..." --weigh # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append +ynh_script_progression --message="Updating a configuration file..." --weight=1 + +#================================================= +# UPDATE A CONFIG FILE +#================================================= +### Same as during install +### +### The file will automatically be backed-up if it's found to be manually modified (because +### ynh_add_config keeps track of the file's checksum) +ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" + + #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= From 78990d2f868e56a82dde82c8ce2200680fd23b8d Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sun, 30 Jul 2023 15:02:56 +0200 Subject: [PATCH 25/88] remove storing weight setting. --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index 955446f..a518790 100755 --- a/scripts/install +++ b/scripts/install @@ -31,7 +31,6 @@ ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers -ynh_app_setting_set --app=$app --key=weight --value=$weight #================================================= From ec324a6f402a6ee1f60f2894c2e138d96e782d9d Mon Sep 17 00:00:00 2001 From: lapineige Date: Tue, 1 Aug 2023 15:52:49 +0200 Subject: [PATCH 26/88] better help message (#16) --- manifest.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.toml b/manifest.toml index fd13edd..e7c15e5 100644 --- a/manifest.toml +++ b/manifest.toml @@ -46,8 +46,8 @@ ram.runtime = "50M" optional = true [install.weight] - ask.en = "number of G to allow" - ask.fr = "nombre de G à allouer" + ask.en = "Number of GB to allow for storage" + ask.fr = "Nombre de GB à allouer pour le stockage" type = "number" [resources] From 3c81656a65df8ab60624652d11b03e72c9b7292d Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 16:35:24 +0200 Subject: [PATCH 27/88] Cleanup --- scripts/_common.sh | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 668cfa3..d0fbbaa 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -3,7 +3,6 @@ #================================================= # COMMON VARIABLES #================================================= -pkg_dependencies_virtualisation="qemu-utils e2fsprogs" #================================================= # PERSONAL HELPERS @@ -62,51 +61,6 @@ apply_layout() { # EXPERIMENTAL HELPERS #================================================= -ynh_send_readme_to_admin() { - local app_message="${1:-...No specific information...}" - local recipients="${2:-root}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. -Specific information for the application $app. -$app_message" - - # Define binary to use for mail command - if [ -e /usr/bin/bsd-mailx ] - then - local mail_bin=/usr/bin/bsd-mailx - else - local mail_bin=/usr/bin/mail.mailutils - fi - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} #================================================= # FUTURE OFFICIAL HELPERS #================================================= From 490814db06c5277eacfdb506065a47cefb2475c9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 16:39:18 +0200 Subject: [PATCH 28/88] Simplify regenconf hook handling --- .../98-nginx_garage => conf/regenconf_nginx_garage | 0 scripts/backup | 5 ----- scripts/install | 8 ++------ scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 3 +++ sources/extra_files/app/.gitignore | 2 -- sources/patches/.gitignore | 2 -- 8 files changed, 5 insertions(+), 17 deletions(-) rename sources/hooks/conf_regen/98-nginx_garage => conf/regenconf_nginx_garage (100%) delete mode 100644 sources/extra_files/app/.gitignore delete mode 100644 sources/patches/.gitignore diff --git a/sources/hooks/conf_regen/98-nginx_garage b/conf/regenconf_nginx_garage similarity index 100% rename from sources/hooks/conf_regen/98-nginx_garage rename to conf/regenconf_nginx_garage diff --git a/scripts/backup b/scripts/backup index 3f1e253..6524c9b 100755 --- a/scripts/backup +++ b/scripts/backup @@ -32,8 +32,6 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" - - #================================================= # SPECIFIC BACKUP #================================================= @@ -54,9 +52,6 @@ ynh_backup --src_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$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/install b/scripts/install index a518790..1be7697 100755 --- a/scripts/install +++ b/scripts/install @@ -91,13 +91,9 @@ 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" +ynh_script_progression --message="Adding regen-conf hook..." --weight=1 +ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx #================================================= diff --git a/scripts/remove b/scripts/remove index 0c1407f..ecbf940 100755 --- a/scripts/remove +++ b/scripts/remove @@ -114,7 +114,6 @@ ynh_secure_remove --file="/var/log/$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 84f975b..29eadd6 100755 --- a/scripts/restore +++ b/scripts/restore @@ -63,7 +63,6 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.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" #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 1943280..1e120ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,6 +45,9 @@ ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config +ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" +yunohost tools regen-conf nginx + #================================================= # SETUP SYSTEMD #================================================= diff --git a/sources/extra_files/app/.gitignore b/sources/extra_files/app/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/extra_files/app/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] diff --git a/sources/patches/.gitignore b/sources/patches/.gitignore deleted file mode 100644 index 783a4ae..0000000 --- a/sources/patches/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*~ -*.sw[op] From db6def2d96063304bd84dcb43557aa7d943630b9 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 16:51:34 +0200 Subject: [PATCH 29/88] Clarify the confusing 'virtualisation' variable thingies ... --- conf/mount_disk.sh | 4 +++- conf/systemd.service | 10 +++++----- conf/umount_disk.sh | 6 ++++-- scripts/_common.sh | 29 ++++++++++++----------------- scripts/config | 4 ++-- scripts/install | 24 ++++++------------------ scripts/remove | 7 +------ scripts/restore | 3 +-- 8 files changed, 34 insertions(+), 53 deletions(-) diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index c42ae46..bcc4d7d 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -1,5 +1,7 @@ #!/bin/bash -if [ "$VIRTUALISATION" = "true" ] + +# If we're inside a container +if systemd-detect-virt -c -q then data_dir=__DATA_DIR__ format=$1 diff --git a/conf/systemd.service b/conf/systemd.service index 0e2106c..05f78ac 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,7 +5,7 @@ Wants=network-online.target [Service] User=__APP__ -Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1' +Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__SYSTEM_IS_INSIDE_CONTAINER__' 'RUST_BACKTRACE=1' ExecStartPre=+__INSTALL_DIR__/mount_disk.sh ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server ExecStopPost=+__INSTALL_DIR__/umount_disk.sh @@ -17,16 +17,16 @@ StandardError=inherit # Depending on specificities of your service/app, you may need to tweak these # .. but this should be a good baseline # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html -__VIRT_PROTECTION__PrivateTmp=yes +__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__PrivateTmp=yes #PrivateDevices=yes # RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 RestrictNamespaces=yes RestrictRealtime=yes #DevicePolicy=closed -__VIRT_PROTECTION__ProtectSystem=full -__VIRT_PROTECTION__ProtectControlGroups=yes +__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectSystem=full +__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectControlGroups=yes #ProtectKernelModules=yes -__VIRT_PROTECTION__ProtectKernelTunables=yes +__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectKernelTunables=yes LockPersonality=yes SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap diff --git a/conf/umount_disk.sh b/conf/umount_disk.sh index 7222ef0..15e6314 100755 --- a/conf/umount_disk.sh +++ b/conf/umount_disk.sh @@ -1,7 +1,9 @@ #!/bin/bash -if [ "$VIRTUALISATION" = "true" ] + +# If we're inside a container +if systemd-detect-virt -c -q then - data_dir=__DATA_DIR__ + data_dir=__DATA_DIR__ nbd=$(cat $data_dir/nbd_index) umount /dev/nbd$nbd qemu-nbd --disconnect /dev/nbd$nbd diff --git a/scripts/_common.sh b/scripts/_common.sh index d0fbbaa..ae268d3 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,27 +4,22 @@ # COMMON VARIABLES #================================================= +GARAGE_VERSION="0.8.2" + +if systemd-detect-virt -c -q +then + system_is_inside_container="true" + # used to comment systemd isolation to allow mount disk + comment_if_system_is_inside_container="#" +else + system_is_inside_container="false" + comment_if_system_is_inside_container="" +fi + #================================================= # PERSONAL HELPERS #================================================= -systemd-detect-virt -c -q -if [ $? ] -then #system is inside a container, - export VIRTUALISATION=true - virtualisation=true - # comment systemd isolation to allow mount disk - virt_protection="#" -else - virtualisation=false - export VIRTUALISATION=false - # uncomment systemd isolation - virt_protection="" -fi - - -GARAGE_VERSION="0.8.2" - garage_connect() { local command="$1" local peer="$2" diff --git a/scripts/config b/scripts/config index a39681c..f96b00b 100644 --- a/scripts/config +++ b/scripts/config @@ -17,7 +17,7 @@ ynh_abort_if_errors final_path=$(ynh_app_setting_get $app final_path) node_id=$(ynh_app_setting_get $app node_id) datadir=$(ynh_app_setting_get $app datadir) -if [ "$virtualisation" = "true" ] +if [[ "$system_is_inside_container" == "true" ]] then nbd_index=$(cat $datadir/nbd_index) fi @@ -28,7 +28,7 @@ get__weight() { } set__weight() { - if [ "$virtualisation" = "true" ] + if [[ "$system_is_inside_container" == "true" ]] then systemctl stop $app old_weight="$(ynh_app_setting_get --app=$app --key=weight)" diff --git a/scripts/install b/scripts/install index 1be7697..0c68f56 100755 --- a/scripts/install +++ b/scripts/install @@ -66,26 +66,14 @@ chown $app:$app "$install_dir/garage.toml" #================================================= ynh_script_progression --message="Creating a data directory..." --weight=5 -if [ "$virtualisation" = "true" ] +if [[ "$system_is_inside_container" == "true" ]] then - ynh_print_warn --message="This may take time regarding disk size…" -fi - -#================================================= -# create data partition -#================================================= - -if [ "$virtualisation" = "true" ] -then - # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. + ynh_print_warn --message="This may take time regarding disk size…" + + # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G - VIRTUALISATION=true $install_dir/mount_disk.sh true -fi - - -if [ "$virtualisation" = "true" ] -then - VIRTUALISATION=true $install_dir/umount_disk.sh + $install_dir/mount_disk.sh true + $install_dir/umount_disk.sh fi #================================================= diff --git a/scripts/remove b/scripts/remove index ecbf940..d97f6be 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,11 +13,6 @@ source /usr/share/yunohost/helpers # LOAD SETTINGS #================================================= -if [ "$virtualisation" = "true" ] -then - export VIRTUALISTATION=true -fi - #================================================= # REMOVE NODE CONFIGURATION #================================================= @@ -60,7 +55,7 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight ynh_remove_logrotate -if [ "$virtualisation" = "true" ] +if [[ "$system_is_inside_container" == "true" ]] then #================================================= # REMOVE VIRTUAL DISK diff --git a/scripts/restore b/scripts/restore index 29eadd6..8995364 100755 --- a/scripts/restore +++ b/scripts/restore @@ -26,9 +26,8 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1 mkdir -p "$data_dir/data" -if [ "$virtualisation" = "true" ] +if [[ "$system_is_inside_container" == "true" ]] then - export VIRTUALISATION=true # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G $install_dir/mount_disk.sh true From 56f0757d79efe6a1e773aa7059c8a3d86700d595 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 16:57:41 +0200 Subject: [PATCH 30/88] Having --weight=1 is unecessary --- scripts/change_url | 6 +++--- scripts/install | 20 ++++++++++---------- scripts/remove | 14 +++++++------- scripts/restore | 18 +++++++++--------- scripts/upgrade | 16 ++++++++-------- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/scripts/change_url b/scripts/change_url index f5ff536..643b687 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 +ynh_script_progression --message="Stopping a systemd service..." --time ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time --weight=1 +ynh_script_progression --message="Updating NGINX web server configuration..." --time ynh_change_url_nginx_config @@ -30,7 +30,7 @@ ynh_change_url_nginx_config #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time --weight=1 +ynh_script_progression --message="Starting a systemd service..." --time ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" diff --git a/scripts/install b/scripts/install index 0c68f56..3462c0d 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=1 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers @@ -36,14 +36,14 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=1 +ynh_script_progression --message="Setting up source files..." chmod +x $install_dir/garage #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." --weight=1 +ynh_script_progression --message="Configuring NGINX web server..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -51,7 +51,7 @@ ynh_add_nginx_config #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." --weight=1 +ynh_script_progression --message="Adding a configuration file..." ynh_add_config --template="mount_disk.sh" --destination="$install_dir/mount_disk.sh" ynh_add_config --template="umount_disk.sh" --destination="$install_dir/umount_disk.sh" @@ -79,7 +79,7 @@ fi #================================================= # ADD REGEN-CONF HOOK #================================================= -ynh_script_progression --message="Adding regen-conf hook..." --weight=1 +ynh_script_progression --message="Adding regen-conf hook..." ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx @@ -87,7 +87,7 @@ yunohost tools regen-conf nginx #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=1 +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config @@ -97,7 +97,7 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Configuring log rotation..." --weight=1 +ynh_script_progression --message="Configuring log rotation..." # Use logrotate to manage application logfile(s) ynh_use_logrotate @@ -105,14 +105,14 @@ ynh_use_logrotate #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -120,7 +120,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # CONFIGURE GARAGE #================================================= -ynh_script_progression --message="Configuring garage..." --weight=1 +ynh_script_progression --message="Configuring garage..." garage_command="$install_dir/garage -c $install_dir/garage.toml" diff --git a/scripts/remove b/scripts/remove index d97f6be..806a3f4 100755 --- a/scripts/remove +++ b/scripts/remove @@ -34,14 +34,14 @@ fi # 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 integration..." --weight=1 + ynh_script_progression --message="Removing $app service integration..." yunohost service remove $app fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=1 +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config @@ -49,7 +49,7 @@ ynh_remove_systemd_config #================================================= # REMOVE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Removing logrotate configuration..." --weight=1 +ynh_script_progression --message="Removing logrotate configuration..." # Remove the app-specific logrotate config ynh_remove_logrotate @@ -60,7 +60,7 @@ then #================================================= # REMOVE VIRTUAL DISK #================================================= - ynh_script_progression --message="umount virtual disk..." --weight=1 + ynh_script_progression --message="umount virtual disk..." # Remove the app directory securely $install_dir/umount_disk.sh @@ -73,7 +73,7 @@ fi #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Removing NGINX web server configuration..." # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -89,7 +89,7 @@ ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" if yunohost firewall list | grep -q "\- $port$" then - ynh_script_progression --message="Closing port $port..." --weight=1 + ynh_script_progression --message="Closing port $port..." ynh_exec_warn_less yunohost firewall disallow TCP $port fi @@ -98,7 +98,7 @@ fi #================================================= # REMOVE VARIOUS FILES #================================================= -ynh_script_progression --message="Removing various files..." --weight=1 +ynh_script_progression --message="Removing various files..." # Remove the log files ynh_secure_remove --file="/var/log/$app" diff --git a/scripts/restore b/scripts/restore index 8995364..69c72dc 100755 --- a/scripts/restore +++ b/scripts/restore @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=1 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$install_dir" @@ -22,7 +22,7 @@ chown -R $app:$app "$install_dir" #================================================= # RESTORE THE DATA DIRECTORY #================================================= -ynh_script_progression --message="Restoring the data directory..." --weight=1 +ynh_script_progression --message="Restoring the data directory..." mkdir -p "$data_dir/data" @@ -49,13 +49,13 @@ chown -R $app:$app "$data_dir" #================================================= # Open the port - ynh_script_progression --message="Configuring firewall..." --weight=1 + ynh_script_progression --message="Configuring firewall..." ynh_exec_warn_less yunohost firewall allow TCP $port #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the NGINX web server configuration..." --weight=1 +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 @@ -66,7 +66,7 @@ yunohost tools regen-conf nginx #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=1 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet @@ -74,21 +74,21 @@ systemctl enable $app.service --quiet #================================================= # RESTORE THE LOGROTATE CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." --weight=1 +ynh_script_progression --message="Restoring the logrotate configuration..." ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." #recreate log folder mkdir /var/log/$app @@ -116,7 +116,7 @@ fi #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." --weight=1 +ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index 1e120ae..74305e6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=1 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" @@ -30,7 +30,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=1 + ynh_script_progression --message="Upgrading source files..." ynh_setup_source --dest_dir="$install_dir" fi @@ -40,7 +40,7 @@ chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config @@ -51,7 +51,7 @@ yunohost tools regen-conf nginx #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_add_systemd_config @@ -61,12 +61,12 @@ ynh_add_systemd_config #================================================= # SETUP LOGROTATE #================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1 +ynh_script_progression --message="Upgrading logrotate configuration..." # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -ynh_script_progression --message="Updating a configuration file..." --weight=1 +ynh_script_progression --message="Updating a configuration file..." #================================================= # UPDATE A CONFIG FILE @@ -81,14 +81,14 @@ ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=1 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" From b9bb90c7d51090f7d4f22a21f86b966fafd89cef Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 16:58:46 +0200 Subject: [PATCH 31/88] No need to keep the example config panel --- config_panel.toml.example | 295 -------------------------------------- 1 file changed, 295 deletions(-) delete mode 100644 config_panel.toml.example diff --git a/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index 752051a..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,295 +0,0 @@ - -## Config panel are available from webadmin > Apps > YOUR_APP > Config Panel Button -## Those panels let user configure some params on their apps using a friendly interface, -## and remove the need to manually edit files from the command line. - -## From a packager perspective, this .toml is coupled to the scripts/config script, -## which may be used to define custom getters/setters. However, most use cases -## should be covered automagically by the core, thus it may not be necessary -## to define a scripts/config at all! - -## ----------------------------------------------------------------------------- -## IMPORTANT: In accordance with YunoHost's spirit, please keep things simple and -## do not overwhelm the admin with tons of misunderstandable or advanced settings. -## ----------------------------------------------------------------------------- - -## The top level describe the entire config panels screen. - -## The version is a required property. -## Here a small reminder to associate config panel version with YunoHost version -## | Config | YNH | Config panel small change log | -## | ------ | --- | ------------------------------------------------------- | -## | 0.1 | 3.x | 0.1 config script not compatible with YNH >= 4.3 | -## | 1.0 | 4.3.x | The new config panel system with 'bind' property | -version = "1.0" - -## (optional) i18n property let you internationalize questions, however this feature -## is only available in core configuration panel (like yunohost domain config). -## So in app config panel this key is ignored for now, but you can internationalize -## by using a lang dictionary (see property name bellow) -# i18n = "prefix_translation_key" - -################################################################################ -#### ABOUT PANELS -################################################################################ - -## The next level describes web admin panels -## You have to choose an ID for each panel, in this example the ID is "main" -## Keep in mind this ID will be used in CLI to refer to your question, so choose -## something short and meaningfull. -## In the webadmin, each panel corresponds to a distinct tab / form -[main] - -## Define the label for your panel -## Internationalization works similarly to the 'description' and 'ask' questions in the manifest -# name.en = "Main configuration" -# name.fr = "Configuration principale" - -## (optional) If you need to trigger a service reload-or-restart after the user -## change a question in this panel, you can add your service in the list. -services = ["__APP__"] -# or services = ["nginx", "__APP__"] to also reload-or-restart nginx - -## (optional) This help properties is a short help displayed on the same line -## than the panel title but not displayed in the tab. -# help = "" - - ############################################################################ - #### ABOUT SECTIONS - ############################################################################ - - ## A panel is composed of one or several sections. - ## - ## Sections are meant to group questions together when they correspond to - ## a same subtopic. This impacts the rendering in terms of CLI prompts - ## and HTML forms - ## - ## You should choose an ID for your section, and prefix it with the panel ID - ## (Be sure to not make a typo in the panel ID, which would implicitly create - ## an other entire panel) - ## - ## We use the context of pepettes_ynh as an example, - ## which is a simple donation form app written in python, - ## and for which the admin will want to edit the configuration - [main.customization] - - ## (optional) Defining a proper title for sections is not mandatory - ## and depends on the exact rendering you're aiming for the CLI / webadmin - name = "" - - ## (optional) This help properties is a short help displayed on the same line - ## than the section title, meant to provide additional details - # help = "" - - ## (optional) As for panel, you can specify to trigger a service - ## reload-or-restart after the user change a question in this section. - ## This property is added to the panel property, it doesn't deactivate it. - ## So no need to replicate, the service list from panel services property. - # services = [] - - ## (optional) By default all questions are optionals, but you can specify a - ## default behaviour for question in the section - ##optional = false - - ## (optional) It's also possible with the 'visible' property to only - ## display the section depending on the user's answers to previous questions. - ## - ## Be careful that the 'visible' property should only refer to **previous** questions - ## Hence, it should not make sense to have a "visible" property on the very first section. - ## - ## Also, keep in mind that this feature only works in the webadmin and not in CLI - ## (therefore a user could be prompted in CLI for a question that may not be relevant) - # visible = true - - ######################################################################## - #### ABOUT QUESTIONS - ######################################################################## - - ## A section is compound of one or several questions. - - ## --------------------------------------------------------------------- - ## IMPORTANT: as for panel and section you have to choose an ID, but this - ## one should be unique in all this document, even if the question is in - ## an other panel. - ## --------------------------------------------------------------------- - - ## You can use same questions types and properties than in manifest.yml - ## install part. However, in YNH 4.3, a lot of change has been made to - ## extend availables questions types list. - ## See: TODO DOC LINK - - [main.customization.weight] - - ## (required) The ask property is equivalent to the ask property in - ## the manifest. However, in config panels, questions are displayed on the - ## left side and therefore have less space to be rendered. Therefore, - ## it is better to use a short question, and use the "help" property to - ## provide additional details if necessary. - ask.en = "allocated space" - - ## (required) The type property indicates how the question should be - ## displayed, validated and managed. Some types have specific properties. - ## - ## Types available: string, boolean, number, range, text, password, path - ## email, url, date, time, color, select, domain, user, tags, file. - ## - ## For a complete list with specific properties, see: TODO DOC LINK - type = "number" - - ######################################################################## - #### ABOUT THE BIND PROPERTY - ######################################################################## - - ## (recommended) 'bind' property is a powerful feature that let you - ## configure how and where the data will be read, validated and written. - - ## By default, 'bind property is in "settings" mode, it means it will - ## **only** read and write the value in application settings file. - ## bind = "settings" - - ## However, settings usually correspond to key/values in actual app configurations - ## Hence, a more useful mode is to have bind = ":FILENAME". In that case, YunoHost - ## will automagically find a line with "KEY=VALUE" in FILENAME - ## (with the adequate separator between KEY and VALUE) - ## - ## YunoHost will then use this value for the read/get operation. - ## During write/set operations, YunoHost will overwrite the value - ## in **both** FILENAME and in the app's settings.yml - - ## Configuration file format supported: yaml, toml, json, ini, env, php, - ## python. The feature probably works with others formats, but should be tested carefully. - - ## Note that this feature only works with relatively simple cases - ## such as `KEY: VALUE`, but won't properly work with - ## complex data structures like multilin array/lists or dictionnaries. - ## It also doesn't work with XML format, custom config function call, php define(), ... - - ## More info on TODO - # bind = ":/var/www/__APP__/settings.py" - - - ## By default, bind = ":FILENAME" will use the question ID as KEY - ## ... but the question ID may sometime not be the exact KEY name in the configuration file. - ## - ## In particular, in pepettes, the python variable is 'name' and not 'project_name' - ## (c.f. https://github.com/YunoHost-Apps/pepettes_ynh/blob/5cc2d3ffd6529cc7356ff93af92dbb6785c3ab9a/conf/settings.py##L11 ) - ## - ## In that case, the key name can be specified before the column ':' - - bind = "name:/var/www/__APP__/settings.py" - - ## --------------------------------------------------------------------- - ## IMPORTANT: other 'bind' mode exists: - ## - ## bind = "FILENAME" (with no column character before FILENAME) - ## may be used to bind to the **entire file content** (instead of a single KEY/VALUE) - ## This could be used to expose an entire configuration file, or binary files such as images - ## For example: - ## bind = "/var/www/__APP__/img/logo.png" - ## - ## bind = "null" can be used to disable reading / writing in settings. - ## This creates sort of a "virtual" or "ephemeral" question which is not related to any actual setting - ## In this mode, you are expected to define custom getter/setters/validators in scripts/config: - ## - ## getter: get__QUESTIONID() - ## setter: set__QUESTIONID() - ## validator: validate__QUESTIONID() - ## - ## You can also specify a common getter / setter / validator, with the - ## function 'bind' mode, for example here it will try to run - ## get__array_settings() first. - # bind = "array_settings()" - ## --------------------------------------------------------------------- - - ## --------------------------------------------------------------------- - ## IMPORTANT: with the exception of bind=null questions, - ## question IDs should almost **always** correspond to an app setting - ## initialized / reused during install/upgrade. - ## Not doing so may result in inconsistencies between the config panel mechanism - ## and the use of ynh_add_config - ## --------------------------------------------------------------------- - - ######################################################################## - #### OTHER GENERIC PROPERTY FOR QUESTIONS - ######################################################################## - - ## (optional) An help text for the question - help = "Fill the name of the project which will received donation" - - ## (optional) An example display as placeholder in web form - # example = "YunoHost" - - ## (optional) set to true in order to redact the value in operation logs - # redact = false - - ## (optional) A validation pattern - ## --------------------------------------------------------------------- - ## IMPORTANT: your pattern should be between simple quote, not double. - ## --------------------------------------------------------------------- - pattern.regexp = '^\w{3,30}$' - pattern.error = "The name should be at least 3 chars and less than 30 chars. Alphanumeric chars are accepted" - - ## Note: visible and optional properties are also available for questions - - - [main.customization.contact_url] - ask = "Contact url" - type = "url" - example = "mailto: contact@example.org" - help = "mailto: accepted" - pattern.regexp = '^mailto:[^@]+@[^@]+|https://$' - pattern.error = "Should be https or mailto:" - bind = ":/var/www/__APP__/settings.py" - - [main.customization.logo] - ask = "Logo" - type = "file" - accept = ".png" - help = "Fill with an already resized logo" - bind = "__FINALPATH__/img/logo.png" - - [main.customization.favicon] - ask = "Favicon" - type = "file" - accept = ".png" - help = "Fill with an already sized favicon" - bind = "__FINALPATH__/img/favicon.png" - - - [main.stripe] - name = "Stripe general info" - optional = false - - # The next alert is overwrited with a getter from the config script - [main.stripe.amount] - ask = "Donation in the month : XX € - type = "alert" - style = "success" - - [main.stripe.publishable_key] - ask = "Publishable key" - type = "string" - redact = true - help = "Indicate here the stripe publishable key" - bind = ":/var/www/__APP__/settings.py" - - [main.stripe.secret_key] - ask = "Secret key" - type = "string" - redact = true - help = "Indicate here the stripe secret key" - bind = ":/var/www/__APP__/settings.py" - - [main.stripe.prices] - ask = "Prices ID" - type = "tags" - help = """\ - Indicates here the prices ID of donation products you created in stripe interfaces. \ - Go on [Stripe products](https://dashboard.stripe.com/products) to create those donation products. \ - Fill it tag with 'FREQUENCY/CURRENCY/PRICE_ID' \ - FREQUENCY: 'one_time' or 'recuring' \ - CURRENCY: 'EUR' or 'USD' \ - PRICE_ID: ID from stripe interfaces starting with 'price_' \ - """ - pattern.regexp = '^(one_time|recuring)/(EUR|USD)/price_.*$' - pattern.error = "Please respect the format describe in help text for each price ID" From b85c5231271c49d754edadf3022a64bffe973f85 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 17:37:37 +0200 Subject: [PATCH 32/88] manifest.toml: fix dynamic dependencies declaration --- manifest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index e7c15e5..ba52e30 100644 --- a/manifest.toml +++ b/manifest.toml @@ -81,5 +81,5 @@ ram.runtime = "50M" [resources.apt] packages_from_raw_bash = """ - systemd-detect-virt -q -c && apt install qemu-utils e2fsprogs + systemd-detect-virt -q -c && echo "qemu-utils e2fsprogs" || true """ From 224b3063e2654e966dd68bb82c095568182c56f7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 17:55:17 +0200 Subject: [PATCH 33/88] Missing setup_source in install x_x --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 3462c0d..d769867 100755 --- a/scripts/install +++ b/scripts/install @@ -38,6 +38,7 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers #================================================= ynh_script_progression --message="Setting up source files..." +ynh_setup_source --dest_dir="$install_dir" chmod +x $install_dir/garage #================================================= From a0be4c3e5dc6e47201c1fc44d678174214157115 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 Aug 2023 18:48:03 +0200 Subject: [PATCH 34/88] Fix chmod +x on file that doesnt exist ... --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d769867..78dd45a 100755 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers ynh_script_progression --message="Setting up source files..." ynh_setup_source --dest_dir="$install_dir" -chmod +x $install_dir/garage +# chmod +x $install_dir/garage # this file doesnt seem to exist ... remove this line ? #================================================= # NGINX CONFIGURATION From 26161fbe2946feaf7c08e59c76afcd635e3c2723 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:11:36 +0100 Subject: [PATCH 35/88] Update regenconf_nginx_garage: hook should act on the $pending_dir, not the actual conf --- conf/regenconf_nginx_garage | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/conf/regenconf_nginx_garage b/conf/regenconf_nginx_garage index a974512..e3a5a32 100644 --- a/conf/regenconf_nginx_garage +++ b/conf/regenconf_nginx_garage @@ -8,5 +8,4 @@ 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" +ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="$pending_dir/etc/nginx/conf.d/$domain.conf" From 041cf1c42ceba7076a174c0ac866b3d6b65d809e Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 10 Dec 2023 13:11:40 +0000 Subject: [PATCH 36/88] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f178ee2..31f8f08 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ Garage is designed for storage clusters composed of nodes running at different p * Official user documentation: * Official admin documentation: * Upstream app code repository: -* YunoHost documentation for this app: +* YunoHost Store: * Report a bug: ## Developer info diff --git a/README_fr.md b/README_fr.md index e243ef7..ff14725 100644 --- a/README_fr.md +++ b/README_fr.md @@ -57,7 +57,7 @@ Garage is designed for storage clusters composed of nodes running at different p * Documentation officielle utilisateur : * Documentation officielle de l’admin : * Dépôt de code officiel de l’app : -* Documentation YunoHost pour cette app : +* YunoHost Store: * Signaler un bug : ## Informations pour les développeurs From 4f9c6bd04733036d68bfbe1371b2a5813d27308f Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:38:27 +0100 Subject: [PATCH 37/88] Update regenconf_nginx_garage: oopsi --- conf/regenconf_nginx_garage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/regenconf_nginx_garage b/conf/regenconf_nginx_garage index e3a5a32..d8a34b0 100644 --- a/conf/regenconf_nginx_garage +++ b/conf/regenconf_nginx_garage @@ -8,4 +8,4 @@ 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="$pending_dir/etc/nginx/conf.d/$domain.conf" +ynh_replace_special_string --match_string="server_name $domain" --replace_string="server_name $domain *.$domain" --target_file="$pending_dir/../nginx/etc/nginx/conf.d/$domain.conf" From d1951c143541932fec048c431ed79793c86a44af Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:40:34 +0100 Subject: [PATCH 38/88] Update conf/mount_disk.sh: fix condition that creates the virtual disk --- conf/mount_disk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index bcc4d7d..0c09ab1 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -1,7 +1,7 @@ #!/bin/bash -# If we're inside a container -if systemd-detect-virt -c -q +# If we're NOT inside a container +if ! systemd-detect-virt -c -q then data_dir=__DATA_DIR__ format=$1 From 50002636a14dff09d1876595ea8ff3c288a06bda Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:41:03 +0100 Subject: [PATCH 39/88] Update conf/umount_disk.sh: same as previous commit --- conf/umount_disk.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/umount_disk.sh b/conf/umount_disk.sh index 15e6314..9ecc0d6 100755 --- a/conf/umount_disk.sh +++ b/conf/umount_disk.sh @@ -1,7 +1,7 @@ #!/bin/bash -# If we're inside a container -if systemd-detect-virt -c -q +# If we're NOT inside a container +if ! systemd-detect-virt -c -q then data_dir=__DATA_DIR__ nbd=$(cat $data_dir/nbd_index) From b1be70cc72c482f028bd10fc9c4e2c42cfb28d61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:46:24 +0100 Subject: [PATCH 40/88] Update manifest.toml --- manifest.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index ba52e30..735f010 100644 --- a/manifest.toml +++ b/manifest.toml @@ -17,11 +17,14 @@ userdoc = "https://garagehq.deuxfleurs.fr/documentation/quick-start/" code = "https://git.deuxfleurs.fr/Deuxfleurs/garage" [integration] -yunohost = ">= 11.1.18" +yunohost = ">= 11.2" architectures = "all" multi_instance = true + ldap = false + sso = false + disk = "50M" ram.build = "50M" ram.runtime = "50M" From d7eb6c78730d44d546e75a1c2fcfdf1ba781ce93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:00:53 +0100 Subject: [PATCH 41/88] 0.9.0 --- manifest.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest.toml b/manifest.toml index 735f010..6d85208 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Garage" description.en = "S3 storage" description.fr = "stockage S3" -version = "0.8.2~ynh1" +version = "0.9.0~ynh1" maintainers = ["oiseauroch"] @@ -59,14 +59,14 @@ ram.runtime = "50M" [resources.sources.main] in_subdir = false - amd64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/x86_64-unknown-linux-musl/garage" - amd64.sha256 = "c15aa223b0fffb856c6e16276d1e77b0e94eb783a26eaeb7de80324f7c8b23c5" - arm64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/aarch64-unknown-linux-musl/garage" - arm64.sha256 = "9c419d47e87ac254a96cda6476e3c5c9102a9a2ea1ec1dc65d338bb46e415d78" - i386.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/i686-unknown-linux-musl/garage" - i386.sha256 = "a733fcd9b0a0f6271960f0d65978b8a8474317fa41325595aa4825764b71f089" - armhf.url = "https://garagehq.deuxfleurs.fr/_releases/v0.8.2/armv6l-unknown-linux-musleabihf/garage" - armhf.sha256 = "1eb79aa8fff6c00bd1dd5da53dedd04685fe28b3402476a3b10b1b66aa10f80a" + amd64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/x86_64-unknown-linux-musl/garage" + amd64.sha256 = "3ae4ecb2a75610ab7bfe77bfac7a5c7a8834a0544158ac8ee37723e6d8fd1859" + arm64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/aarch64-unknown-linux-musl/garage" + arm64.sha256 = "b4db67a618ed493e1803d8bae83e8ea091703763b182d4c62fa1896179b17b9b" + i386.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/i686-unknown-linux-musl/garage" + i386.sha256 = "fcec4c6918ac5ae04829ed9c4f20c7eef0966194eabfe961e6d7f8aee14b0108" + armhf.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/armv6l-unknown-linux-musleabihf/garage" + armhf.sha256 = "8f04a38fcafc2ccda652738f2e80b0d2b6443150db0d7165db2de6c75035b4e3" [resources.ports] main.default = 4000 From 9fc625df31f961ef7ae5f64ca06d84e4aa518a9d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 10 Dec 2023 14:00:58 +0000 Subject: [PATCH 42/88] Auto-update README --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 31f8f08..7474101 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Garage is designed for storage clusters composed of nodes running at different p - K2V API (experimental) -**Shipped version:** 0.8.2~ynh1 +**Shipped version:** 0.9.0~ynh1 ## Disclaimers / important information * Limitations : diff --git a/README_fr.md b/README_fr.md index ff14725..f0ac369 100644 --- a/README_fr.md +++ b/README_fr.md @@ -35,7 +35,7 @@ Garage is designed for storage clusters composed of nodes running at different p - K2V API (experimental) -**Version incluse :** 0.8.2~ynh1 +**Version incluse :** 0.9.0~ynh1 ## Avertissements / informations importantes * Limitations : From 2669b8b41fe16a4198087f6b4a34b07b0d9b003d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:14:58 +0100 Subject: [PATCH 43/88] Update install --- scripts/install | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/scripts/install b/scripts/install index 78dd45a..a48b89b 100755 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -69,7 +68,7 @@ ynh_script_progression --message="Creating a data directory..." --weight=5 if [[ "$system_is_inside_container" == "true" ]] then - ynh_print_warn --message="This may take time regarding disk size…" + ynh_print_warn --message="This may take time regarding disk size..." # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G @@ -93,22 +92,10 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE From 6f145ca3c7587619297521ef370376459c0728d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:15:39 +0100 Subject: [PATCH 44/88] cleaning --- manifest.toml | 1 + scripts/install | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/manifest.toml b/manifest.toml index 6d85208..fdeee40 100644 --- a/manifest.toml +++ b/manifest.toml @@ -59,6 +59,7 @@ ram.runtime = "50M" [resources.sources.main] in_subdir = false + extract = false amd64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/x86_64-unknown-linux-musl/garage" amd64.sha256 = "3ae4ecb2a75610ab7bfe77bfac7a5c7a8834a0544158ac8ee37723e6d8fd1859" arm64.url = "https://garagehq.deuxfleurs.fr/_releases/v0.9.0/aarch64-unknown-linux-musl/garage" diff --git a/scripts/install b/scripts/install index 78dd45a..da24ba1 100755 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,8 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers ynh_script_progression --message="Setting up source files..." ynh_setup_source --dest_dir="$install_dir" -# chmod +x $install_dir/garage # this file doesnt seem to exist ... remove this line ? + +chmod +x $install_dir/garage #================================================= # NGINX CONFIGURATION From 9dfe0785db2a28b19032bbab62c358f4bab69ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 15:23:59 +0100 Subject: [PATCH 45/88] cleaning --- check_process | 32 ----------------------------- conf/mount_disk.sh | 1 - manifest.toml | 1 + scripts/_common.sh | 7 ++++--- scripts/backup | 5 ----- scripts/change_url | 8 ++++---- scripts/install | 17 ++-------------- scripts/remove | 50 ++-------------------------------------------- scripts/restore | 37 ++-------------------------------- scripts/upgrade | 28 +++----------------------- 10 files changed, 18 insertions(+), 168 deletions(-) delete mode 100644 check_process diff --git a/check_process b/check_process deleted file mode 100644 index 45831c9..0000000 --- a/check_process +++ /dev/null @@ -1,32 +0,0 @@ -# See here for more information -# https://github.com/YunoHost/package_check#syntax-check_process-file - -# Move this file from check_process.default to check_process when you have filled it. - -;; Test complet - ; Manifest - domain="domain.tld" - rpc_secret="" - bootstrap_peers="" - weight="10" - datadir="" - ; Checks - pkg_linter=1 - setup_sub_dir=0 - setup_root=0 - setup_nourl=1 - setup_private=0 - setup_public=0 - upgrade=1 - upgrade=0 from_commit=CommitHash - backup_restore=1 - multi_instance=1 - port_already_use=0 - change_url=1 -;;; Options -Email= -Notification=none -;;; Upgrade options - ; commit=CommitHash - name=Name and date of the commit. - manifest_arg=domain=DOMAIN&rpc_secret=RPC_SECRET&bootstrap_peers=BOOTSTRAP_PEERS&weight=WEIGHT&datadir=DATADIR diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index 0c09ab1..53f2acc 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -18,7 +18,6 @@ then echo "formatting /dev/nbd$i" mkfs.ext4 /dev/nbd$i fi - mkdir -p $data_dir/data chown __APP__:__APP__ $data_dir/data mount /dev/nbd$i $data_dir/data/ fi diff --git a/manifest.toml b/manifest.toml index fdeee40..af0af6f 100644 --- a/manifest.toml +++ b/manifest.toml @@ -79,6 +79,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] + subdirs = ["data", "metadata"] [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index ae268d3..55ecd08 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -4,7 +4,7 @@ # COMMON VARIABLES #================================================= -GARAGE_VERSION="0.8.2" +GARAGE_VERSION="0.9.0" if systemd-detect-virt -c -q then @@ -32,7 +32,7 @@ garage_connect() { i=$(( i + 1 )) if [ $i -gt 30 ] then - ynh_die --message="unable to get layout from remote peer" + ynh_die --message="Unable to get layout from remote peer" fi sleep 1 done @@ -48,10 +48,11 @@ apply_layout() { then $garage_command layout apply --version $layout_version else - ynh_print_warn --message="unable to apply layout. No enough nodes" + ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 fi } + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/backup b/scripts/backup index 6524c9b..80e2ce2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,11 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/change_url b/scripts/change_url index 643b687..8361d45 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time +ynh_script_progression --message="Updating NGINX web server configuration..." ynh_change_url_nginx_config @@ -30,7 +30,7 @@ ynh_change_url_nginx_config #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time +ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -38,4 +38,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app"--last diff --git a/scripts/install b/scripts/install index da24ba1..b5836f0 100755 --- a/scripts/install +++ b/scripts/install @@ -32,7 +32,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers - #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -70,7 +69,7 @@ ynh_script_progression --message="Creating a data directory..." --weight=5 if [[ "$system_is_inside_container" == "true" ]] then - ynh_print_warn --message="This may take time regarding disk size…" + ynh_print_warn --message="This may take time regarding disk size..." # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G @@ -94,22 +93,10 @@ ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Configuring log rotation..." - # Use logrotate to manage application logfile(s) ynh_use_logrotate -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/remove b/scripts/remove index 806a3f4..872de97 100755 --- a/scripts/remove +++ b/scripts/remove @@ -9,13 +9,10 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - #================================================= # REMOVE NODE CONFIGURATION #================================================= + $install_dir/garage -c $install_dir/garage.toml layout remove "$node_id" apply_layout "$install_dir/garage -c $install_dir/garage.toml " @@ -24,7 +21,6 @@ then ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough" fi - #================================================= # STANDARD REMOVE #================================================= @@ -38,43 +34,23 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - # Remove the app-specific logrotate config ynh_remove_logrotate - if [[ "$system_is_inside_container" == "true" ]] then #================================================= # REMOVE VIRTUAL DISK #================================================= - ynh_script_progression --message="umount virtual disk..." + ynh_script_progression --message="Umount virtual disk..." # Remove the app directory securely $install_dir/umount_disk.sh fi -#================================================= -# REMOVE NGINX HOOK -#================================================= - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -82,31 +58,9 @@ ynh_remove_nginx_config ynh_replace_string --replace_string="server_name $domain" --match_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - -#================================================= -# SPECIFIC REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= - ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx diff --git a/scripts/restore b/scripts/restore index 69c72dc..3f8f6c0 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,8 +24,6 @@ chown -R $app:$app "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." -mkdir -p "$data_dir/data" - if [[ "$system_is_inside_container" == "true" ]] then # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. @@ -33,25 +31,8 @@ then $install_dir/mount_disk.sh true fi - -# # FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$data_dir" -chmod -R o-rwx "$data_dir" chown -R $app:$app "$data_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= - -# Open the port - ynh_script_progression --message="Configuring firewall..." - ynh_exec_warn_less yunohost firewall allow TCP $port - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -63,27 +44,12 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE @@ -94,6 +60,7 @@ ynh_script_progression --message="Starting a systemd service..." mkdir /var/log/$app ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" + #================================================= # RECREATE CONFIGURATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 74305e6..bf7a341 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -48,43 +48,21 @@ ynh_add_nginx_config ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -ynh_script_progression --message="Updating a configuration file..." +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # UPDATE A CONFIG FILE #================================================= -### Same as during install -### -### The file will automatically be backed-up if it's found to be manually modified (because -### ynh_add_config keeps track of the file's checksum) +ynh_script_progression --message="Updating a configuration file..." + ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" - -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app - #================================================= # START SYSTEMD SERVICE #================================================= From a2cf57b4e94e2fa865381e3c592360f8ecfb161a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:16:20 +0100 Subject: [PATCH 46/88] cleaning --- doc/{DISCLAIMER.md => ADMIN.md} | 0 manifest.toml | 1 - scripts/restore | 2 +- scripts/upgrade | 3 +-- 4 files changed, 2 insertions(+), 4 deletions(-) rename doc/{DISCLAIMER.md => ADMIN.md} (100%) diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/manifest.toml b/manifest.toml index 735f010..142ff9e 100644 --- a/manifest.toml +++ b/manifest.toml @@ -32,7 +32,6 @@ ram.runtime = "50M" [install] [install.domain] type = "domain" - full_domain = true [install.rpc_secret] ask.en = "UUID of the network (rpc-secret) " diff --git a/scripts/restore b/scripts/restore index 69c72dc..82d142d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -83,7 +83,7 @@ ynh_restore_file --origin_path="/etc/logrotate.d/$app" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 74305e6..bc5deea 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -77,13 +77,12 @@ ynh_script_progression --message="Updating a configuration file..." ### ynh_add_config keeps track of the file's checksum) ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add --needs_exposed_ports $port --description="s3 storage" --log="/var/log/$app/$app.log" $app +yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= # START SYSTEMD SERVICE From f432979eab4a0342f25807ea14ae2955d80e1643 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 10 Dec 2023 19:16:25 +0000 Subject: [PATCH 47/88] Auto-update README --- README.md | 15 --------------- README_fr.md | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/README.md b/README.md index 31f8f08..d8d339d 100644 --- a/README.md +++ b/README.md @@ -36,21 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Shipped version:** 0.8.2~ynh1 -## Disclaimers / important information - -* Limitations : - * This application is not usable if you're not part of a cluster with minimun 3 other nodes - * If you are behind a nat and use upnp to configure your port redirection, you may need to add peers via config panel instead of during installation and/or create a permanent redirection in your router/box - -* infos you should be aware of: - * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. - * This application consider that the weight of the node is the size reserved to garage in G - * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. - -# How to run commands for Garage -1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. -2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index ff14725..f24d3ff 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,21 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Version incluse :** 0.8.2~ynh1 -## Avertissements / informations importantes - -* Limitations : - * This application is not usable if you're not part of a cluster with minimun 3 other nodes - * If you are behind a nat and use upnp to configure your port redirection, you may need to add peers via config panel instead of during installation and/or create a permanent redirection in your router/box - -* infos you should be aware of: - * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. - * This application consider that the weight of the node is the size reserved to garage in G - * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. - -# How to run commands for Garage -1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. -2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. - ## Documentations et ressources * Site officiel de l’app : From 71ef247b3d7a0675a3f195388c51487f29edbbc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:16:49 +0100 Subject: [PATCH 48/88] Create tests.toml --- tests.toml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tests.toml diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..91daf17 --- /dev/null +++ b/tests.toml @@ -0,0 +1,7 @@ +test_format = 1.0 + +[default] + + # ------------ + # Tests to run + # ------------ \ No newline at end of file From 372de747a8ac3427fd3e9d883679a2127d2f8774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:34:23 +0100 Subject: [PATCH 49/88] cleaning --- doc/{DISCLAIMER.md => ADMIN.md} | 0 tests.toml | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename doc/{DISCLAIMER.md => ADMIN.md} (100%) create mode 100644 tests.toml diff --git a/doc/DISCLAIMER.md b/doc/ADMIN.md similarity index 100% rename from doc/DISCLAIMER.md rename to doc/ADMIN.md diff --git a/tests.toml b/tests.toml new file mode 100644 index 0000000..e69de29 From d31371694bc940376e936e70ec28694e9d25b715 Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 10 Dec 2023 19:34:28 +0000 Subject: [PATCH 50/88] Auto-update README --- README.md | 15 --------------- README_fr.md | 15 --------------- 2 files changed, 30 deletions(-) diff --git a/README.md b/README.md index 7474101..18ab4b4 100644 --- a/README.md +++ b/README.md @@ -36,21 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Shipped version:** 0.9.0~ynh1 -## Disclaimers / important information - -* Limitations : - * This application is not usable if you're not part of a cluster with minimun 3 other nodes - * If you are behind a nat and use upnp to configure your port redirection, you may need to add peers via config panel instead of during installation and/or create a permanent redirection in your router/box - -* infos you should be aware of: - * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. - * This application consider that the weight of the node is the size reserved to garage in G - * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. - -# How to run commands for Garage -1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. -2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index f0ac369..388ea98 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,21 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Version incluse :** 0.9.0~ynh1 -## Avertissements / informations importantes - -* Limitations : - * This application is not usable if you're not part of a cluster with minimun 3 other nodes - * If you are behind a nat and use upnp to configure your port redirection, you may need to add peers via config panel instead of during installation and/or create a permanent redirection in your router/box - -* infos you should be aware of: - * This application provide a node that you can connect to a garage cluster. Few option are manageable by the config panel for the current node but IT DOESN'T offer simpler way to manage bucket and keys. You have to do it by command line or let an other node managing it. - * This application consider that the weight of the node is the size reserved to garage in G - * This application will try to create a virtual disk to ensure garage doesn't use more than allowed. If virtualisation is not available your responsible to check space used by garage. - -# How to run commands for Garage -1. Use `yunohost app shell garage` to use the command line in Garage own environnement (don't forget to `exit` at the end). You will be located in `/opt/yunohost/garage/` own directory. -2. Then for each use of the `garage` command, you need to specify the config file as a parameter `garage -c garage.toml [the actions you wish to run]`. - ## Documentations et ressources * Site officiel de l’app : From 10f25ee54f2219b3109747157d2c8cbed81c173d Mon Sep 17 00:00:00 2001 From: yunohost-bot Date: Sun, 10 Dec 2023 19:35:46 +0000 Subject: [PATCH 51/88] Auto-update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 7176552..18ab4b4 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Shipped version:** 0.9.0~ynh1 - ## Documentation and resources * Official app website: diff --git a/README_fr.md b/README_fr.md index c6acc98..388ea98 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,7 +36,6 @@ Garage is designed for storage clusters composed of nodes running at different p **Version incluse :** 0.9.0~ynh1 - ## Documentations et ressources * Site officiel de l’app : From f84c1b3a223dc8a2809f699237ddf08112c63b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:36:43 +0100 Subject: [PATCH 52/88] Update manifest.toml --- manifest.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/manifest.toml b/manifest.toml index 178276f..9aa4d92 100644 --- a/manifest.toml +++ b/manifest.toml @@ -33,6 +33,10 @@ ram.runtime = "50M" [install.domain] type = "domain" + [install.init_main_permission] + type = "group" + default = "visitors" + [install.rpc_secret] ask.en = "UUID of the network (rpc-secret) " ask.fr = "UUID de l'ilot (rpc-secret)" From 490ccfde42012859bd0d99ad13cca8125c6d00df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:38:16 +0100 Subject: [PATCH 53/88] Update tests.toml --- tests.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index 91daf17..c653a24 100644 --- a/tests.toml +++ b/tests.toml @@ -4,4 +4,6 @@ test_format = 1.0 # ------------ # Tests to run - # ------------ \ No newline at end of file + # ------------ + + args.weight = 2 \ No newline at end of file From 073c935d099700abc515daee9b1a7878cc6a8523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:39:14 +0100 Subject: [PATCH 54/88] Update tests.toml --- tests.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index c653a24..8282c93 100644 --- a/tests.toml +++ b/tests.toml @@ -6,4 +6,4 @@ test_format = 1.0 # Tests to run # ------------ - args.weight = 2 \ No newline at end of file + args.weight = "10" \ No newline at end of file From b9f09dd2e682e996bed5d4aa187666df0531af28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:40:31 +0100 Subject: [PATCH 55/88] Update tests.toml --- tests.toml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index 91daf17..cfc9cf6 100644 --- a/tests.toml +++ b/tests.toml @@ -4,4 +4,6 @@ test_format = 1.0 # ------------ # Tests to run - # ------------ \ No newline at end of file + # ------------ + + args.weight = "10" \ No newline at end of file From 37f93ac72c4293a45bf36620d64840f2aaeca9c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:52:41 +0100 Subject: [PATCH 56/88] cleaning --- doc/POST_INSTALL.md | 6 ++++++ scripts/backup | 5 ----- scripts/change_url | 8 ++++---- scripts/install | 36 +++++++++++------------------------- scripts/remove | 20 ++------------------ 5 files changed, 23 insertions(+), 52 deletions(-) create mode 100644 doc/POST_INSTALL.md diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md new file mode 100644 index 0000000..b420b12 --- /dev/null +++ b/doc/POST_INSTALL.md @@ -0,0 +1,6 @@ +Your Garage node have been installed. You can now connect to other nodes with the following identifiers : + + rpc_secret: __RPC_SECRET__ + bootstrap_peers: __SELF_BOOTSTRAP_PEERS__ + +Current garage layout: __GARAGE_LAYOUT__ diff --git a/scripts/backup b/scripts/backup index 6524c9b..80e2ce2 100755 --- a/scripts/backup +++ b/scripts/backup @@ -15,11 +15,6 @@ source /usr/share/yunohost/helpers #================================================= ynh_print_info --message="Declaring files to be backed up..." -### N.B. : the following 'ynh_backup' calls are only a *declaration* of what needs -### to be backuped and not an actual copy of any file. The actual backup that -### creates and fill the archive with the files happens in the core after this -### script is called. Hence ynh_backups calls takes basically 0 seconds to run. - #================================================= # BACKUP THE APP MAIN DIR #================================================= diff --git a/scripts/change_url b/scripts/change_url index 643b687..ae914ad 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -14,14 +14,14 @@ source /usr/share/yunohost/helpers #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --time +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" #================================================= # MODIFY URL IN NGINX CONF #================================================= -ynh_script_progression --message="Updating NGINX web server configuration..." --time +ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 ynh_change_url_nginx_config @@ -30,7 +30,7 @@ ynh_change_url_nginx_config #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --time +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -38,4 +38,4 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap # END OF SCRIPT #================================================= -ynh_script_progression --message="Change of URL completed for $app" --time --last +ynh_script_progression --message="Change of URL completed for $app" --last diff --git a/scripts/install b/scripts/install index a48b89b..73c047b 100755 --- a/scripts/install +++ b/scripts/install @@ -27,7 +27,7 @@ fi #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." +ynh_script_progression --message="Storing installation settings..." --weight=1 ynh_app_setting_set --app=$app --key=rpc_secret --value=$rpc_secret ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers @@ -35,7 +35,7 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." +ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" # chmod +x $install_dir/garage # this file doesnt seem to exist ... remove this line ? @@ -43,7 +43,7 @@ ynh_setup_source --dest_dir="$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring NGINX web server..." +ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -51,7 +51,7 @@ ynh_add_nginx_config #================================================= # ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Adding a configuration file..." +ynh_script_progression --message="Adding a configuration file..." --weight=1 ynh_add_config --template="mount_disk.sh" --destination="$install_dir/mount_disk.sh" ynh_add_config --template="umount_disk.sh" --destination="$install_dir/umount_disk.sh" @@ -64,7 +64,7 @@ chown $app:$app "$install_dir/garage.toml" #================================================= # CREATE DATA DIRECTORY #================================================= -ynh_script_progression --message="Creating a data directory..." --weight=5 +ynh_script_progression --message="Creating a data directory..." --weight=5 if [[ "$system_is_inside_container" == "true" ]] then @@ -79,7 +79,7 @@ fi #================================================= # ADD REGEN-CONF HOOK #================================================= -ynh_script_progression --message="Adding regen-conf hook..." +ynh_script_progression --message="Adding regen-conf hook..." --weight=1 ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx @@ -87,7 +87,7 @@ yunohost tools regen-conf nginx #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." +ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config @@ -100,7 +100,7 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" @@ -108,7 +108,7 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$ap #================================================= # CONFIGURE GARAGE #================================================= -ynh_script_progression --message="Configuring garage..." +ynh_script_progression --message="Configuring garage..." --weight=1 garage_command="$install_dir/garage -c $install_dir/garage.toml" @@ -138,24 +138,10 @@ fi self_bootstrap_peers="$($garage_command node id --quiet)" garage_layout="$($garage_command layout show)" - -#================================================= -# Send email to admin -#================================================= -app_message=" -your garage node have been installed. You can now connect to other nodes with the following identifiers : - - rpc_secret: $rpc_secret - bootstrap_peers: $self_bootstrap_peers - -Current garage layout : - -$garage_layout" - -ynh_send_readme_to_admin --app_message="$app_message" +ynh_app_setting_set --app=$app --key=garage_layout --value=$garage_layout #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" --last diff --git a/scripts/remove b/scripts/remove index 806a3f4..c5a9009 100755 --- a/scripts/remove +++ b/scripts/remove @@ -1,4 +1,4 @@ - #!/bin/bash +#!/bin/bash #================================================= # GENERIC START @@ -9,10 +9,6 @@ source _common.sh source /usr/share/yunohost/helpers -#================================================= -# LOAD SETTINGS -#================================================= - #================================================= # REMOVE NODE CONFIGURATION #================================================= @@ -24,7 +20,6 @@ then ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough" fi - #================================================= # STANDARD REMOVE #================================================= @@ -60,7 +55,7 @@ then #================================================= # REMOVE VIRTUAL DISK #================================================= - ynh_script_progression --message="umount virtual disk..." + ynh_script_progression --message="Umount virtual disk..." # Remove the app directory securely $install_dir/umount_disk.sh @@ -82,17 +77,6 @@ ynh_remove_nginx_config ynh_replace_string --replace_string="server_name $domain" --match_string="server_name $domain *.$domain" --target_file="/etc/nginx/conf.d/$domain.conf" ynh_store_file_checksum --file="/etc/nginx/conf.d/$domain.conf" - -#================================================= -# CLOSE A PORT -#================================================= - -if yunohost firewall list | grep -q "\- $port$" -then - ynh_script_progression --message="Closing port $port..." - ynh_exec_warn_less yunohost firewall disallow TCP $port -fi - #================================================= # SPECIFIC REMOVE #================================================= From 060b38422d849ee3bfefae7a923c8f1469b11c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:53:23 +0100 Subject: [PATCH 57/88] Update manifest.toml --- manifest.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/manifest.toml b/manifest.toml index 142ff9e..f9ca10c 100644 --- a/manifest.toml +++ b/manifest.toml @@ -77,6 +77,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] + subdirs = ["data"] [resources.permissions] main.url = "/" From ed30446be7f7b60d3d6b690e56f4b6cb344c5c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 20:56:18 +0100 Subject: [PATCH 58/88] Update tests.toml --- tests.toml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index cfc9cf6..137a83f 100644 --- a/tests.toml +++ b/tests.toml @@ -6,4 +6,9 @@ test_format = 1.0 # Tests to run # ------------ - args.weight = "10" \ No newline at end of file + exclude = ["install.private", "install.root", "install.subdir", "install.multi"] + + # ------------------------------- + # Default args to use for install + # ------------------------------- + args.weight = "10" From 3a53cc86965f878a665bab322ad96025a840a11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:01:43 +0100 Subject: [PATCH 59/88] cleaning --- conf/mount_disk.sh | 1 - manifest.toml | 2 +- scripts/_common.sh | 4 ++-- scripts/backup | 2 -- scripts/change_url | 4 ++-- scripts/install | 2 +- scripts/remove | 39 +++------------------------------------ scripts/restore | 39 ++++----------------------------------- scripts/upgrade | 26 +++++--------------------- 9 files changed, 18 insertions(+), 101 deletions(-) diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index 0c09ab1..53f2acc 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -18,7 +18,6 @@ then echo "formatting /dev/nbd$i" mkfs.ext4 /dev/nbd$i fi - mkdir -p $data_dir/data chown __APP__:__APP__ $data_dir/data mount /dev/nbd$i $data_dir/data/ fi diff --git a/manifest.toml b/manifest.toml index f9ca10c..3ee43a4 100644 --- a/manifest.toml +++ b/manifest.toml @@ -77,7 +77,7 @@ ram.runtime = "50M" [resources.install_dir] [resources.data_dir] - subdirs = ["data"] + subdirs = ["data", "metadata"] [resources.permissions] main.url = "/" diff --git a/scripts/_common.sh b/scripts/_common.sh index ae268d3..9408df1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -32,7 +32,7 @@ garage_connect() { i=$(( i + 1 )) if [ $i -gt 30 ] then - ynh_die --message="unable to get layout from remote peer" + ynh_die --message="Unable to get layout from remote peer" fi sleep 1 done @@ -48,7 +48,7 @@ apply_layout() { then $garage_command layout apply --version $layout_version else - ynh_print_warn --message="unable to apply layout. No enough nodes" + ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 fi } diff --git a/scripts/backup b/scripts/backup index 80e2ce2..d306ce7 100755 --- a/scripts/backup +++ b/scripts/backup @@ -27,8 +27,6 @@ ynh_backup --src_path="$install_dir" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" -#================================================= -# SPECIFIC BACKUP #================================================= # BACKUP LOGROTATE #================================================= diff --git a/scripts/change_url b/scripts/change_url index ae914ad..3a9b28d 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -16,7 +16,7 @@ source /usr/share/yunohost/helpers #================================================= ynh_script_progression --message="Stopping a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # MODIFY URL IN NGINX CONF @@ -32,7 +32,7 @@ ynh_change_url_nginx_config #================================================= ynh_script_progression --message="Starting a systemd service..." --weight=1 -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT diff --git a/scripts/install b/scripts/install index 73c047b..2791de0 100755 --- a/scripts/install +++ b/scripts/install @@ -103,7 +103,7 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # CONFIGURE GARAGE diff --git a/scripts/remove b/scripts/remove index c5a9009..c7210aa 100755 --- a/scripts/remove +++ b/scripts/remove @@ -12,12 +12,13 @@ source /usr/share/yunohost/helpers #================================================= # REMOVE NODE CONFIGURATION #================================================= + $install_dir/garage -c $install_dir/garage.toml layout remove "$node_id" apply_layout "$install_dir/garage -c $install_dir/garage.toml " if [ $? -ne 0 ] then - ynh_print_warn --message="unable to remove the node. Maybe the number of node staying alive is not enough" + ynh_print_warn --message="Unable to remove the node. Maybe the number of node staying alive is not enough" fi #================================================= @@ -33,43 +34,20 @@ then yunohost service remove $app fi -#================================================= -# STOP AND REMOVE SERVICE -#================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." - # Remove the dedicated systemd config ynh_remove_systemd_config -#================================================= -# REMOVE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Removing logrotate configuration..." - # Remove the app-specific logrotate config ynh_remove_logrotate - if [[ "$system_is_inside_container" == "true" ]] then - #================================================= - # REMOVE VIRTUAL DISK - #================================================= ynh_script_progression --message="Umount virtual disk..." # Remove the app directory securely $install_dir/umount_disk.sh fi -#================================================= -# REMOVE NGINX HOOK -#================================================= - -#================================================= -# REMOVE NGINX CONFIGURATION -#================================================= -ynh_script_progression --message="Removing NGINX web server configuration..." - # Remove the dedicated NGINX config ynh_remove_nginx_config @@ -77,20 +55,9 @@ ynh_remove_nginx_config ynh_replace_string --replace_string="server_name $domain" --match_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 REMOVE -#================================================= -# REMOVE VARIOUS FILES -#================================================= -ynh_script_progression --message="Removing various files..." - # Remove the log files ynh_secure_remove --file="/var/log/$app" -#================================================= -# GENERIC FINALIZATION -#================================================= - ynh_secure_remove --file="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx @@ -98,4 +65,4 @@ yunohost tools regen-conf nginx # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" --last diff --git a/scripts/restore b/scripts/restore index 82d142d..eea021b 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,8 +24,6 @@ chown -R $app:$app "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." -mkdir -p "$data_dir/data" - if [[ "$system_is_inside_container" == "true" ]] then # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. @@ -33,25 +31,9 @@ then $install_dir/mount_disk.sh true fi - -# # FIXME: this should be managed by the core in the future -# Here, as a packager, you may have to tweak the ownerhsip/permissions -# such that the appropriate users (e.g. maybe www-data) can access -# files in some cases. -# But FOR THE LOVE OF GOD, do not allow r/x for "others" on the entire folder - -# this will be treated as a security issue. -chmod 750 "$data_dir" chmod -R o-rwx "$data_dir" chown -R $app:$app "$data_dir" -#================================================= -# SPECIFIC RESTORATION -#================================================= - -# Open the port - ynh_script_progression --message="Configuring firewall..." - ynh_exec_warn_less yunohost firewall allow TCP $port - #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= @@ -63,26 +45,11 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx -#================================================= -# RESTORE SYSTEMD -#================================================= -ynh_script_progression --message="Restoring the systemd configuration..." - ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable $app.service --quiet -#================================================= -# RESTORE THE LOGROTATE CONFIGURATION -#================================================= -ynh_script_progression --message="Restoring the logrotate configuration..." - ynh_restore_file --origin_path="/etc/logrotate.d/$app" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.log" --needs_exposed_ports $port #================================================= @@ -93,7 +60,8 @@ ynh_script_progression --message="Starting a systemd service..." #recreate log folder mkdir /var/log/$app -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" + #================================================= # RECREATE CONFIGURATION #================================================= @@ -111,12 +79,13 @@ if [ -n "$bootstrap_peers" ] then garage_connect "$garage_command" "$bootstrap_peers" fi + #================================================= # GENERIC FINALIZATION #================================================= # RELOAD NGINX AND PHP-FPM #================================================= -ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..." +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 bc5deea..166be47 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -22,7 +22,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Stopping a systemd service..." -ynh_systemd_action --service_name=$app --action="stop" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE @@ -48,33 +48,17 @@ ynh_add_nginx_config ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" yunohost tools regen-conf nginx -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - # Create a dedicated systemd config ynh_add_systemd_config -#================================================= -# GENERIC FINALIZATION -#================================================= -# SETUP LOGROTATE -#================================================= -ynh_script_progression --message="Upgrading logrotate configuration..." - # Use logrotate to manage app-specific logfile(s) ynh_use_logrotate --non-append -ynh_script_progression --message="Updating a configuration file..." - #================================================= # UPDATE A CONFIG FILE #================================================= -### Same as during install -### -### The file will automatically be backed-up if it's found to be manually modified (because -### ynh_add_config keeps track of the file's checksum) +ynh_script_progression --message="Updating a configuration file..." + ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" #================================================= @@ -89,10 +73,10 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l #================================================= ynh_script_progression --message="Starting a systemd service..." -ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" #================================================= # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" --last From 1bb15265aa325d745911cd5767ce76ad5a443b59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:15:10 +0100 Subject: [PATCH 60/88] Delete updater.sh --- .github/workflows/updater.sh | 137 ----------------------------------- 1 file changed, 137 deletions(-) delete mode 100755 .github/workflows/updater.sh diff --git a/.github/workflows/updater.sh b/.github/workflows/updater.sh deleted file mode 100755 index 72eb5cb..0000000 --- a/.github/workflows/updater.sh +++ /dev/null @@ -1,137 +0,0 @@ -#!/bin/bash - -#================================================= -# PACKAGE UPDATING HELPER -#================================================= - -# This script is meant to be run by GitHub Actions -# The YunoHost-Apps organisation offers a template Action to run this script periodically -# Since each app is different, maintainers can adapt its contents so as to perform -# automatic actions when a new upstream release is detected. - -# Remove this exit command when you are ready to run this Action -exit 1 - -#================================================= -# FETCHING LATEST RELEASE AND ITS ASSETS -#================================================= - -# Fetching information -current_version=$(cat manifest.json | jq -j '.version|split("~")[0]') -repo=$(cat manifest.json | jq -j '.upstream.code|split("https://github.com/")[1]') -# Some jq magic is needed, because the latest upstream release is not always the latest version (e.g. security patches for older versions) -version=$(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '.[] | select( .prerelease != true ) | .tag_name' | sort -V | tail -1) -assets=($(curl --silent "https://api.github.com/repos/$repo/releases" | jq -r '[ .[] | select(.tag_name=="'$version'").assets[].browser_download_url ] | join(" ") | @sh' | tr -d "'")) - -# Later down the script, we assume the version has only digits and dots -# Sometimes the release name starts with a "v", so let's filter it out. -# You may need more tweaks here if the upstream repository has different naming conventions. -if [[ ${version:0:1} == "v" || ${version:0:1} == "V" ]]; then - version=${version:1} -fi - -# Setting up the environment variables -echo "Current version: $current_version" -echo "Latest release from upstream: $version" -echo "VERSION=$version" >> $GITHUB_ENV -echo "REPO=$repo" >> $GITHUB_ENV -# For the time being, let's assume the script will fail -echo "PROCEED=false" >> $GITHUB_ENV - -# Proceed only if the retrieved version is greater than the current one -if ! dpkg --compare-versions "$current_version" "lt" "$version" ; then - echo "::warning ::No new version available" - exit 0 -# Proceed only if a PR for this new version does not already exist -elif git ls-remote -q --exit-code --heads https://github.com/$GITHUB_REPOSITORY.git ci-auto-update-v$version ; then - echo "::warning ::A branch already exists for this update" - exit 0 -fi - -# Each release can hold multiple assets (e.g. binaries for different architectures, source code, etc.) -echo "${#assets[@]} available asset(s)" - -#================================================= -# UPDATE SOURCE FILES -#================================================= - -# Here we use the $assets variable to get the resources published in the upstream release. -# Here is an example for Grav, it has to be adapted in accordance with how the upstream releases look like. - -# Let's loop over the array of assets URLs -for asset_url in ${assets[@]}; do - -echo "Handling asset at $asset_url" - -# Assign the asset to a source file in conf/ directory -# Here we base the source file name upon a unique keyword in the assets url (admin vs. update) -# Leave $src empty to ignore the asset -case $asset_url in - *"admin"*) - src="app" - ;; - *"update"*) - src="app-upgrade" - ;; - *) - src="" - ;; -esac - -# If $src is not empty, let's process the asset -if [ ! -z "$src" ]; then - -# Create the temporary directory -tempdir="$(mktemp -d)" - -# Download sources and calculate checksum -filename=${asset_url##*/} -curl --silent -4 -L $asset_url -o "$tempdir/$filename" -checksum=$(sha256sum "$tempdir/$filename" | head -c 64) - -# Delete temporary directory -rm -rf $tempdir - -# Get extension -if [[ $filename == *.tar.gz ]]; then - extension=tar.gz -else - extension=${filename##*.} -fi - -# Rewrite source file -cat < conf/$src.src -SOURCE_URL=$asset_url -SOURCE_SUM=$checksum -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=$extension -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= -EOT -echo "... conf/$src.src updated" - -else -echo "... asset ignored" -fi - -done - -#================================================= -# SPECIFIC UPDATE STEPS -#================================================= - -# Any action on the app's source code can be done. -# The GitHub Action workflow takes care of committing all changes after this script ends. - -#================================================= -# GENERIC FINALIZATION -#================================================= - -# Replace new version in manifest -echo "$(jq -s --indent 4 ".[] | .version = \"$version~ynh1\"" manifest.json)" > manifest.json - -# No need to update the README, yunohost-bot takes care of it - -# The Action will proceed only if the PROCEED environment variable is set to true -echo "PROCEED=true" >> $GITHUB_ENV -exit 0 From 63fc25dc6228f900a7e2ac085cbedc643833cf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:15:55 +0100 Subject: [PATCH 61/88] Update mount_disk.sh --- conf/mount_disk.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/mount_disk.sh b/conf/mount_disk.sh index 53f2acc..0c09ab1 100755 --- a/conf/mount_disk.sh +++ b/conf/mount_disk.sh @@ -18,6 +18,7 @@ then echo "formatting /dev/nbd$i" mkfs.ext4 /dev/nbd$i fi + mkdir -p $data_dir/data chown __APP__:__APP__ $data_dir/data mount /dev/nbd$i $data_dir/data/ fi From b2fb83a17b51a7375b0dacca8459099d5b9a58dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:16:52 +0100 Subject: [PATCH 62/88] Update tests.toml --- tests.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tests.toml b/tests.toml index 137a83f..a1a35da 100644 --- a/tests.toml +++ b/tests.toml @@ -11,4 +11,5 @@ test_format = 1.0 # ------------------------------- # Default args to use for install # ------------------------------- + args.weight = "10" From b8e80fc2398fe646b447414a52c182d02f253057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=CC=81ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sun, 10 Dec 2023 21:17:26 +0100 Subject: [PATCH 63/88] Update upgrade --- scripts/upgrade | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index acc63af..8206d81 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -20,7 +20,7 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." +ynh_script_progression --message="Stopping a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" @@ -30,7 +30,7 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." + ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" fi @@ -40,7 +40,7 @@ chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading NGINX web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config ynh_add_nginx_config @@ -59,14 +59,14 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l #================================================= # UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Updating a configuration file..." +ynh_script_progression --message="Updating a configuration file..." --weight=1 ynh_add_config --template="garage.toml" --destination="$install_dir/garage.toml" #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." +ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" From 81d57ee80292a946af0595505ea51346859b3d9e Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Mon, 11 Dec 2023 01:42:18 +0100 Subject: [PATCH 64/88] Reneable install tests because otherwise the CI cant test anything ... --- tests.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests.toml b/tests.toml index a1a35da..e68217c 100644 --- a/tests.toml +++ b/tests.toml @@ -6,7 +6,7 @@ test_format = 1.0 # Tests to run # ------------ - exclude = ["install.private", "install.root", "install.subdir", "install.multi"] + exclude = ["install.private"] # ------------------------------- # Default args to use for install From 6388d37dc936f467adee5eb3cc119b860a2c68b5 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 Dec 2023 18:47:53 +0100 Subject: [PATCH 65/88] Fix weird chmod --- scripts/install | 2 +- scripts/upgrade | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index d93896f..e765ec6 100755 --- a/scripts/install +++ b/scripts/install @@ -39,7 +39,7 @@ ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" -chmod +x $install_dir/garage +chmod 750 $install_dir #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 8206d81..e89eff1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -34,7 +34,7 @@ then ynh_setup_source --dest_dir="$install_dir" fi -chmod +x $install_dir/garage +chmod 750 $install_dir chown -R $app:$app "$install_dir" #================================================= From a6c4796499a0e9c3c31afbdfd648183d3ea109e0 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 Dec 2023 20:31:18 +0100 Subject: [PATCH 66/88] install: simplify node id loop, add stuff to be able to debug --- scripts/install | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index e765ec6..56f834e 100755 --- a/scripts/install +++ b/scripts/install @@ -115,14 +115,12 @@ garage_command="$install_dir/garage -c $install_dir/garage.toml" i=0 # sometimes server need some time to start -until [ "" != "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do +while [ -z "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ]; do i=$(( i + 1 )) - if [ $i -gt 30 ] - then - ynh_die --message="unable to get node id" - fi + [ $i -le 30 ] || { $garage_command node id || true; ynh_die --message="unable to get node id"; } sleep 1 done + node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) ynh_app_setting_set --app=$app --key=node_id --value=$node_id From d23d326476a4f0884f35d83ee4fd8acbd593195b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 Dec 2023 20:54:06 +0100 Subject: [PATCH 67/88] Tmp debug --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index 56f834e..46aa967 100755 --- a/scripts/install +++ b/scripts/install @@ -41,6 +41,9 @@ ynh_setup_source --dest_dir="$install_dir" chmod 750 $install_dir +# FIXME: Tmp debug +ynh_print_info --message="$(ls -l $install_dir)" + #================================================= # NGINX CONFIGURATION #================================================= From 8cb88725829331ca33b469f98bad1050a1f0065c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 15 Dec 2023 21:05:04 +0100 Subject: [PATCH 68/88] Fix source setup --- scripts/install | 6 +++--- scripts/upgrade | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 46aa967..b81e282 100755 --- a/scripts/install +++ b/scripts/install @@ -38,11 +38,11 @@ ynh_app_setting_set --app=$app --key=bootstrap_peers --value=$bootstrap_peers ynh_script_progression --message="Setting up source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" +mv $install_dir/main $install_dir/garage chmod 750 $install_dir - -# FIXME: Tmp debug -ynh_print_info --message="$(ls -l $install_dir)" +chmod +x $install_dir/garage +chown -R $app:$app "$install_dir" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index e89eff1..fd8c553 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -32,9 +32,11 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=1 ynh_setup_source --dest_dir="$install_dir" + mv $install_dir/main $install_dir/garage fi chmod 750 $install_dir +chmod +x $install_dir/garage chown -R $app:$app "$install_dir" #================================================= From e40686a13c451cdf33b8b04ab2336f106dc8de6b Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sat, 16 Dec 2023 20:59:36 +0100 Subject: [PATCH 69/88] fix test enough nodes --- scripts/_common.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 55ecd08..9bc28f6 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -43,13 +43,14 @@ apply_layout() { garage_command=$1 $garage_command layout show 2>/dev/null - local layout_version=$($garage_command layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) + if [ "$(./garage -c garage.toml layout show | grep 'This new layout cannot yet be applied')" ] if [ "$layout_version" != "" ] then - $garage_command layout apply --version $layout_version - else ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 + else + local layout_version=$($garage_command layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) + $garage_command layout apply --version $layout_version fi } From ced6335f6b57d3412e1b8e569f3a71b54eccfdfc Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sat, 16 Dec 2023 21:07:06 +0100 Subject: [PATCH 70/88] remove wrong line --- scripts/_common.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 9bc28f6..6e169e8 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -44,7 +44,6 @@ apply_layout() { garage_command=$1 $garage_command layout show 2>/dev/null if [ "$(./garage -c garage.toml layout show | grep 'This new layout cannot yet be applied')" ] - if [ "$layout_version" != "" ] then ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 From fcfe9758fd5b7c1767ee26044e06298aeb3131a4 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sat, 16 Dec 2023 21:17:12 +0100 Subject: [PATCH 71/88] use var for garage_command --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 6e169e8..c7497a5 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -43,7 +43,7 @@ apply_layout() { garage_command=$1 $garage_command layout show 2>/dev/null - if [ "$(./garage -c garage.toml layout show | grep 'This new layout cannot yet be applied')" ] + if [ "$($garage_command -c garage.toml layout show | grep 'This new layout cannot yet be applied')" ] then ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 From 2f7a656d4fdd68b40d11e5cf908af71575c65dc5 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Sun, 17 Dec 2023 09:22:57 +0100 Subject: [PATCH 72/88] fix layout show --- scripts/_common.sh | 2 +- scripts/install | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index c7497a5..74aedcc 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -43,7 +43,7 @@ apply_layout() { garage_command=$1 $garage_command layout show 2>/dev/null - if [ "$($garage_command -c garage.toml layout show | grep 'This new layout cannot yet be applied')" ] + if [ "$($garage_command layout show | grep 'This new layout cannot yet be applied')" ] then ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 diff --git a/scripts/install b/scripts/install index b81e282..99e25e6 100755 --- a/scripts/install +++ b/scripts/install @@ -140,7 +140,7 @@ fi self_bootstrap_peers="$($garage_command node id --quiet)" garage_layout="$($garage_command layout show)" -ynh_app_setting_set --app=$app --key=garage_layout --value=$garage_layout +ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout" #================================================= # END OF SCRIPT From f19c69c4ceb885dad90f2233c2259beeb06aea32 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Mon, 18 Dec 2023 16:40:50 +0100 Subject: [PATCH 73/88] add systemd startup test --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 99e25e6..b08fe05 100755 --- a/scripts/install +++ b/scripts/install @@ -107,7 +107,9 @@ yunohost service add $app --description="s3 storage" --log="/var/log/$app/$app.l ynh_script_progression --message="Starting a systemd service..." --weight=1 # Start a systemd service -ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" +ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --line_match="Started Garage: Data Store." + + #================================================= # CONFIGURE GARAGE From fb98b384033228358888455084eb9f7b2f6c0bad Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:37:05 +0100 Subject: [PATCH 74/88] Update scripts/install: workaround for nginx endpoint --- scripts/install | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/install b/scripts/install index b08fe05..d99b803 100755 --- a/scripts/install +++ b/scripts/install @@ -50,6 +50,15 @@ chown -R $app:$app "$install_dir" ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config +if [[ "${PACKAGE_CHECK_EXEC:-} -eq 1 ]] +then + cat << EOF > ../conf/nginx.conf +location / { + return 200 'This is a dummy page for garage, only displayed during tests on Yunohost CI' +} +EOF +fi + ynh_add_nginx_config #================================================= From ee92f4b95c95960e335d1bfa92c880f7ec267dea Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 19 Dec 2023 00:05:53 +0100 Subject: [PATCH 75/88] zgrmbl --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d99b803..dc4a3fb 100755 --- a/scripts/install +++ b/scripts/install @@ -50,7 +50,7 @@ chown -R $app:$app "$install_dir" ynh_script_progression --message="Configuring NGINX web server..." --weight=1 # Create a dedicated NGINX config -if [[ "${PACKAGE_CHECK_EXEC:-} -eq 1 ]] +if [[ "${PACKAGE_CHECK_EXEC:-}" -eq 1 ]] then cat << EOF > ../conf/nginx.conf location / { From ef1b1f184814f3262394bf5c9b86006d721a0aaa Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 19 Dec 2023 01:13:15 +0100 Subject: [PATCH 76/88] zgrmbl --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index dc4a3fb..9478dfc 100755 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,7 @@ if [[ "${PACKAGE_CHECK_EXEC:-}" -eq 1 ]] then cat << EOF > ../conf/nginx.conf location / { - return 200 'This is a dummy page for garage, only displayed during tests on Yunohost CI' + return 200 'This is a dummy page for garage, only displayed during tests on Yunohost CI'; } EOF fi From e9ca0f074a21369f01c5c1d28ffb36fcedaf45fb Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 01:22:02 +0100 Subject: [PATCH 77/88] Attempt to fix config panel ... --- config_panel.toml | 2 +- scripts/config | 24 +++--------------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 9375c6b..8a9db1c 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -19,7 +19,7 @@ version = "1.0" ask = "allocated space (Gio)" help = "This value is doubled used by yunohost. It set the weight of the garage node and if virtualisation is enabled, it create a virtual disk with the same size" type = "number" - bind = "weight()" + bind = "null" [main.garage_conf.bootstrap_peers] ask = "Friend serveur adress" diff --git a/scripts/config b/scripts/config index f96b00b..61950b5 100644 --- a/scripts/config +++ b/scripts/config @@ -1,31 +1,18 @@ #!/bin/bash -#================================================= -# GENERIC STARTING -#================================================= -# IMPORT GENERIC HELPERS -#================================================= source _common.sh source /usr/share/yunohost/helpers -ynh_abort_if_errors - #================================================= # RETRIEVE ARGUMENTS #================================================= -final_path=$(ynh_app_setting_get $app final_path) -node_id=$(ynh_app_setting_get $app node_id) -datadir=$(ynh_app_setting_get $app datadir) if [[ "$system_is_inside_container" == "true" ]] then - nbd_index=$(cat $datadir/nbd_index) + nbd_index=$(cat $data_dir/nbd_index) fi -command="$final_path/garage -c $final_path/garage.toml" -get__weight() { - ynh_app_setting_get --app=$app --key=weight -} +command="$install_dir/garage -c $install_dir/garage.toml" set__weight() { if [[ "$system_is_inside_container" == "true" ]] @@ -45,7 +32,7 @@ set__weight() { qemu-nbd --disconnect /dev/nbd$nbd_index qemu-img resize --shrink $datadir/garage_data.qcow2 "$weight"G fi - $final_path/umount_disk.sh + $install_dir/umount_disk.sh systemctl start $app sleep 3 fi @@ -55,11 +42,6 @@ set__weight() { } - -get__bootstrap_peers() { - ynh_app_setting_get --app=$app --key=bootstrap_peers -} - set__bootstrap_peers() { garage_connect "$command" "$bootstrap_peers" 2>/dev/null apply_layout "$command" From 50939cbc5ffd97eca068b4d1690aec982d0c8268 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 01:28:20 +0100 Subject: [PATCH 78/88] =?UTF-8?q?Attempt=20to=20fix=20config=20panel=20...?= =?UTF-8?q?=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config_panel.toml | 2 +- scripts/config | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config_panel.toml b/config_panel.toml index 8a9db1c..bf5a682 100644 --- a/config_panel.toml +++ b/config_panel.toml @@ -39,7 +39,7 @@ services = ["__APP__"] ask = "Choose/Change rpc secret" type = "string" redact = true - bind = "rpc_secret:/opt/yunohost/__APP__/garage.toml" + bind = "rpc_secret:__INSTALL_DIR__/garage.toml" pattern.regexp = '^[0-9a-f]{64}$' pattern.error = "rpc_secret have to be a 32-byte hex-encoded random string. See https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/ for more information" help = "Be careful if your node is already connected to a cluster, it won't be able to connect anymore if you change the rpc_secret value" diff --git a/scripts/config b/scripts/config index 61950b5..ebe614c 100644 --- a/scripts/config +++ b/scripts/config @@ -21,8 +21,8 @@ set__weight() { old_weight="$(ynh_app_setting_get --app=$app --key=weight)" if [ $old_weight -le $weight ] then - qemu-img resize $datadir/garage_data.qcow2 "$weight"G - qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage_data.qcow2 + qemu-img resize $data_dir/garage_data.qcow2 "$weight"G + qemu-nbd --connect /dev/nbd$nbd_index $data_dir/garage_data.qcow2 e2fsck -f -y /dev/nbd$nbd_index resize2fs /dev/nbd$nbd_index qemu-nbd --disconnect /dev/nbd$nbd_index @@ -30,7 +30,7 @@ set__weight() { e2fsck -f -y /dev/nbd0 resize2fs /dev/nbd$nbd_index $weightG qemu-nbd --disconnect /dev/nbd$nbd_index - qemu-img resize --shrink $datadir/garage_data.qcow2 "$weight"G + qemu-img resize --shrink $data_dir/garage_data.qcow2 "$weight"G fi $install_dir/umount_disk.sh systemctl start $app @@ -65,7 +65,7 @@ ask: $status" EOF -if [[ "$(echo \"$status\" | grep \"FAILED NODES\")" ]] || [[ "$(echo \"$status\" | grep 'garage layout show')" ]] +if echo "$status" | grep -q "FAILED NODES\|garage layout show" then cat << EOF style: "danger" From 50f8c5e316d12c9c6f4a7512b61a9528bc9dc1ff Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 01:57:31 +0100 Subject: [PATCH 79/88] Make system_is_inside_container a proper bash function --- conf/systemd.service | 2 +- scripts/_common.sh | 12 ++++++++---- scripts/config | 4 ++-- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/conf/systemd.service b/conf/systemd.service index 05f78ac..6e9ddf0 100644 --- a/conf/systemd.service +++ b/conf/systemd.service @@ -5,7 +5,7 @@ Wants=network-online.target [Service] User=__APP__ -Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__SYSTEM_IS_INSIDE_CONTAINER__' 'RUST_BACKTRACE=1' +Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__SYSTEM_IS_INSIDE_CONTAINER_BOOL__' 'RUST_BACKTRACE=1' ExecStartPre=+__INSTALL_DIR__/mount_disk.sh ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server ExecStopPost=+__INSTALL_DIR__/umount_disk.sh diff --git a/scripts/_common.sh b/scripts/_common.sh index 74aedcc..cbadbf1 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -6,13 +6,17 @@ GARAGE_VERSION="0.9.0" -if systemd-detect-virt -c -q +system_is_inside_container() { + systemd-detect-virt -c -q +} + +if system_is_inside_container then - system_is_inside_container="true" # used to comment systemd isolation to allow mount disk + system_is_inside_container_bool="true" comment_if_system_is_inside_container="#" else - system_is_inside_container="false" + system_is_inside_container_bool="false" comment_if_system_is_inside_container="" fi @@ -22,7 +26,7 @@ fi garage_connect() { local command="$1" - local peer="$2" + local peer="$2" # connect to cluster $command node connect "$peer" sleep 2 diff --git a/scripts/config b/scripts/config index ebe614c..0e8b3bf 100644 --- a/scripts/config +++ b/scripts/config @@ -7,7 +7,7 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= -if [[ "$system_is_inside_container" == "true" ]] +if system_is_inside_container then nbd_index=$(cat $data_dir/nbd_index) fi @@ -15,7 +15,7 @@ fi command="$install_dir/garage -c $install_dir/garage.toml" set__weight() { - if [[ "$system_is_inside_container" == "true" ]] + if system_is_inside_container then systemctl stop $app old_weight="$(ynh_app_setting_get --app=$app --key=weight)" diff --git a/scripts/install b/scripts/install index 9478dfc..74da92b 100755 --- a/scripts/install +++ b/scripts/install @@ -79,7 +79,7 @@ chown $app:$app "$install_dir/garage.toml" #================================================= ynh_script_progression --message="Creating a data directory..." --weight=5 -if [[ "$system_is_inside_container" == "true" ]] +if system_is_inside_container then ynh_print_warn --message="This may take time regarding disk size..." diff --git a/scripts/remove b/scripts/remove index c7210aa..d138caf 100755 --- a/scripts/remove +++ b/scripts/remove @@ -40,7 +40,7 @@ ynh_remove_systemd_config # Remove the app-specific logrotate config ynh_remove_logrotate -if [[ "$system_is_inside_container" == "true" ]] +if system_is_inside_container then ynh_script_progression --message="Umount virtual disk..." diff --git a/scripts/restore b/scripts/restore index 37f1510..cef70ba 100755 --- a/scripts/restore +++ b/scripts/restore @@ -24,7 +24,7 @@ chown -R $app:$app "$install_dir" #================================================= ynh_script_progression --message="Restoring the data directory..." -if [[ "$system_is_inside_container" == "true" ]] +if system_is_inside_container then # to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit size. qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G From d8317106210ea2a129869fd1156469af0fb06ead Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 02:04:51 +0100 Subject: [PATCH 80/88] Rename node_id to secret_node_id such as it gets redacted when sharing logs.. --- scripts/config | 5 ++++- scripts/install | 6 +++--- scripts/remove | 2 +- scripts/restore | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/config b/scripts/config index 0e8b3bf..d007180 100644 --- a/scripts/config +++ b/scripts/config @@ -7,6 +7,9 @@ source /usr/share/yunohost/helpers # RETRIEVE ARGUMENTS #================================================= +data_dir=$(ynh_app_setting_get $app data_dir) +secret_node_id=$(ynh_app_setting_get $app data_dir) + if system_is_inside_container then nbd_index=$(cat $data_dir/nbd_index) @@ -36,7 +39,7 @@ set__weight() { systemctl start $app sleep 3 fi - $command layout assign $node_id -c $weight 2>/dev/null + $command layout assign $secret_node_id -c $weight 2>/dev/null apply_layout "$command" ynh_app_setting_set --app=$app --key=weight --value=$weight } diff --git a/scripts/install b/scripts/install index 74da92b..4465505 100755 --- a/scripts/install +++ b/scripts/install @@ -135,12 +135,12 @@ while [ -z "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ]; do sleep 1 done -node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) -ynh_app_setting_set --app=$app --key=node_id --value=$node_id +secret_node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) +ynh_app_setting_set --app=$app --key=secret_node_id --value=$secret_node_id # define node -$garage_command layout assign $node_id -z $domain -c $weight -t $domain +$garage_command layout assign $secret_node_id -z $domain -c $weight -t $domain # if there is enough node, apply layout apply_layout "$garage_command" diff --git a/scripts/remove b/scripts/remove index d138caf..e6c5473 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,7 +13,7 @@ source /usr/share/yunohost/helpers # REMOVE NODE CONFIGURATION #================================================= -$install_dir/garage -c $install_dir/garage.toml layout remove "$node_id" +$install_dir/garage -c $install_dir/garage.toml layout remove "$secret_node_id" apply_layout "$install_dir/garage -c $install_dir/garage.toml " if [ $? -ne 0 ] diff --git a/scripts/restore b/scripts/restore index cef70ba..ddbebe5 100755 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ sleep 2 garage_command="$install_dir/garage -c $install_dir/garage.toml" # define node -$garage_command layout assign $node_id -z $domain -c $weight -t $domain +$garage_command layout assign $secret_node_id -z $domain -c $weight -t $domain # if there is enough node, apply layout apply_layout "$garage_command" From f472785ac606a869a760b38a1f2ed57f431b0dd8 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 03:10:04 +0100 Subject: [PATCH 81/88] Further simplify, homogeneize garage command call syntax --- scripts/_common.sh | 29 ++++++++++------------------- scripts/config | 16 +++++++--------- scripts/install | 18 ++++++++---------- scripts/remove | 4 ++-- scripts/restore | 8 +++----- 5 files changed, 30 insertions(+), 45 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index cbadbf1..42a7e66 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -24,15 +24,16 @@ fi # PERSONAL HELPERS #================================================= +garage="$install_dir/garage -c $install_dir/garage.toml" + garage_connect() { - local command="$1" - local peer="$2" + local peer="$1" # connect to cluster - $command node connect "$peer" + $garage node connect "$peer" sleep 2 # wait until layout is updated local i=0 - until $command layout show 2>/dev/null | grep "${peer:0:15}"; do + until $garage layout show 2>/dev/null | grep "${peer:0:15}"; do i=$(( i + 1 )) if [ $i -gt 30 ] then @@ -43,24 +44,14 @@ garage_connect() { } -apply_layout() { - - garage_command=$1 - $garage_command layout show 2>/dev/null - if [ "$($garage_command layout show | grep 'This new layout cannot yet be applied')" ] +garage_layout_apply() { + $garage layout show 2>/dev/null + if [ "$($garage layout show | grep 'This new layout cannot yet be applied')" ] then ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 else - local layout_version=$($garage_command layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) - $garage_command layout apply --version $layout_version + local layout_version=$($garage layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) + $garage layout apply --version $layout_version fi } - -#================================================= -# EXPERIMENTAL HELPERS -#================================================= - -#================================================= -# FUTURE OFFICIAL HELPERS -#================================================= diff --git a/scripts/config b/scripts/config index d007180..0b24848 100644 --- a/scripts/config +++ b/scripts/config @@ -10,13 +10,11 @@ source /usr/share/yunohost/helpers data_dir=$(ynh_app_setting_get $app data_dir) secret_node_id=$(ynh_app_setting_get $app data_dir) -if system_is_inside_container +if ! system_is_inside_container then nbd_index=$(cat $data_dir/nbd_index) fi -command="$install_dir/garage -c $install_dir/garage.toml" - set__weight() { if system_is_inside_container then @@ -39,29 +37,29 @@ set__weight() { systemctl start $app sleep 3 fi - $command layout assign $secret_node_id -c $weight 2>/dev/null - apply_layout "$command" + $garage layout assign $secret_node_id -c $weight 2>/dev/null + garage_layout_apply ynh_app_setting_set --app=$app --key=weight --value=$weight } set__bootstrap_peers() { - garage_connect "$command" "$bootstrap_peers" 2>/dev/null - apply_layout "$command" + garage_connect "$bootstrap_peers" 2>/dev/null + garage_layout_apply 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 + en: "**Node Id** : $($garage 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') +status=$($garage status 2> /dev/null | sed -E 's/([a-z0-9]{16})/\n**\1**/g') cat << EOF ask: en: "**Current garage layout**: \n diff --git a/scripts/install b/scripts/install index 4465505..eeafaad 100755 --- a/scripts/install +++ b/scripts/install @@ -125,32 +125,30 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" --l #================================================= ynh_script_progression --message="Configuring garage..." --weight=1 -garage_command="$install_dir/garage -c $install_dir/garage.toml" - i=0 # sometimes server need some time to start -while [ -z "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ]; do +while [ -z "$($garage node id -q 2>/dev/null | cut -d '@' -f1)" ]; do i=$(( i + 1 )) - [ $i -le 30 ] || { $garage_command node id || true; ynh_die --message="unable to get node id"; } + [ $i -le 30 ] || { $garage node id || true; ynh_die --message="unable to get node id"; } sleep 1 done -secret_node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1) +secret_node_id=$($garage node id -q 2>/dev/null | cut -d '@' -f1) ynh_app_setting_set --app=$app --key=secret_node_id --value=$secret_node_id # define node -$garage_command layout assign $secret_node_id -z $domain -c $weight -t $domain +$garage layout assign $secret_node_id -z $domain -c $weight -t $domain # if there is enough node, apply layout -apply_layout "$garage_command" +garage_layout_apply if [ -n "$bootstrap_peers" ] then - garage_connect "$garage_command" "$bootstrap_peers" + garage_connect "$bootstrap_peers" fi -self_bootstrap_peers="$($garage_command node id --quiet)" -garage_layout="$($garage_command layout show)" +self_bootstrap_peers="$($garage node id --quiet)" +garage_layout="$($garage layout show)" ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout" #================================================= diff --git a/scripts/remove b/scripts/remove index e6c5473..50cab65 100755 --- a/scripts/remove +++ b/scripts/remove @@ -13,9 +13,9 @@ source /usr/share/yunohost/helpers # REMOVE NODE CONFIGURATION #================================================= -$install_dir/garage -c $install_dir/garage.toml layout remove "$secret_node_id" +$garage layout remove "$secret_node_id" -apply_layout "$install_dir/garage -c $install_dir/garage.toml " +garage_layout_apply if [ $? -ne 0 ] then ynh_print_warn --message="Unable to remove the node. Maybe the number of node staying alive is not enough" diff --git a/scripts/restore b/scripts/restore index ddbebe5..4062cf3 100755 --- a/scripts/restore +++ b/scripts/restore @@ -67,16 +67,14 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" sleep 2 -garage_command="$install_dir/garage -c $install_dir/garage.toml" - # define node -$garage_command layout assign $secret_node_id -z $domain -c $weight -t $domain +$garage layout assign $secret_node_id -z $domain -c $weight -t $domain # if there is enough node, apply layout -apply_layout "$garage_command" +garage_layout_apply if [ -n "$bootstrap_peers" ] then - garage_connect "$garage_command" "$bootstrap_peers" + garage_connect "$bootstrap_peers" fi #================================================= From 4974d91302ca74985d53e865e222dee63dcf689b Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 03:12:51 +0100 Subject: [PATCH 82/88] 'if [[ $(command) ]]' probably doesnt mean what you think it means --- scripts/_common.sh | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 42a7e66..b99be04 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -35,10 +35,7 @@ garage_connect() { local i=0 until $garage layout show 2>/dev/null | grep "${peer:0:15}"; do i=$(( i + 1 )) - if [ $i -gt 30 ] - then - ynh_die --message="Unable to get layout from remote peer" - fi + [ $i -le 30 ] || ynh_die --message="Unable to get layout from remote peer" sleep 1 done } @@ -46,12 +43,12 @@ garage_connect() { garage_layout_apply() { $garage layout show 2>/dev/null - if [ "$($garage layout show | grep 'This new layout cannot yet be applied')" ] + if $garage layout show | grep -q 'This new layout cannot yet be applied' then ynh_print_warn --message="Unable to apply layout. No enough nodes" return 0 - else - local layout_version=$($garage layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) - $garage layout apply --version $layout_version - fi + fi + + local layout_version=$($garage layout show 2>/dev/null | grep -Po -- "(?<=--version).*" | head -1 | xargs) + $garage layout apply --version $layout_version } From 53cecfdff563309695e6ceb82297759cbca69717 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 19 Dec 2023 03:17:11 +0100 Subject: [PATCH 83/88] Apply nginx workaround for upgrade too --- scripts/change_url | 9 +++++++++ scripts/upgrade | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/scripts/change_url b/scripts/change_url index 3a9b28d..25eb04a 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -23,6 +23,15 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path="systemd" #================================================= ynh_script_progression --message="Updating NGINX web server configuration..." --weight=1 +if [[ "${PACKAGE_CHECK_EXEC:-}" -eq 1 ]] +then + cat << EOF > ../conf/nginx.conf +location / { + return 200 'This is a dummy page for garage, only displayed during tests on Yunohost CI'; +} +EOF +fi + ynh_change_url_nginx_config #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fd8c553..8be55b1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -45,6 +45,14 @@ chown -R $app:$app "$install_dir" ynh_script_progression --message="Upgrading NGINX web server configuration..." --weight=1 # Create a dedicated NGINX config +if [[ "${PACKAGE_CHECK_EXEC:-}" -eq 1 ]] +then + cat << EOF > ../conf/nginx.conf +location / { + return 200 'This is a dummy page for garage, only displayed during tests on Yunohost CI'; +} +EOF +fi ynh_add_nginx_config ynh_add_config --template="regenconf_nginx_garage" --destination="/usr/share/yunohost/hooks/conf_regen/98-nginx_$app" From 728fa923b5ee38ca00a8e178547fcf92cd4e630d Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 19 Dec 2023 10:44:07 +0100 Subject: [PATCH 84/88] add setting for self bootstrap peer --- scripts/install | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/install b/scripts/install index eeafaad..3f65675 100755 --- a/scripts/install +++ b/scripts/install @@ -149,6 +149,11 @@ fi self_bootstrap_peers="$($garage node id --quiet)" garage_layout="$($garage layout show)" + +self_bootstrap_peers="$($garage_command node id --quiet)" +ynh_app_setting_set --app=$app --key=self_bootstrap_peers --value="$self_bootstrap_peers" + +garage_layout="$($garage_command layout show)" ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout" #================================================= From 90980267781e7c801692bf924a58c34c1d1509b8 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 19 Dec 2023 10:43:13 +0100 Subject: [PATCH 85/88] Revert "add setting for self bootstrap peer" This reverts commit 556cadf284737d66f8a010d95a0fe92a0e86d0a6. --- scripts/install | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3f65675..3b94821 100755 --- a/scripts/install +++ b/scripts/install @@ -151,8 +151,6 @@ self_bootstrap_peers="$($garage node id --quiet)" garage_layout="$($garage layout show)" self_bootstrap_peers="$($garage_command node id --quiet)" -ynh_app_setting_set --app=$app --key=self_bootstrap_peers --value="$self_bootstrap_peers" - garage_layout="$($garage_command layout show)" ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout" From ee4f09ee549861cf0471e6731194fcd123d8bb2f Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 19 Dec 2023 10:46:50 +0100 Subject: [PATCH 86/88] add units to capacity --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3b94821..4c321b8 100755 --- a/scripts/install +++ b/scripts/install @@ -138,7 +138,7 @@ ynh_app_setting_set --app=$app --key=secret_node_id --value=$secret_node_id # define node -$garage layout assign $secret_node_id -z $domain -c $weight -t $domain +$garage layout assign $secret_node_id -z $domain -c ${weight}GB -t $domain # if there is enough node, apply layout garage_layout_apply From 47a48d3a12cf9ed25cfab162ee6a3b84009c0f93 Mon Sep 17 00:00:00 2001 From: oiseauroch Date: Tue, 19 Dec 2023 13:31:33 +0100 Subject: [PATCH 87/88] change node id --- scripts/install | 3 --- scripts/restore | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 4c321b8..10555e6 100755 --- a/scripts/install +++ b/scripts/install @@ -149,9 +149,6 @@ fi self_bootstrap_peers="$($garage node id --quiet)" garage_layout="$($garage layout show)" - -self_bootstrap_peers="$($garage_command node id --quiet)" -garage_layout="$($garage_command layout show)" ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout" #================================================= diff --git a/scripts/restore b/scripts/restore index 4062cf3..cb4c7d1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -65,10 +65,21 @@ ynh_systemd_action --service_name=$app --action="start" --log_path="systemd" # RECREATE CONFIGURATION #================================================= -sleep 2 +i=0 +# sometimes server need some time to start +while [ -z "$($garage node id -q 2>/dev/null | cut -d '@' -f1)" ]; do + i=$(( i + 1 )) + [ $i -le 30 ] || { $garage node id || true; ynh_die --message="unable to get node id"; } + sleep 1 +done + +# restoring garage can lead to change node id +secret_node_id=$($garage node id -q 2>/dev/null | cut -d '@' -f1) +ynh_app_setting_set --app=$app --key=secret_node_id --value=$secret_node_id + # define node -$garage layout assign $secret_node_id -z $domain -c $weight -t $domain +$garage layout assign $secret_node_id -z $domain -c ${weight}GB -t $domain # if there is enough node, apply layout garage_layout_apply From c3bf3226330726f06f339e8cfc2ba872d79bbfc6 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin <4533074+alexAubin@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:11:26 +0100 Subject: [PATCH 88/88] Gotta save self_bootstrap_peers as setting if we want to use it in POST_INSTALL message --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 10555e6..762cc18 100755 --- a/scripts/install +++ b/scripts/install @@ -148,6 +148,7 @@ then fi self_bootstrap_peers="$($garage node id --quiet)" +ynh_app_setting_set --app=$app --key=self_bootstrap_peers --value=$self_bootstrap_peers garage_layout="$($garage layout show)" ynh_app_setting_set --app=$app --key=garage_layout --value="$garage_layout"