#!/bin/sh
	# Isolated from stock OpenClash — only touch /etc/wycloud namespace
	# Stage config only for upgrades / reinstalls that still have live data.
	case "$1" in
	install|upgrade)
		if [ -f "/etc/config/wycloud" ] && [ ! -f "/tmp/wycloud.bak" ]; then
			cp -f "/etc/config/wycloud" "/tmp/wycloud.bak" >/dev/null 2>&1
			cp -rf "/etc/wycloud" "/tmp/wycloud" >/dev/null 2>&1
			cp -rf "/usr/share/wycloud/ui" "/tmp/wycloud_ui" >/dev/null 2>&1
			cp -rf "/www/luci-static/resources/wycloud/pac" "/tmp/wycloud_pac" >/dev/null 2>&1
		fi
		;;
	esac
	exit 0
