From 4689d7074ebe6c5ed9ac2476fe65c3d55512ccc0 Mon Sep 17 00:00:00 2001 From: SunBK201 Date: Fri, 5 Dec 2025 03:24:19 +0800 Subject: [PATCH] fix: add uci-defaults script --- openwrt/Makefile | 10 ++++++++-- openwrt/files/uci-defaults | 11 +++++++++++ scripts/build.sh | 4 +++- scripts/ipkg/CONTROL/postrm | 10 +++++++--- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 openwrt/files/uci-defaults diff --git a/openwrt/Makefile b/openwrt/Makefile index ae9377c..7bf92ac 100644 --- a/openwrt/Makefile +++ b/openwrt/Makefile @@ -55,6 +55,8 @@ define Package/ua3f/install $(INSTALL_BIN) ./files/ua3f.init $(1)/etc/init.d/ua3f $(INSTALL_DIR) $(1)/etc/config/ $(INSTALL_CONF) ./files/ua3f.uci $(1)/etc/config/ua3f + $(INSTALL_DIR) $(1)/etc/uci-defaults/ + $(INSTALL_BIN) ./files/uci-defaults $(1)/etc/uci-defaults/luci-ua3f $(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n/ $(INSTALL_DATA) $(PKG_BUILD_DIR)/ua3f.zh-cn.lmo $(1)/usr/lib/lua/luci/i18n/ua3f.zh-cn.lmo $(CP) $(PKG_BUILD_DIR)/files/luci/* $(1)/usr/lib/lua/luci/ @@ -62,8 +64,12 @@ endef define Package/ua3f/postrm #!/bin/sh -uci set ua3f.enabled.enabled='0' > /dev/null 2>&1 -uci commit ua3f > /dev/null 2>&1 +uci -q set ua3f.enabled.enabled=0 +uci -q commit ua3f +[ -f "/etc/config/ucitrack" ] && { + uci -q delete ucitrack.ua3f + uci -q commit ucitrack +} rm -rf /var/log/ua3f >/dev/null 2>&1 rm -rf /usr/lib/lua/luci/model/cbi/ua3f >/dev/null 2>&1 rm -rf /usr/lib/lua/luci/model/cbi/ua3f.lua >/dev/null 2>&1 diff --git a/openwrt/files/uci-defaults b/openwrt/files/uci-defaults new file mode 100644 index 0000000..bd5c4e1 --- /dev/null +++ b/openwrt/files/uci-defaults @@ -0,0 +1,11 @@ +#!/bin/sh + +[ -e "/etc/config/ucitrack" ] && { + uci -q delete ucitrack.@ua3f[-1] + uci -q add ucitrack ua3f + uci -q set ucitrack.@ua3f[-1].init=ua3f + uci -q commit ucitrack +} + +rm -f /tmp/luci-indexcache* >/dev/null 2>&1 +exit 0 diff --git a/scripts/build.sh b/scripts/build.sh index 66abc93..e594480 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -104,10 +104,12 @@ mkdir -p \ $opkg_template/usr/lib/lua/luci/view/ua3f \ $opkg_template/usr/lib/lua/luci/i18n \ $opkg_template/etc/init.d \ - $opkg_template/etc/config + $opkg_template/etc/config \ + $opkg_template/etc/uci-defaults cp openwrt/files/ua3f.init $opkg_template/etc/init.d/ua3f cp openwrt/files/ua3f.uci $opkg_template/etc/config/ua3f +cp openwrt/files/uci-defaults $opkg_template/etc/uci-defaults/luci-ua3f cp -r openwrt/files/luci/* $opkg_template/usr/lib/lua/luci/ po2lmo openwrt/po/zh_cn/ua3f.po $opkg_template/usr/lib/lua/luci/i18n/ua3f.zh-cn.lmo diff --git a/scripts/ipkg/CONTROL/postrm b/scripts/ipkg/CONTROL/postrm index 34bae39..e054fae 100755 --- a/scripts/ipkg/CONTROL/postrm +++ b/scripts/ipkg/CONTROL/postrm @@ -1,8 +1,12 @@ #!/bin/sh -uci set ua3f.enabled.enabled='0' > /dev/null 2>&1 -uci commit ua3f > /dev/null 2>&1 +uci -q set ua3f.enabled.enabled=0 +uci -q commit ua3f +[ -f "/etc/config/ucitrack" ] && { + uci -q delete ucitrack.ua3f + uci -q commit ucitrack +} rm -rf /var/log/ua3f >/dev/null 2>&1 rm -rf /usr/lib/lua/luci/model/cbi/ua3f >/dev/null 2>&1 rm -rf /usr/lib/lua/luci/model/cbi/ua3f.lua >/dev/null 2>&1 rm -rf /usr/lib/lua/luci/controller/ua3f.lua >/dev/null 2>&1 -rm -rf /usr/lib/lua/luci/view/ua3f >/dev/null 2>&1 +rm -rf /usr/lib/lua/luci/view/ua3f >/dev/null 2>&1 \ No newline at end of file