2022-03-16 15:00:11 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# Copyright (C) Juewuy
|
|
|
|
|
|
|
|
clashdir=/data/clash
|
|
|
|
profile=/etc/profile
|
|
|
|
|
|
|
|
#h初始化环境变量
|
2022-09-22 20:36:53 +08:00
|
|
|
sed -i "/alias clash/d" $profile
|
|
|
|
sed -i "/export clashdir/d" $profile
|
|
|
|
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
|
|
|
echo "export clashdir=\"$clashdir\"" >> $profile
|
2022-03-16 15:00:11 +08:00
|
|
|
#设置init.d服务并启动clash服务
|
|
|
|
ln -sf $clashdir/clashservice /etc/init.d/clash
|
|
|
|
chmod 755 /etc/init.d/clash
|
|
|
|
|
2022-03-16 16:10:18 +08:00
|
|
|
if [ ! -f $clashdir/.dis_startup ];then
|
2022-03-16 15:00:11 +08:00
|
|
|
log_file=`uci get system.@system[0].log_file`
|
|
|
|
while [ "$i" -lt 10 ];do
|
2022-11-20 20:12:37 +08:00
|
|
|
sleep 5
|
2022-03-16 15:00:11 +08:00
|
|
|
[ -n "$(grep 'init complete' $log_file)" ] && i=10 || i=$((i+1))
|
|
|
|
done
|
|
|
|
/etc/init.d/clash start
|
|
|
|
/etc/init.d/clash enable
|
2022-03-16 16:10:18 +08:00
|
|
|
fi
|