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

Make system_is_inside_container a proper bash function

This commit is contained in:
Alexandre Aubin 2023-12-19 01:57:31 +01:00
parent 50939cbc5f
commit 50f8c5e316
6 changed files with 14 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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)"

View file

@ -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..."

View file

@ -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..."

View file

@ -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