#!/bin/sh
[ -n "${IPKG_INSTROOT}" ] || [ "${PKG_UPGRADE}" = 1 ] && exit 0
rm -f /etc/config/forestvpn /www/forestvpn-setup.txt
rm -rf /var/run/forestvpn
# the table of ForestVPN's own sockets (lib/forestvpn/direct.nft): prerm's `uninstall pkg` deleted it, and the stops after it could load it again
nft delete table inet forestvpn_direct 2>/dev/null
# the LuCI pages' menu and ACL went with the package: LuCI's caches must not show a menu entry that now leads nowhere (WP L-1)
rm -f /tmp/luci-indexcache.*
rm -rf /tmp/luci-modulecache/
killall -HUP rpcd 2>/dev/null
for d in /usr/libexec/forestvpn /lib/forestvpn /lib/upgrade/forestvpn /etc/forestvpn-reinstall /www-notice /usr/share/forestvpn /www/luci-static/resources/view/forestvpn /www/luci-static/resources/forestvpn; do
	[ -d "$d" ] && find "$d" -depth -type d -exec rmdir {} \; 2>/dev/null
done
exit 0
