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
2020-11-16 15:10:12 +01:00

46 lines
1.2 KiB
Bash

#!/bin/bash
# to test the functionnality :
# yunohost app remove homeassistant
source _common.sh
source /usr/share/yunohost/helpers
# retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get --app=$app --key=domain)
port=$(ynh_app_setting_get --app=$app --key=port)
# definie useful vars
final_path="/opt/yunohost/$app"
home_path="/home/$app"
# remove metapackage and its dependencies
ynh_remove_app_dependencies
# remove the app directory securely
ynh_secure_remove --file="$final_path"
# remove the dedicated nginx config
ynh_remove_nginx_config
# remove a directory securely
ynh_secure_remove --file="$home_path"
# Remove a service from the admin panel, added by `yunohost service add`
if yunohost service status "$app@$app" >/dev/null 2>&1 ; then
yunohost service remove "$app@$app"
fi
# remove systemd service
ynh_systemd_action --service_name="$app@$app" --action=stop
ynh_systemd_action --service_name="$app@$app" --action=disable
ynh_secure_remove --file="/etc/systemd/system/$app@$app.service"
# close port
ynh_exec_fully_quiet yunohost firewall disallow TCP $port
# delete a system user
ynh_system_user_delete --username="$app"
# remove sudoers file
ynh_secure_remove --file="/etc/sudoers.d/$app"