mirror of
https://github.com/YunoHost-Apps/garage_ynh.git
synced 2024-09-03 18:36:32 +02:00
Clarify the confusing 'virtualisation' variable thingies ...
This commit is contained in:
parent
490814db06
commit
db6def2d96
8 changed files with 34 additions and 53 deletions
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
if [ "$VIRTUALISATION" = "true" ]
|
||||
|
||||
# If we're inside a container
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
data_dir=__DATA_DIR__
|
||||
format=$1
|
||||
|
|
|
@ -5,7 +5,7 @@ Wants=network-online.target
|
|||
|
||||
[Service]
|
||||
User=__APP__
|
||||
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__VIRTUALISATION__' 'RUST_BACKTRACE=1'
|
||||
Environment='RUST_LOG=garage=info' 'VIRTUALISATION=__SYSTEM_IS_INSIDE_CONTAINER__' '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
|
||||
|
@ -17,16 +17,16 @@ StandardError=inherit
|
|||
# Depending on specificities of your service/app, you may need to tweak these
|
||||
# .. but this should be a good baseline
|
||||
# Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
|
||||
__VIRT_PROTECTION__PrivateTmp=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__PrivateTmp=yes
|
||||
#PrivateDevices=yes
|
||||
# RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
RestrictNamespaces=yes
|
||||
RestrictRealtime=yes
|
||||
#DevicePolicy=closed
|
||||
__VIRT_PROTECTION__ProtectSystem=full
|
||||
__VIRT_PROTECTION__ProtectControlGroups=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectSystem=full
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectControlGroups=yes
|
||||
#ProtectKernelModules=yes
|
||||
__VIRT_PROTECTION__ProtectKernelTunables=yes
|
||||
__COMMENT_IF_SYSTEM_IS_INSIDE_CONTAINER__ProtectKernelTunables=yes
|
||||
LockPersonality=yes
|
||||
SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/bin/bash
|
||||
if [ "$VIRTUALISATION" = "true" ]
|
||||
|
||||
# If we're inside a container
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
data_dir=__DATA_DIR__
|
||||
data_dir=__DATA_DIR__
|
||||
nbd=$(cat $data_dir/nbd_index)
|
||||
umount /dev/nbd$nbd
|
||||
qemu-nbd --disconnect /dev/nbd$nbd
|
||||
|
|
|
@ -4,27 +4,22 @@
|
|||
# COMMON VARIABLES
|
||||
#=================================================
|
||||
|
||||
GARAGE_VERSION="0.8.2"
|
||||
|
||||
if systemd-detect-virt -c -q
|
||||
then
|
||||
system_is_inside_container="true"
|
||||
# used to comment systemd isolation to allow mount disk
|
||||
comment_if_system_is_inside_container="#"
|
||||
else
|
||||
system_is_inside_container="false"
|
||||
comment_if_system_is_inside_container=""
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PERSONAL HELPERS
|
||||
#=================================================
|
||||
|
||||
systemd-detect-virt -c -q
|
||||
if [ $? ]
|
||||
then #system is inside a container,
|
||||
export VIRTUALISATION=true
|
||||
virtualisation=true
|
||||
# comment systemd isolation to allow mount disk
|
||||
virt_protection="#"
|
||||
else
|
||||
virtualisation=false
|
||||
export VIRTUALISATION=false
|
||||
# uncomment systemd isolation
|
||||
virt_protection=""
|
||||
fi
|
||||
|
||||
|
||||
GARAGE_VERSION="0.8.2"
|
||||
|
||||
garage_connect() {
|
||||
local command="$1"
|
||||
local peer="$2"
|
||||
|
|
|
@ -17,7 +17,7 @@ ynh_abort_if_errors
|
|||
final_path=$(ynh_app_setting_get $app final_path)
|
||||
node_id=$(ynh_app_setting_get $app node_id)
|
||||
datadir=$(ynh_app_setting_get $app datadir)
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
nbd_index=$(cat $datadir/nbd_index)
|
||||
fi
|
||||
|
@ -28,7 +28,7 @@ get__weight() {
|
|||
}
|
||||
|
||||
set__weight() {
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
systemctl stop $app
|
||||
old_weight="$(ynh_app_setting_get --app=$app --key=weight)"
|
||||
|
|
|
@ -66,26 +66,14 @@ chown $app:$app "$install_dir/garage.toml"
|
|||
#=================================================
|
||||
ynh_script_progression --message="Creating a data directory..." --weight=5
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
ynh_print_warn --message="This may take time regarding disk size…"
|
||||
fi
|
||||
ynh_print_warn --message="This may take time regarding disk size…"
|
||||
|
||||
#=================================================
|
||||
# create data partition
|
||||
#=================================================
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
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
|
||||
VIRTUALISATION=true $install_dir/mount_disk.sh true
|
||||
fi
|
||||
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
VIRTUALISATION=true $install_dir/umount_disk.sh
|
||||
$install_dir/mount_disk.sh true
|
||||
$install_dir/umount_disk.sh
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -13,11 +13,6 @@ source /usr/share/yunohost/helpers
|
|||
# LOAD SETTINGS
|
||||
#=================================================
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
then
|
||||
export VIRTUALISTATION=true
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# REMOVE NODE CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -60,7 +55,7 @@ ynh_script_progression --message="Removing logrotate configuration..." --weight
|
|||
ynh_remove_logrotate
|
||||
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
#=================================================
|
||||
# REMOVE VIRTUAL DISK
|
||||
|
|
|
@ -26,9 +26,8 @@ ynh_script_progression --message="Restoring the data directory..." --weight=1
|
|||
|
||||
mkdir -p "$data_dir/data"
|
||||
|
||||
if [ "$virtualisation" = "true" ]
|
||||
if [[ "$system_is_inside_container" == "true" ]]
|
||||
then
|
||||
export VIRTUALISATION=true
|
||||
# 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
|
||||
$install_dir/mount_disk.sh true
|
||||
|
|
Loading…
Add table
Reference in a new issue