2016-08-13 01:08:44 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Détruit les conteneurs lxc de demo.
|
|
|
|
# Permet de repartir sur des bases saines avec le script demo_lxc_build.sh
|
|
|
|
|
|
|
|
# Récupère le dossier du script
|
2016-09-18 19:23:54 +02:00
|
|
|
if [ "${0:0:1}" == "/" ]; then script_dir="$(dirname "$0")"; else script_dir="$(echo $PWD/$(dirname "$0" | cut -d '.' -f2) | sed 's@/$@@')"; fi
|
2016-08-13 01:08:44 +02:00
|
|
|
|
2022-10-13 05:46:46 +02:00
|
|
|
source $script_dir/ynh_lxd
|
|
|
|
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)
|
|
|
|
lxdbr_demo_network=$(ynh_app_setting_get --app=$app --key=lxdbr_demo_network)
|
|
|
|
lxc_ip1=$(ynh_app_setting_get --app=$app --key=lxc_ip1)
|
|
|
|
lxc_ip2=$(ynh_app_setting_get --app=$app --key=lxc_ip2)
|
|
|
|
|
2022-10-15 22:25:49 +02:00
|
|
|
ynh_print_info --message=">> Starting demo destroy."
|
|
|
|
|
2022-10-13 05:46:46 +02:00
|
|
|
/bin/bash "$final_path/demo_stop.sh" -f
|
|
|
|
|
2022-10-15 22:25:49 +02:00
|
|
|
ynh_print_info --message="> Deleting containers and snapshots"
|
2022-10-15 23:36:15 +02:00
|
|
|
ynh_exec_warn_less ynh_secure_remove --file="/var/lib/lxd/snapshots/$lxc_name1/snap0.tar.gz"
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_lxc_delete --name=$lxc_name1
|
2022-10-15 23:36:15 +02:00
|
|
|
ynh_exec_warn_less ynh_secure_remove --file="/var/lib/lxd/snapshots/$lxc_name2/snap0.tar.gz"
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_lxc_delete --name=$lxc_name2
|
|
|
|
|
2022-10-15 22:25:49 +02:00
|
|
|
ynh_print_info --message="> Deleting crons"
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_secure_remove --file=/etc/cron.d/demo_switch
|
|
|
|
ynh_secure_remove --file=/etc/cron.d/demo_upgrade
|
|
|
|
|
2022-10-15 22:25:49 +02:00
|
|
|
ynh_print_info --message="> Deleting service"
|
2022-10-13 05:46:46 +02:00
|
|
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
|
|
|
then
|
2022-10-15 22:47:40 +02:00
|
|
|
ynh_print_info --message="> Removing $app service integration..."
|
2022-10-13 05:46:46 +02:00
|
|
|
yunohost service remove $app
|
2016-09-18 19:23:54 +02:00
|
|
|
fi
|
2022-10-15 22:47:40 +02:00
|
|
|
ynh_print_info --message="> Stopping and removing the systemd service..."
|
2022-10-13 05:46:46 +02:00
|
|
|
ynh_remove_systemd_config
|
2022-10-15 22:25:49 +02:00
|
|
|
|
|
|
|
ynh_print_info --message=">> Finished demo destroy."
|