mirror of
https://github.com/YunoHost-Apps/pihole_ynh.git
synced 2024-09-03 20:05:58 +02:00
172 lines
5.3 KiB
Bash
Executable file
172 lines
5.3 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
#=================================================
|
|
# GENERIC STARTING
|
|
#=================================================
|
|
# IMPORT GENERIC HELPERS
|
|
#=================================================
|
|
|
|
source _common.sh
|
|
source /usr/share/yunohost/helpers
|
|
|
|
#=================================================
|
|
# LOAD SETTINGS
|
|
#=================================================
|
|
ynh_script_progression --message="Load settings" --weight=2
|
|
|
|
app=$YNH_APP_INSTANCE_NAME
|
|
|
|
domain=$(ynh_app_setting_get $app domain)
|
|
port=$(ynh_app_setting_get $app port)
|
|
|
|
#=================================================
|
|
# STANDARD REMOVE
|
|
#=================================================
|
|
# REMOVE SERVICE FROM ADMIN PANEL
|
|
#=================================================
|
|
|
|
# Check if the service is declared in YunoHost
|
|
if ynh_exec_fully_quiet yunohost service status pihole-FTL
|
|
then
|
|
ynh_print_info "Remove pihole-FTL service" >&2
|
|
yunohost service remove pihole-FTL
|
|
fi
|
|
|
|
#=================================================
|
|
# STOP PIHOLE-FTL SERVICE
|
|
#=================================================
|
|
ynh_script_progression --message="Stop and remove the service"
|
|
|
|
ynh_systemd_action --action=stop --service_name=pihole-FTL
|
|
ynh_exec_warn_less systemctl disable pihole-FTL
|
|
rm -f "/etc/init.d/pihole-FTL" "/usr/bin/pihole-FTL" "/var/run/pihole-FTL.pid" "/var/run/pihole-FTL.port"
|
|
|
|
#=================================================
|
|
# REMOVE DEPENDENCIES
|
|
#=================================================
|
|
ynh_script_progression --message="Remove dependencies" --weight=7
|
|
|
|
# Remove metapackage and its dependencies
|
|
ynh_remove_app_dependencies
|
|
|
|
#=================================================
|
|
# REMOVE THE DIRECTORIES OF THE APP
|
|
#=================================================
|
|
ynh_script_progression --message="Remove app main directories"
|
|
|
|
# Remove storage directory
|
|
ynh_secure_remove "/etc/pihole"
|
|
# Remove app directory
|
|
ynh_secure_remove "/opt/pihole"
|
|
# Remove admin panel directory
|
|
ynh_secure_remove "/var/www/pihole"
|
|
# Remove local clone of the repository
|
|
ynh_secure_remove "/etc/.pihole"
|
|
|
|
#=================================================
|
|
# REMOVE NGINX CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Remove nginx configuration"
|
|
|
|
# Remove the dedicated nginx config
|
|
ynh_remove_nginx_config
|
|
|
|
#=================================================
|
|
# REMOVE PHP-FPM CONFIGURATION
|
|
#=================================================
|
|
ynh_script_progression --message="Remove php-fpm configuration" --weight=2
|
|
|
|
# Remove the dedicated php-fpm config
|
|
ynh_remove_fpm_config
|
|
|
|
#=================================================
|
|
# CLOSE PORTS
|
|
#=================================================
|
|
ynh_script_progression --message="Close ports" --weight=13
|
|
|
|
if yunohost firewall list | grep -q "\- $port$"
|
|
then
|
|
ynh_print_info "Close port $port" >&2
|
|
ynh_exec_quiet yunohost firewall disallow TCP $port
|
|
fi
|
|
|
|
if yunohost firewall list | grep -q "\- 67$"
|
|
then
|
|
ynh_print_info "Close port 67" >&2
|
|
ynh_exec_quiet yunohost firewall disallow UDP 67
|
|
fi
|
|
|
|
#=================================================
|
|
# SPECIFIC REMOVE
|
|
#=================================================
|
|
# REMOVE CRON FILE
|
|
#=================================================
|
|
|
|
ynh_secure_remove "/etc/cron.d/pihole"
|
|
|
|
#=================================================
|
|
# REMOVE OTHER FILES
|
|
#=================================================
|
|
|
|
# Remove logs
|
|
ynh_secure_remove "/var/log/pihole.log"
|
|
ynh_secure_remove "/var/log/pihole-FTL.log"
|
|
|
|
# Remove main script
|
|
ynh_secure_remove "/usr/local/bin/pihole"
|
|
ynh_secure_remove "/etc/bash_completion.d/pihole"
|
|
|
|
# Remove sudoer file
|
|
ynh_secure_remove "/etc/sudoers.d/pihole"
|
|
|
|
#=================================================
|
|
# REMOVE DNSMASQ CONFIG
|
|
#=================================================
|
|
ynh_script_progression --message="Remove Dnsmasq config" --weight=2
|
|
|
|
ynh_systemd_action --action=stop --service_name=dnsmasq
|
|
rm -f "/etc/dnsmasq.d/01-pihole.conf"
|
|
rm -f "/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
|
rm -f "/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
|
rm -f "/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
|
|
|
ynh_replace_string "#pihole# " "" /etc/dnsmasq.conf
|
|
|
|
#=================================================
|
|
# CLEAN /etc/hosts
|
|
#=================================================
|
|
ynh_script_progression --message="Clean /etc/hosts"
|
|
|
|
# Uncomment lines in /etc/hosts
|
|
sed -i "s/#Commented by pihole# //g" /etc/hosts
|
|
|
|
# And remove extra lines, added by PiHole
|
|
sed -i "/#Added by pihole#/d" /etc/hosts
|
|
|
|
#=================================================
|
|
# RESTART DNSMASQ
|
|
#=================================================
|
|
ynh_script_progression --message="Restart Dnsmasq"
|
|
|
|
ynh_systemd_action --action=restart --service_name=dnsmasq
|
|
|
|
#=================================================
|
|
# REMOVE CONF_REGEN HOOK
|
|
#=================================================
|
|
|
|
ynh_secure_remove /usr/share/yunohost/hooks/conf_regen/50-dnsmasq_$app
|
|
|
|
#=================================================
|
|
# GENERIC FINALISATION
|
|
#=================================================
|
|
# REMOVE DEDICATED USER
|
|
#=================================================
|
|
ynh_script_progression --message="Remove the dedicated user" --weight=2
|
|
|
|
ynh_system_user_delete $app
|
|
|
|
#=================================================
|
|
# END OF SCRIPT
|
|
#=================================================
|
|
|
|
ynh_script_progression --message="Deletion completed" --last
|