mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 11:42:18 +08:00
v1.0.0beta17.8
~增加了对padavan系统读取局域网设备过滤列表的支持 ~优化了配置文件保存方式,减少闪存消耗 ~修复了部分mipsle设备无法正确识别核心的bug ~修复了部分情况下订阅链接/配置链接丢失的bug ~修复了部分情况下会连续下载两次核心的bug
This commit is contained in:
parent
2fa0840c6e
commit
66cc65f239
|
@ -11,6 +11,9 @@ getconfig(){
|
|||
yaml=$clashdir/config.yaml
|
||||
#检查/读取标识文件
|
||||
[ ! -f $ccfg ] && echo '#标识clash运行状态的文件,不明勿动!' > $ccfg
|
||||
#检查重复行并去除
|
||||
[ -n "$(awk 'a[$0]++' $ccfg)" ] && awk '!a[$0]++' $ccfg > $ccfg
|
||||
#使用source加载配置文件
|
||||
source $ccfg
|
||||
#设置默认核心资源目录
|
||||
[ -z "$bindir" ] && bindir=$clashdir
|
||||
|
@ -78,7 +81,7 @@ getconfig(){
|
|||
echo -----------------------------------------------
|
||||
#检查新手引导
|
||||
if [ -z "$userguide" ];then
|
||||
sed -i "1i\userguide=1" $ccfg
|
||||
setconfig userguide 1
|
||||
source $clashdir/getdate.sh && userguide
|
||||
fi
|
||||
#检查执行权限
|
||||
|
@ -87,8 +90,7 @@ getconfig(){
|
|||
setconfig(){
|
||||
#参数1代表变量名,参数2代表变量值,参数3即文件路径
|
||||
[ -z "$3" ] && configpath=$clashdir/mark || configpath=$3
|
||||
sed -i "/${1}*/"d $configpath
|
||||
echo "${1}=${2}" >> $configpath
|
||||
[ -n "$(grep ${1} $configpath)" ] && sed -i "s/${1}=.*/${1}=${2}/g" $configpath || echo "${1}=${2}" >> $configpath
|
||||
}
|
||||
#启动相关
|
||||
errornum(){
|
||||
|
@ -124,7 +126,7 @@ clashstart(){
|
|||
}
|
||||
checkrestart(){
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[32m检测到配置文件已变更,需要重启clash服务以生效!\033[0m"
|
||||
echo -e "\033[32m检测到已变更的内容,请重启clash服务!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "是否现在重启clash服务?(1/0) > " res
|
||||
[ "$res" = 1 ] && clashstart
|
||||
|
@ -178,7 +180,7 @@ setport(){
|
|||
read -p "请输入Http/Sock5用户名及密码 > " input
|
||||
if [ "$input" = "0" ];then
|
||||
authentication=""
|
||||
sed -i "/authentication*/"d $ccfg
|
||||
setconfig authentication
|
||||
echo 密码已移除!
|
||||
else
|
||||
if [ "$local_proxy" = "已开启" ];then
|
||||
|
@ -267,8 +269,8 @@ setdns(){
|
|||
elif [ "$num" = 3 ]; then
|
||||
dns_nameserver=""
|
||||
dns_fallback=""
|
||||
sed -i "/dns_nameserver*/"d $ccfg
|
||||
sed -i "/dns_fallback*/"d $ccfg
|
||||
setconfig dns_nameserver
|
||||
setconfig dns_fallback
|
||||
echo -e "\033[33mDNS配置已重置!!!\033[0m"
|
||||
setdns
|
||||
elif [ "$num" = 4 ]; then
|
||||
|
@ -364,9 +366,10 @@ macfilter(){
|
|||
fi
|
||||
}
|
||||
echo -----------------------------------------------
|
||||
[ -f /var/lib/dhcp/dhcpd.leases ] && dhcpdir='/var/lib/dhcp/dhcpd.leases'
|
||||
[ -f /var/lib/dhcpd/dhcpd.leases ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
|
||||
[ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases'
|
||||
[ -z "$dhcpdir" ] && dhcpdir='/var/lib/dhcp/dhcpd.leases'
|
||||
[ -z "$dhcpdir" ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
|
||||
[ -z "$dhcpdir" ] && dhcpdir='/tmp/dhcp.leases'
|
||||
[ -z "$dhcpdir" ] && dhcpdir='/tmp/dnsmasq.leases'
|
||||
[ -z "$dhcpdir" ] && dhcpdir='/dev/null'
|
||||
[ -z "$macfilter_type" ] && macfilter_type='黑名单'
|
||||
[ "$macfilter_type" = "黑名单" ] && macfilter_over='白名单' || macfilter_over='黑名单'
|
||||
|
@ -798,7 +801,7 @@ clashadv(){
|
|||
if [ "$dns_no" = "已禁用" ];then
|
||||
read -p "检测到内置DNS已被禁用,是否启用内置DNS?(1/0) > " res
|
||||
if [ "$res" = "1" ];then
|
||||
sed -i "/dns_no*/"d $ccfg
|
||||
setconfig dns_no
|
||||
setdns
|
||||
fi
|
||||
else
|
||||
|
@ -1008,8 +1011,10 @@ clashsh(){
|
|||
elif [ "$num" = 2 ]; then
|
||||
checkcfg=$(cat $ccfg)
|
||||
clashcfg
|
||||
checkcfg_new=$(cat $ccfg)
|
||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||
if [ -n "$PID" ];then
|
||||
checkcfg_new=$(cat $ccfg)
|
||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||
fi
|
||||
clashsh
|
||||
|
||||
elif [ "$num" = 3 ]; then
|
||||
|
@ -1050,15 +1055,23 @@ clashsh(){
|
|||
elif [ "$num" = 7 ]; then
|
||||
checkcfg=$(cat $ccfg)
|
||||
clashadv
|
||||
checkcfg_new=$(cat $ccfg)
|
||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||
if [ -n "$PID" ];then
|
||||
checkcfg_new=$(cat $ccfg)
|
||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||
fi
|
||||
clashsh
|
||||
|
||||
elif [ "$num" = 8 ]; then
|
||||
source $clashdir/getdate.sh && testcommand
|
||||
|
||||
elif [ "$num" = 9 ]; then
|
||||
checkcfg=$(cat $ccfg)
|
||||
source $clashdir/getdate.sh && update
|
||||
if [ -n "$PID" ];then
|
||||
checkcfg_new=$(cat $ccfg)
|
||||
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
|
||||
fi
|
||||
clashsh
|
||||
|
||||
else
|
||||
errornum
|
||||
|
|
|
@ -394,26 +394,28 @@ getcpucore(){
|
|||
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="386"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="amd64"
|
||||
if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ];then
|
||||
mipstype=$(echo -n I | hexdump -o | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
|
||||
[ "$mipstype" != "1" ] && cpucore="mips-softfloat" || cpucore="mipsle-softfloat"
|
||||
mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
|
||||
[ "$mipstype" = "0" ] && cpucore="mips-softfloat" || cpucore="mipsle-softfloat"
|
||||
fi
|
||||
[ -n "$cpucore" ] && setconfig cpucore $cpucore
|
||||
}
|
||||
setcpucore(){
|
||||
cpucore_list="armv5 armv7 armv8 386 amd64 \nmipsle-softfloat mipsle-hardfloat mips-softfloat"
|
||||
cpucore_list="armv5 armv7 armv8 386 amd64 mipsle-softfloat mipsle-hardfloat mips-softfloat"
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[31m仅适合脚本无法正确识别核心或核心无法正常运行时使用!\033[0m"
|
||||
echo -e "当前可供在线下载的处理器架构为:"
|
||||
echo -e "\033[32m$cpucore_list\033[0m"
|
||||
echo $cpucore_list | awk -F " " '{for(i=1;i<=NF;i++) {print i" "$i }}'
|
||||
echo -e "如果您的CPU架构未在以上列表中,请运行【uname -a】命令,并复制好返回信息"
|
||||
echo -e "之后前往 t.me/clashfm 群提交或 github.com/juewuy/ShellClash 提交issue"
|
||||
echo -----------------------------------------------
|
||||
read -p "请手动输入处理器架构 > " cpucore
|
||||
if [ -z "$(echo $cpucore_list |grep "$cpucore")" ];then
|
||||
read -p "请输入对应数字 > " num
|
||||
setcpucore=$(echo $cpucore_list | awk '{print $"'"$num"'"}' )
|
||||
if [ -z "$setcpucore" ];then
|
||||
echo -e "\033[31m请输入正确的处理器架构!\033[0m"
|
||||
sleep 1
|
||||
cpucore=""
|
||||
else
|
||||
cpucore=$setcpucore
|
||||
setconfig cpucore $cpucore
|
||||
fi
|
||||
}
|
||||
|
@ -770,9 +772,8 @@ update(){
|
|||
read -p "请输入对应数字 > " num
|
||||
if [ -z "$num" ]; then
|
||||
errornum
|
||||
clashsh
|
||||
elif [ "$num" = 0 ]; then
|
||||
clashsh
|
||||
i=
|
||||
elif [ "$num" = 1 ]; then
|
||||
getsh
|
||||
|
||||
|
@ -840,9 +841,7 @@ update(){
|
|||
update
|
||||
else
|
||||
errornum
|
||||
clashsh
|
||||
fi
|
||||
exit;
|
||||
}
|
||||
#新手引导
|
||||
userguide(){
|
||||
|
|
|
@ -33,8 +33,7 @@ getconfig(){
|
|||
setconfig(){
|
||||
#参数1代表变量名,参数2代表变量值,参数3即文件路径
|
||||
[ -z "$3" ] && configpath=$clashdir/mark || configpath=$3
|
||||
sed -i "/${1}*/"d $configpath
|
||||
echo "${1}=${2}" >> $configpath
|
||||
[ -n "$(grep ${1} $configpath)" ] && sed -i "s/${1}=.*/${1}=${2}/g" $configpath || echo "${1}=${2}" >> $configpath
|
||||
}
|
||||
compare(){
|
||||
if [ ! -f $1 -o ! -f $2 ];then
|
||||
|
@ -422,7 +421,6 @@ web_save(){
|
|||
fi
|
||||
}
|
||||
#使用get_save获取面板节点设置
|
||||
#get_save http://localhost:${db_port}/proxies | awk -F "{" '{for(i=1;i<=NF;i++) print $i}' | grep -E '^"all".*"Selector"' | grep -oE '"name".*"now".*",' | sed 's/"name"://g' | sed 's/"now"://g'| sed 's/"//g' > /tmp/clash_web_save_$USER
|
||||
get_save http://localhost:${db_port}/proxies | awk -F "{" '{for(i=1;i<=NF;i++) print $i}' | grep -E '^"all".*"Selector"' > /tmp/clash_web_check_$USER
|
||||
while read line ;do
|
||||
def=$(echo $line | awk -F "[\[,]" '{print $2}')
|
||||
|
@ -430,8 +428,10 @@ web_save(){
|
|||
[ "$def" != "$now" ] && echo $line | grep -oE '"name".*"now".*",' | sed 's/"name"://g' | sed 's/"now"://g'| sed 's/"//g' >> /tmp/clash_web_save_$USER
|
||||
done < /tmp/clash_web_check_$USER
|
||||
#对比文件,如果有变动且不为空则写入磁盘,否则清除缓存
|
||||
[ ! -s /tmp/clash_web_save_$USER ] && compare /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
[ "$?" = 0 ] && rm -rf /tmp/clash_web_save_$USER || mv -f /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
if [ -s /tmp/clash_web_save_$USER ];then
|
||||
compare /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
[ "$?" = 0 ] && rm -rf /tmp/clash_web_save_$USER || mv -f /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
fi
|
||||
}
|
||||
web_restore(){
|
||||
put_save(){
|
||||
|
|
Loading…
Reference in New Issue
Block a user