2016-08-12 17:35:14 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2016-08-13 01:08:44 +02:00
|
|
|
# Stoppe les conteneurs de demo et arrête la config réseau dédiée.
|
|
|
|
|
2016-08-12 17:35:14 +02:00
|
|
|
# Récupère le dossier du script
|
2022-10-13 05:46:46 +02:00
|
|
|
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$(ynh_print_info --message=$PWD/$(dirname "$0" | cut -d '.' -f2) | sed 's@/$@@')"; fi
|
2016-08-12 17:35:14 +02:00
|
|
|
|
2022-10-13 05:46:46 +02:00
|
|
|
source $script_dir/ynh_lxd
|
|
|
|
source $script_dir/ynh_lxd_demo
|
|
|
|
source /usr/share/yunohost/helpers
|
|
|
|
|
|
|
|
app=${__APP__:-yunohost_demo}
|
|
|
|
final_path=$(ynh_app_setting_get --app=$app --key=final_path)
|
|
|
|
lxc_name1=$(ynh_app_setting_get --app=$app --key=lxc_name1)
|
|
|
|
lxc_name2=$(ynh_app_setting_get --app=$app --key=lxc_name2)
|
2016-08-12 17:35:14 +02:00
|
|
|
|
2016-09-18 19:23:54 +02:00
|
|
|
if [ "$#" -eq 1 ] && [ "$1" == "-f" ]
|
|
|
|
then
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_print_info --message="> Suppression des lock et arrêt forcé des conteneurs."
|
|
|
|
ynh_secure_remove --file="/var/lib/lxd/$lxc_name1.lock_fileS"
|
|
|
|
ynh_secure_remove --file="/var/lib/lxd/$lxc_name2.lock_fileS"
|
|
|
|
ynh_secure_remove --file="/var/lib/lxd/$lxc_name1.lock_fileU"
|
|
|
|
ynh_secure_remove --file="/var/lib/lxd/$lxc_name2.lock_fileU"
|
2016-09-18 19:23:54 +02:00
|
|
|
else
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_print_info --message="> Attend la libération des lock sur les conteneurs."
|
|
|
|
while test -e /var/lib/lxd/$lxc_name1.lock_file* || test -e /var/lib/lxd/$lxc_name2.lock_file*; do
|
2016-09-18 19:23:54 +02:00
|
|
|
sleep 5 # Attend que les conteneur soit libérés par les script upgrade ou switch, le cas échéant.
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_print_info --message="> Arrêt des conteneurs"
|
2022-10-15 02:43:00 +02:00
|
|
|
if ynh_lxc_exists --name=$lxc_name1
|
2022-10-13 05:46:46 +02:00
|
|
|
then
|
2022-10-15 02:43:00 +02:00
|
|
|
if ! ynh_lxc_is_stopped --name=$lxc_name1
|
|
|
|
then
|
|
|
|
ynh_print_info --message="Arrêt du conteneur $lxc_name1"
|
|
|
|
ynh_lxc_stop_as_demo --name=$lxc_name1
|
|
|
|
fi
|
2016-08-12 17:35:14 +02:00
|
|
|
fi
|
2022-10-15 02:43:00 +02:00
|
|
|
if ynh_lxc_exists --name=$lxc_name2
|
2022-10-13 05:46:46 +02:00
|
|
|
then
|
2022-10-15 02:43:00 +02:00
|
|
|
if ! ynh_lxc_is_stopped --name=$lxc_name2
|
|
|
|
then
|
|
|
|
ynh_print_info --message="Arrêt du conteneur $lxc_name2"
|
|
|
|
ynh_lxc_stop_as_demo --name=$lxc_name2
|
|
|
|
fi
|
2016-08-12 17:35:14 +02:00
|
|
|
fi
|