~增加AX6S的tun模块修复功能
This commit is contained in:
juewuy
2023-03-01 14:06:53 +08:00
parent 89f0336f7f
commit da4258dd34
7 changed files with 45 additions and 619 deletions

View File

@@ -4,27 +4,55 @@
clashdir=/data/clash
profile=/etc/profile
#检查clash运行状态
if [ -z $(pidof clash) ]; then
tunfix(){
#在/tmp创建并挂载overlay
[ -e /tmp/overlay ] || mkdir /tmp/overlay
[ -e /tmp/overlay/upper ] || mkdir /tmp/overlay/upper
[ -e /tmp/overlay/work ] || mkdir /tmp/overlay/work
mount --bind /tmp/overlay /overlay
. /lib/functions/preinit.sh
fopivot /overlay/upper /overlay/work /rom 1
#Fixup miwifi misc, and DO NOT use /overlay/upper/etc instead, /etc/uci-defaults/* may be already removed
mount -o noatime,move /rom/data /data 2>&-
mount -o noatime,move /rom/etc /etc 2>&-
mount -o noatime,move /rom/userdisk /userdisk 2>&-
#将tun.ko链接到lib
ln -s $clashdir/tun.ko /overlay/upper/lib/modules/4.4.198/tun.ko
}
init(){
#初始化环境变量
sed -i "/alias clash/d" $profile
sed -i "/export clashdir/d" $profile
echo "alias clash=\"$clashdir/clash.sh\"" >>$profile
echo "export clashdir=\"$clashdir\"" >>$profile
#设置init.d服务并启动clash服务
#设置init.d服务
cp -f $clashdir/clashservice /etc/init.d/clash
chmod 755 /etc/init.d/clash
#启动服务
if [ ! -f $clashdir/.dis_startup ]; then
log_file=$(uci get system.@system[0].log_file)
while [ "$i" -lt 10 ]; do
sleep 5
[ -n "$(grep 'init complete' $log_file)" ] && i=10 || i=$((i + 1))
done
#AX6S/AX6000修复tun功能
[ -f $clashdir/tun.ko -a ! -f /lib/modules/4.4.198/tun.ko ] && tunfix
#
/etc/init.d/clash start
/etc/init.d/clash enable
fi
else
sleep 10
$clashdir/start.sh restart
fi
}
case "$1" in
tunfix) tunfix ;;
init) init ;;
*)
if [ -z $(pidof clash) ];then
init
else
sleep 10
$clashdir/start.sh restart
fi
;;
esac