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

67 lines
2.1 KiB
Text
Raw Normal View History

2018-09-25 19:03:30 +02:00
#!/bin/bash
# to test the functionnality :
2021-11-20 19:05:14 +01:00
# yunohost app remove homeassistant --purge
2018-09-25 19:03:30 +02:00
2018-10-18 05:16:40 +02:00
source _common.sh
2018-09-25 19:03:30 +02:00
source /usr/share/yunohost/helpers
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
2020-08-12 22:22:59 +02:00
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
2018-09-25 19:03:30 +02:00
# definie useful vars
2018-10-18 05:16:40 +02:00
final_path="/opt/yunohost/$app"
2021-11-20 19:05:14 +01:00
data_path="/home/yunohost.app/$app"
2021-11-24 22:23:50 +01:00
log_file="/var/log/$app/$app.log"
2021-11-20 19:05:14 +01:00
# Remove a service from the admin panel, added by `yunohost service add`
2021-11-21 21:25:39 +01:00
if ynh_exec_warn_less yunohost service status "$app" >/dev/null ; then
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing $app service integration..."
2021-11-21 21:25:39 +01:00
yunohost service remove "$app"
2021-11-20 19:05:14 +01:00
fi
# remove systemd service
ynh_script_progression --message="Stopping and removing the systemd service..."
2021-11-21 21:25:39 +01:00
ynh_remove_systemd_config --service="$app"
2021-11-20 19:05:14 +01:00
# remove the app-specific logrotate config
ynh_script_progression --message="Removing logrotate configuration..."
ynh_remove_logrotate
2018-09-25 19:03:30 +02:00
# remove metapackage and its dependencies
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing dependencies..."
2018-09-25 19:03:30 +02:00
ynh_remove_app_dependencies
# remove the app directory securely
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing app main directory..."
2020-08-12 22:22:59 +02:00
ynh_secure_remove --file="$final_path"
2018-09-25 19:03:30 +02:00
2021-11-20 19:05:14 +01:00
# remove a directory securely if --purge option is used
if [ "${YNH_APP_PURGE:-0}" -eq 1 ] ; then
ynh_script_progression --message="Removing app data directory..."
ynh_secure_remove --file="$data_path"
fi
2018-09-25 19:03:30 +02:00
# remove the dedicated nginx config
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing NGINX web server configuration..."
2018-09-25 19:03:30 +02:00
ynh_remove_nginx_config
2021-11-20 19:05:14 +01:00
# close port
if yunohost firewall list | grep -q "\- $port$" ; then
ynh_script_progression --message="Closing port $port..."
ynh_exec_warn_less yunohost firewall disallow TCP $port
2018-09-25 19:03:30 +02:00
fi
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing various files..."
2021-11-24 22:23:50 +01:00
# remove sudoers file
2021-11-20 19:05:14 +01:00
ynh_secure_remove --file="/etc/sudoers.d/$app"
2021-11-24 22:23:50 +01:00
# Remove the log files
ynh_secure_remove --file="$(dirname "$log_file")"
2018-09-25 19:03:30 +02:00
# delete a system user
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removing the dedicated system user..."
2020-11-16 15:10:12 +01:00
ynh_system_user_delete --username="$app"
2021-11-20 19:05:14 +01:00
ynh_script_progression --message="Removal of $app completed" --last