#!/bin/sh
[ -n "$IPKG_INSTROOT" ] || {
	# Clean up cron job for clash-rules update, if present
	CRON_FILE="/etc/crontabs/root"
	if [ -f "$CRON_FILE" ]; then
		sed -i '\|/opt/clash/bin/clash-rules update|d' "$CRON_FILE" 2>/dev/null || true
		/etc/init.d/cron restart >/dev/null 2>&1 || true
	fi

	rm -rf /opt/clash/ui
	rm -f /opt/clash/ruleset
	rm -f /opt/clash/.dns_backup
	rm -rf /tmp/clash
	rm -rf /www/luci-static/resources/view/ssclash
	rm -f /usr/lib/lua/luci/i18n/ssclash.*.lmo
	rm -f /opt/clash/.config.yaml.upgrade.bak
	rm -f /etc/hotplug.d/iface/40-clash
	rm -f /etc/hotplug.d/net/99-clash-tun
	rm -f /etc/apk/protected_paths.d/ssclash.list
}
