1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lxd_ynh.git synced 2024-09-03 19:45:53 +02:00
lxd_ynh/scripts/remove

109 lines
3.4 KiB
Text
Raw Normal View History

2021-03-01 14:53:57 +01:00
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# LOAD SETTINGS
#=================================================
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Loading installation settings..."
2021-03-01 14:53:57 +01:00
app=$YNH_APP_INSTANCE_NAME
#=================================================
# STANDARD REMOVE
#=================================================
# REMOVE SERVICE INTEGRATION IN YUNOHOST
#=================================================
# Remove the service from the list of services known by YunoHost (added from `yunohost service add`)
if ynh_exec_warn_less yunohost service status $app >/dev/null
then
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Removing $app service integration..."
2021-03-01 14:53:57 +01:00
yunohost service remove $app
fi
#=================================================
# STOP AND REMOVE SERVICE
#=================================================
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Stopping and removing the systemd service..."
2021-03-01 14:53:57 +01:00
# Remove the dedicated systemd config
2021-03-01 19:00:42 +01:00
ynh_remove_systemd_socket_config
2021-03-02 15:44:34 +01:00
ynh_exec_warn_less ynh_remove_systemd_config
2021-03-01 14:53:57 +01:00
#=================================================
# REMOVE DEPENDENCIES
#=================================================
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Removing dependencies..." --weight=20
2021-03-01 14:53:57 +01:00
# Remove metapackage and its dependencies
2021-03-02 15:44:34 +01:00
ynh_exec_warn_less ynh_remove_app_dependencies
2021-03-01 14:53:57 +01:00
#=================================================
# CLOSE A PORT
#=================================================
2021-03-01 19:00:42 +01:00
if yunohost firewall list | grep -q "\- 67$"
2021-03-01 14:53:57 +01:00
then
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Closing port 67..."
2021-03-01 19:00:42 +01:00
ynh_exec_warn_less yunohost firewall disallow Both 67
2021-03-01 14:53:57 +01:00
fi
#=================================================
# SPECIFIC REMOVE
#=================================================
# REMOVE VARIOUS FILES
#=================================================
# Remove a directory securely
2021-03-01 19:00:42 +01:00
ynh_secure_remove --file="/etc/ld.so.conf.d/$app.conf"
ldconfig
ynh_secure_remove --file="/usr/local/lib/$app"
2021-03-01 14:53:57 +01:00
# Remove the log files
2021-03-01 19:00:42 +01:00
ynh_secure_remove --file="/var/log/$app"
ynh_secure_remove --file="/usr/local/bin/lxc"
ynh_secure_remove --file="/usr/local/bin/lxd"
ynh_secure_remove --file="/usr/local/bin/lxc-to-lxd"
ynh_secure_remove --file="/usr/local/bin/lxd-p2c"
2021-03-16 14:10:32 +01:00
ynh_secure_remove --file="/etc/bash_completion.d/lxd-client"
2021-03-01 19:00:42 +01:00
2021-03-16 13:43:01 +01:00
sed -i "/# Added by lxd$/{N;/root:100000:65536/d}" /etc/sub{u,g}id
2021-03-01 14:53:57 +01:00
#=================================================
# GENERIC FINALIZATION
#=================================================
# REMOVE DEDICATED USER
#=================================================
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Removing the dedicated system user..."
2021-03-01 14:53:57 +01:00
# Delete a system user
ynh_system_user_delete --username=$app
2021-03-02 14:58:33 +01:00
#=================================================
2021-10-12 13:39:54 +02:00
# REMOVE CONTAINERS
2021-03-02 14:58:33 +01:00
#=================================================
2021-10-12 13:39:54 +02:00
# Remove the data directory if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ]
then
ynh_script_progression --message="Removing containers..."
ynh_secure_remove --file="/var/lib/lxd"
fi
2021-03-02 14:58:33 +01:00
2021-03-01 14:53:57 +01:00
#=================================================
# END OF SCRIPT
#=================================================
2021-03-02 15:59:40 +01:00
ynh_script_progression --message="Removal of $app completed" --last