-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add mihomo default config and as-default module
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
modules/mihomo-as-default/files/etc/hotplug.d/iface/99-mihomo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CLASH_CONFIG_URL=https://a.com/config.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |