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:
parent
50939cbc5f
commit
50f8c5e316
6 changed files with 14 additions and 10 deletions
|
@ -5,7 +5,7 @@ Wants=network-online.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=__APP__
|
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
|
ExecStartPre=+__INSTALL_DIR__/mount_disk.sh
|
||||||
ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server
|
ExecStart=__INSTALL_DIR__/garage -c __INSTALL_DIR__/garage.toml server
|
||||||
ExecStopPost=+__INSTALL_DIR__/umount_disk.sh
|
ExecStopPost=+__INSTALL_DIR__/umount_disk.sh
|
||||||
|
|
|
@ -6,13 +6,17 @@
|
||||||
|
|
||||||
GARAGE_VERSION="0.9.0"
|
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
|
then
|
||||||
system_is_inside_container="true"
|
|
||||||
# used to comment systemd isolation to allow mount disk
|
# used to comment systemd isolation to allow mount disk
|
||||||
|
system_is_inside_container_bool="true"
|
||||||
comment_if_system_is_inside_container="#"
|
comment_if_system_is_inside_container="#"
|
||||||
else
|
else
|
||||||
system_is_inside_container="false"
|
system_is_inside_container_bool="false"
|
||||||
comment_if_system_is_inside_container=""
|
comment_if_system_is_inside_container=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -22,7 +26,7 @@ fi
|
||||||
|
|
||||||
garage_connect() {
|
garage_connect() {
|
||||||
local command="$1"
|
local command="$1"
|
||||||
local peer="$2"
|
local peer="$2"
|
||||||
# connect to cluster
|
# connect to cluster
|
||||||
$command node connect "$peer"
|
$command node connect "$peer"
|
||||||
sleep 2
|
sleep 2
|
||||||
|
|
|
@ -7,7 +7,7 @@ source /usr/share/yunohost/helpers
|
||||||
# RETRIEVE ARGUMENTS
|
# RETRIEVE ARGUMENTS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if [[ "$system_is_inside_container" == "true" ]]
|
if system_is_inside_container
|
||||||
then
|
then
|
||||||
nbd_index=$(cat $data_dir/nbd_index)
|
nbd_index=$(cat $data_dir/nbd_index)
|
||||||
fi
|
fi
|
||||||
|
@ -15,7 +15,7 @@ fi
|
||||||
command="$install_dir/garage -c $install_dir/garage.toml"
|
command="$install_dir/garage -c $install_dir/garage.toml"
|
||||||
|
|
||||||
set__weight() {
|
set__weight() {
|
||||||
if [[ "$system_is_inside_container" == "true" ]]
|
if system_is_inside_container
|
||||||
then
|
then
|
||||||
systemctl stop $app
|
systemctl stop $app
|
||||||
old_weight="$(ynh_app_setting_get --app=$app --key=weight)"
|
old_weight="$(ynh_app_setting_get --app=$app --key=weight)"
|
||||||
|
|
|
@ -79,7 +79,7 @@ chown $app:$app "$install_dir/garage.toml"
|
||||||
#=================================================
|
#=================================================
|
||||||
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" ]]
|
if system_is_inside_container
|
||||||
then
|
then
|
||||||
ynh_print_warn --message="This may take time regarding disk size..."
|
ynh_print_warn --message="This may take time regarding disk size..."
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ ynh_remove_systemd_config
|
||||||
# Remove the app-specific logrotate config
|
# Remove the app-specific logrotate config
|
||||||
ynh_remove_logrotate
|
ynh_remove_logrotate
|
||||||
|
|
||||||
if [[ "$system_is_inside_container" == "true" ]]
|
if system_is_inside_container
|
||||||
then
|
then
|
||||||
ynh_script_progression --message="Umount virtual disk..."
|
ynh_script_progression --message="Umount virtual disk..."
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ chown -R $app:$app "$install_dir"
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring the data directory..."
|
ynh_script_progression --message="Restoring the data directory..."
|
||||||
|
|
||||||
if [[ "$system_is_inside_container" == "true" ]]
|
if system_is_inside_container
|
||||||
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 $data_dir/garage_data.qcow2 "$weight"G
|
qemu-img create -f qcow2 $data_dir/garage_data.qcow2 "$weight"G
|
||||||
|
|
Loading…
Add table
Reference in a new issue