From 7cbe56b68585ab7a48e130c32d87efc6a3758ff7 Mon Sep 17 00:00:00 2001 From: oiseauroch <5622590+oiseauroch@users.noreply.github.com> Date: Fri, 24 Feb 2023 15:41:36 +0000 Subject: [PATCH] Testing (#3) * add delay for node id * remove unused ip value fix i not defined * fix script * Auto-update README --------- Co-authored-by: yunohost-bot --- README.md | 3 ++- README_fr.md | 3 ++- conf/mount_disk.sh | 3 +++ doc/DISCLAIMER.md | 1 + manifest.json | 2 +- scripts/_common.sh | 3 --- scripts/config | 29 ++++++++++++++--------------- scripts/install | 27 +++++++++++++++------------ 8 files changed, 38 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index df41a66..b9abfb9 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,12 @@ 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 : * 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/README_fr.md b/README_fr.md index 31dc3fe..2f74e15 100644 --- a/README_fr.md +++ b/README_fr.md @@ -35,11 +35,12 @@ 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 : * 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/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/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/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", 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/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 } diff --git a/scripts/install b/scripts/install index a209175..0d5bd16 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 @@ -253,8 +249,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. @@ -403,13 +402,17 @@ 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) +i=0 # 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 +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 +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