This commit is contained in:
oiseauroch 2022-11-30 11:59:12 +01:00
parent 94188611cf
commit 81776945bb
6 changed files with 9 additions and 13 deletions

View File

@ -8,7 +8,7 @@ then
do do
i=$(( i + 1 )) i=$(( i + 1 ))
done done
echo $i echo $i > $datadir/nbd_index
modprobe nbd max_part=$(( i + 1 )) modprobe nbd max_part=$(( i + 1 ))
qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2 qemu-nbd --connect /dev/nbd$i $datadir/garage_data.qcow2
if [[ "$format" = "true" ]] if [[ "$format" = "true" ]]

View File

@ -8,7 +8,7 @@ User=__APP__
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1' Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1'
ExecStartPre=+__FINALPATH__/mount_disk.sh ExecStartPre=+__FINALPATH__/mount_disk.sh
ExecStart=__FINALPATH__/garage -c __FINALPATH__/garage.toml server ExecStart=__FINALPATH__/garage -c __FINALPATH__/garage.toml server
ExecStopPost=+__FINALPATH__/umount_disk.sh __NBD_INDEX__ ExecStopPost=+__FINALPATH__/umount_disk.sh
WorkingDirectory=__FINALPATH__/ WorkingDirectory=__FINALPATH__/
StandardOutput=append:/var/log/__APP__/__APP__.log StandardOutput=append:/var/log/__APP__/__APP__.log
StandardError=inherit StandardError=inherit

View File

@ -1,7 +1,8 @@
#!/bin/bash #!/bin/bash
if [ "$VIRTUALISATION" = "true" ] if [ "$VIRTUALISATION" = "true" ]
then then
nbd=$1 datadir=__DATADIR__
nbd=$(cat $datadir/nbd_index)
umount /dev/nbd$nbd umount /dev/nbd$nbd
qemu-nbd --disconnect /dev/nbd$nbd qemu-nbd --disconnect /dev/nbd$nbd
fi fi

View File

@ -130,8 +130,6 @@ ynh_app_setting_set --app=$app --key=port --value=$port
port_api=$(ynh_find_port --port=5000) port_api=$(ynh_find_port --port=5000)
ynh_app_setting_set --app=$app --key=port_api --value=$port_api ynh_app_setting_set --app=$app --key=port_api --value=$port_api
nbd_index=127
# Optional: Expose this port publicly # Optional: Expose this port publicly
# (N.B.: you only need to do this if the app actually needs to expose the port publicly. # (N.B.: you only need to do this if the app actually needs to expose the port publicly.
@ -273,8 +271,7 @@ if [ "$virtualisation" = "true" ]
then then
# to be sure to not exceed size limit, i use a virtual disk with a fix size to have a max limit 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 $datadir/garage_data.qcow2 "$weight"G qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G
nbd_index=$($final_path/mount_disk.sh true) $final_path/mount_disk.sh true
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
fi fi
# FIXME: this should be managed by the core in the future # FIXME: this should be managed by the core in the future
@ -289,7 +286,7 @@ chown -R $app:$app "$datadir"
if [ "$virtualisation" = "true" ] if [ "$virtualisation" = "true" ]
then then
$final_path/umount_disk.sh $nbd_index $final_path/umount_disk.sh
fi fi
#================================================= #=================================================

View File

@ -28,7 +28,6 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path)
virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation) virtualisation=$(ynh_app_setting_get --app=$app --key=virtualisation)
if [ "$virtualisation" = "true" ] if [ "$virtualisation" = "true" ]
then then
nbd_index=$(ynh_app_setting_get --app=$app --key=nbd_index)
export VIRTUALISTATION=true export VIRTUALISTATION=true
fi fi
#================================================= #=================================================
@ -81,7 +80,7 @@ then
ynh_script_progression --message="umount virtual disk..." --weight=1 ynh_script_progression --message="umount virtual disk..." --weight=1
# Remove the app directory securely # Remove the app directory securely
$final_path/umount_disk.sh $nbd_index $final_path/umount_disk.sh
fi fi
#================================================= #=================================================
# REMOVE APP MAIN DIR # REMOVE APP MAIN DIR

View File

@ -83,12 +83,11 @@ then
ynh_install_app_dependencies $pkg_dependencies_virtualisation 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. # 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 qemu-img create -f qcow2 $datadir/garage_data.qcow2 "$weight"G
nbd_index=$($final_path/mount_disk.sh "$datadir" true) $final_path/mount_disk.sh true
ynh_app_setting_set --app=$app --key=nbd_index --value=$nbd_index
fi fi
# FIXME: this should be managed by the core in the future # # FIXME: this should be managed by the core in the future
# Here, as a packager, you may have to tweak the ownerhsip/permissions # Here, as a packager, you may have to tweak the ownerhsip/permissions
# such that the appropriate users (e.g. maybe www-data) can access # such that the appropriate users (e.g. maybe www-data) can access
# files in some cases. # files in some cases.