diff --git a/modules/mihomo-as-default/files/etc/hotplug.d/iface/99-mihomo b/modules/mihomo-as-default/files/etc/hotplug.d/iface/99-mihomo new file mode 100755 index 0000000..927c1f3 --- /dev/null +++ b/modules/mihomo-as-default/files/etc/hotplug.d/iface/99-mihomo @@ -0,0 +1,26 @@ +#!/bin/sh + +echo "iface $INTERFACE $ACTION detected..." + +[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && { + + sleep 3 + + ps | grep mihomo | grep nobody + if [ $? -eq 0 ]; then + logger "mihomo is running" + else + if [ ! -f /root/.mihomo_first_boot ]; then + logger "First boot detected, starting mihomo..." + + uci -q set mihomo.config.enabled=1 + uci -q commit mihomo + + /etc/init.d/mihomo start + + touch /root/.mihomo_first_boot + else + logger "Not first boot, mihomo start according to config" + fi + fi +} \ No newline at end of file diff --git a/modules/openwrt-mihomo/example.env b/modules/openwrt-mihomo/example.env new file mode 100644 index 0000000..25c9d9f --- /dev/null +++ b/modules/openwrt-mihomo/example.env @@ -0,0 +1 @@ +CLASH_CONFIG_URL=https://a.com/config.yml \ No newline at end of file diff --git a/modules/openwrt-mihomo/files/etc/uci-defaults/99-mihomo b/modules/openwrt-mihomo/files/etc/uci-defaults/99-mihomo new file mode 100644 index 0000000..7aa4de4 --- /dev/null +++ b/modules/openwrt-mihomo/files/etc/uci-defaults/99-mihomo @@ -0,0 +1,13 @@ +uci batch << EOF +set mihomo.config.fast_reload='0' +set mihomo.proxy.tcp_transparent_proxy_mode='tproxy' +set mihomo.proxy.udp_transparent_proxy_mode='tproxy' +set mihomo.proxy.ipv6_proxy='1' +set mihomo.proxy.bypass_china_mainland_ip='1' +set mihomo.subscription.url='$CLASH_CONFIG_URL' +set mihomo.mixin.ipv6='1' +set mihomo.mixin.dns_mode='normal' +set mihomo.mixin.dns_ipv6='1' +set mihomo.mixin.dns_system_hosts='1' +commit +EOF \ No newline at end of file