1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/garage_ynh.git synced 2024-09-03 18:36:32 +02:00
* add delay for node id

* remove unused ip value
fix i not defined

* fix script

* Auto-update README

---------

Co-authored-by: yunohost-bot <yunohost@yunohost.org>
This commit is contained in:
oiseauroch 2023-02-24 15:41:36 +00:00 committed by GitHub
parent 6a3754e3f8
commit 7cbe56b685
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 38 additions and 33 deletions

View file

@ -35,11 +35,12 @@ Garage is designed for storage clusters composed of nodes running at different p
- K2V API (experimental) - K2V API (experimental)
**Shipped version:** 0.8.0~ynh2 **Shipped version:** 0.8.0~ynh3
## Disclaimers / important information ## Disclaimers / important information
* Limitations : * Limitations :
* This application is not usable if you're not part of a cluster with minimun 3 other nodes * 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: * 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 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.

View file

@ -35,11 +35,12 @@ Garage is designed for storage clusters composed of nodes running at different p
- K2V API (experimental) - K2V API (experimental)
**Version incluse :** 0.8.0~ynh2 **Version incluse :** 0.8.0~ynh3
## Avertissements / informations importantes ## Avertissements / informations importantes
* Limitations : * Limitations :
* This application is not usable if you're not part of a cluster with minimun 3 other nodes * 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: * 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 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.

View file

@ -17,5 +17,8 @@ then
mkfs.ext4 /dev/nbd$i mkfs.ext4 /dev/nbd$i
fi fi
mkdir -p $datadir/data mkdir -p $datadir/data
chown __APP__:__APP__ $datadir/data
mount /dev/nbd$i $datadir/data/ mount /dev/nbd$i $datadir/data/
fi fi

View file

@ -1,5 +1,6 @@
* Limitations : * Limitations :
* This application is not usable if you're not part of a cluster with minimun 3 other nodes * 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: * 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 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.

View file

@ -6,7 +6,7 @@
"en": "S3 storage", "en": "S3 storage",
"fr": "stockage S3" "fr": "stockage S3"
}, },
"version": "0.8.0~ynh2", "version": "0.8.0~ynh3",
"url": "https://garagehq.deuxfleurs.fr/", "url": "https://garagehq.deuxfleurs.fr/",
"upstream": { "upstream": {
"license": "AGPL-3.0-only", "license": "AGPL-3.0-only",

View file

@ -12,9 +12,6 @@ pkg_dependencies_virtualisation="qemu-utils e2fsprogs"
GARAGE_VERSION="0.8.0" GARAGE_VERSION="0.8.0"
get_ip() {
curl ip.me
}
# inspired by restic helper # inspired by restic helper
install_garage () { install_garage () {
architecture=$(uname -m) architecture=$(uname -m)

View file

@ -18,7 +18,7 @@ final_path=$(ynh_app_setting_get $app final_path)
node_id=$(ynh_app_setting_get $app node_id) node_id=$(ynh_app_setting_get $app node_id)
virtualisation=$(ynh_app_setting_get $app virtualisation) virtualisation=$(ynh_app_setting_get $app virtualisation)
datadir=$(ynh_app_setting_get $app datadir) 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" command="$final_path/garage -c $final_path/garage.toml"
get__weight() { get__weight() {
@ -28,26 +28,24 @@ get__weight() {
set__weight() { set__weight() {
if [ "$virtualisation" = "true" ] if [ "$virtualisation" = "true" ]
then then
systemctl stop $YNH_APP_INSTANCE_NAME systemctl stop $app
old_weight="$ynh_app_setting_get --app=$app --key=weight" old_weight="$(ynh_app_setting_get --app=$app --key=weight)"
if [ $old_weight -le $weight } if [ $old_weight -le $weight ]
then then
$final_path/umount_disk.sh $nbd_index qemu-img resize $datadir/garage_data.qcow2 "$weight"G
qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage_data.qcow2
qemu-nbd --connect /dev/nbd$nbd_index $datadir/garage.qcow2 e2fsck -f -y /dev/nbd$nbd_index
e2fsck -f /dev/nbd$nbd_index
resize2fs /dev/nbd$nbd_index resize2fs /dev/nbd$nbd_index
mount /dev/nbd$nbd_index $datadir/data/ qemu-nbd --disconnect /dev/nbd$nbd_index
else else
umount /dev/nbd$nbd_index e2fsck -f -y /dev/nbd0
e2fsck -f /dev/nbd$nbd_index
resize2fs /dev/nbd$nbd_index $weightG resize2fs /dev/nbd$nbd_index $weightG
qemu-nbd --disconnect /dev/nbd$nbd_index qemu-nbd --disconnect /dev/nbd$nbd_index
qemu-img resize $datadir/$datadir/garage_data.qcow2 $weightG qemu-img resize --shrink $datadir/garage_data.qcow2 "$weight"G
$nbd_index=$(final_path/mount_disk.sh false)
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
fi fi
systemctl start $YNH_APP_INSTANCE_NAME $final_path/umount_disk.sh
systemctl start $app
sleep 3
fi fi
$command layout assign $node_id -c $weight 2>/dev/null $command layout assign $node_id -c $weight 2>/dev/null
apply_layout "$command" apply_layout "$command"
@ -55,6 +53,7 @@ set__weight() {
} }
get__bootstrap_peers() { get__bootstrap_peers() {
ynh_app_setting_get --app=$app --key=bootstrap_peers ynh_app_setting_get --app=$app --key=bootstrap_peers
} }

View file

@ -24,10 +24,6 @@ ynh_abort_if_errors
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
#port mandatory for garage
ip=$(get_ip)
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
rpc_secret=$YNH_APP_ARG_RPC_SECRET rpc_secret=$YNH_APP_ARG_RPC_SECRET
bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS bootstrap_peers=$YNH_APP_ARG_BOOTSTRAP_PEERS
@ -253,8 +249,11 @@ chown $app:$app "$final_path/garage.toml"
#================================================= #=================================================
# CREATE DATA DIRECTORY # 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. ### 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 ### 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. ### 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" 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 # sometimes server need some time to start
if [ -n "$node_id" ] until [ "" != "$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)" ] ; do
i=$(( i + 1 ))
if [ $i -gt 30 ]
then then
sleep 5 ynh_die --message="unable to get node id"
node_id=$($garage_command node id -q 2>/dev/null | cut -d '@' -f1)
fi 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 ynh_app_setting_set --app=$app --key=node_id --value=$node_id