v1.0.0beta15.7
~优化了本机代理实现方式,增加了选项菜单 ~优化了定时任务实现方式,适配更多设备 ~优化了配置文件修饰方式 ~优化了启动和关闭进程时的检测,修复错误 ~优化了非root用户体验 ~优化脚本结构
This commit is contained in:
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
clash_v=1.2.0
|
clash_v=1.2.0
|
||||||
GeoIP_v=20201021
|
GeoIP_v=20201021
|
||||||
versionsh=123
|
|
||||||
clashpre_v=2020.10.26.gc025a01
|
clashpre_v=2020.10.26.gc025a01
|
||||||
|
versionsh=1.0.0beta15.7
|
||||||
|
|||||||
196
scripts/clash.sh
196
scripts/clash.sh
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) Juewuy
|
# Copyright (C) Juewuy
|
||||||
|
|
||||||
|
#读取配置相关
|
||||||
getconfig(){
|
getconfig(){
|
||||||
#服务器缺省地址
|
#服务器缺省地址
|
||||||
[ -z "$update_url" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash
|
[ -z "$update_url" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash
|
||||||
@@ -37,7 +38,7 @@ getconfig(){
|
|||||||
fi
|
fi
|
||||||
#开机自启描述
|
#开机自启描述
|
||||||
if [ "$start_old" = "已开启" ];then
|
if [ "$start_old" = "已开启" ];then
|
||||||
auto="\033[33m已设置保守模式!\033[0m"
|
auto="\033[32m保守模式\033[0m"
|
||||||
auto1="代理本机:\033[36m$local_proxy\033[0m"
|
auto1="代理本机:\033[36m$local_proxy\033[0m"
|
||||||
elif [ "$autostart" = "enable_rc" -o "$autostart" = "enable_sys" ]; then
|
elif [ "$autostart" = "enable_rc" -o "$autostart" = "enable_sys" ]; then
|
||||||
auto="\033[32m已设置开机启动!\033[0m"
|
auto="\033[32m已设置开机启动!\033[0m"
|
||||||
@@ -89,7 +90,8 @@ setconfig(){
|
|||||||
sed -i "/${1}*/"d $configpath
|
sed -i "/${1}*/"d $configpath
|
||||||
echo "${1}=${2}" >> $configpath
|
echo "${1}=${2}" >> $configpath
|
||||||
}
|
}
|
||||||
echoerrornum(){
|
#启动相关
|
||||||
|
errornum(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m请输入正确的数字!\033[0m"
|
echo -e "\033[31m请输入正确的数字!\033[0m"
|
||||||
}
|
}
|
||||||
@@ -115,7 +117,7 @@ EOF
|
|||||||
cmp -s /tmp/clash_pac $clashdir/ui/pac
|
cmp -s /tmp/clash_pac $clashdir/ui/pac
|
||||||
[ "$?" = 0 ] && rm -rf /tmp/clash_pac || mv -f /tmp/clash_pac $clashdir/ui/pac
|
[ "$?" = 0 ] && rm -rf /tmp/clash_pac || mv -f /tmp/clash_pac $clashdir/ui/pac
|
||||||
}
|
}
|
||||||
start_over(){
|
startover(){
|
||||||
echo -e "\033[32mclash服务已启动!\033[0m"
|
echo -e "\033[32mclash服务已启动!\033[0m"
|
||||||
if [ -n "$hostdir" ];then
|
if [ -n "$hostdir" ];then
|
||||||
echo -e "请使用\033[30;47m http://$host$hostdir \033[0m管理内置规则"
|
echo -e "请使用\033[30;47m http://$host$hostdir \033[0m管理内置规则"
|
||||||
@@ -125,6 +127,32 @@ start_over(){
|
|||||||
echo -e "推荐前往更新菜单安装本地Dashboard面板,连接更稳定!\033[0m"
|
echo -e "推荐前往更新菜单安装本地Dashboard面板,连接更稳定!\033[0m"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
clashstart(){
|
||||||
|
#检查clash核心
|
||||||
|
if [ ! -f $clashdir/clash ];then
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e "\033[31m没有找到核心文件,请先下载clash核心!\033[0m"
|
||||||
|
source $clashdir/getdate.sh && checkupdate && getcore
|
||||||
|
fi
|
||||||
|
#检查GeoIP数据库
|
||||||
|
if [ ! -f $clashdir/Country.mmdb ];then
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e "\033[31m没有找到GeoIP数据库文件,请下载数据库文件!\033[0m"
|
||||||
|
source $clashdir/getdate.sh && checkupdate && getgeo
|
||||||
|
fi
|
||||||
|
#检查yaml配置文件
|
||||||
|
if [ ! -f "$yaml" ];then
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e "\033[31m没有找到配置文件,请先导入配置文件!\033[0m"
|
||||||
|
clashlink
|
||||||
|
fi
|
||||||
|
catpac #生成pac自动代理文件
|
||||||
|
echo -----------------------------------------------
|
||||||
|
$clashdir/start.sh start
|
||||||
|
sleep 1
|
||||||
|
[ -n "$(pidof clash)" ] && startover || exit 1
|
||||||
|
}
|
||||||
|
#功能相关
|
||||||
setport(){
|
setport(){
|
||||||
inputport(){
|
inputport(){
|
||||||
read -p "请输入端口号(1000-65535) > " portx
|
read -p "请输入端口号(1000-65535) > " portx
|
||||||
@@ -168,7 +196,7 @@ setport(){
|
|||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
elif [ "$num" = 1 ]; then
|
elif [ "$num" = 1 ]; then
|
||||||
xport=mix_port
|
xport=mix_port
|
||||||
inputport
|
inputport
|
||||||
@@ -245,7 +273,7 @@ setdns(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashadv
|
clashadv
|
||||||
elif [ "$num" = 1 ]; then
|
elif [ "$num" = 1 ]; then
|
||||||
read -p "请输入新的DNS > " dns_nameserver
|
read -p "请输入新的DNS > " dns_nameserver
|
||||||
@@ -293,31 +321,6 @@ checkport(){
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
clashstart(){
|
|
||||||
#检查clash核心
|
|
||||||
if [ ! -f $clashdir/clash ];then
|
|
||||||
echo -----------------------------------------------
|
|
||||||
echo -e "\033[31m没有找到核心文件,请先下载clash核心!\033[0m"
|
|
||||||
source $clashdir/getdate.sh && checkupdate && getcore
|
|
||||||
fi
|
|
||||||
#检查GeoIP数据库
|
|
||||||
if [ ! -f $clashdir/Country.mmdb ];then
|
|
||||||
echo -----------------------------------------------
|
|
||||||
echo -e "\033[31m没有找到GeoIP数据库文件,请下载数据库文件!\033[0m"
|
|
||||||
source $clashdir/getdate.sh && checkupdate && getgeo
|
|
||||||
fi
|
|
||||||
#检查yaml配置文件
|
|
||||||
if [ ! -f "$yaml" ];then
|
|
||||||
echo -----------------------------------------------
|
|
||||||
echo -e "\033[31m没有找到配置文件,请先导入配置文件!\033[0m"
|
|
||||||
clashlink
|
|
||||||
fi
|
|
||||||
catpac #生成pac自动代理文件
|
|
||||||
echo -----------------------------------------------
|
|
||||||
$clashdir/start.sh start
|
|
||||||
sleep 1
|
|
||||||
[ -n "$(pidof clash)" ] && start_over || exit 1
|
|
||||||
}
|
|
||||||
macfilter(){
|
macfilter(){
|
||||||
add_mac(){
|
add_mac(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -394,7 +397,7 @@ macfilter(){
|
|||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashcfg
|
clashcfg
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashcfg
|
clashcfg
|
||||||
@@ -415,30 +418,72 @@ macfilter(){
|
|||||||
sleep 1
|
sleep 1
|
||||||
macfilter
|
macfilter
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
macfilter
|
macfilter
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
set_local_proxy(){
|
localproxy(){
|
||||||
|
[ -z "$local_proxy" ] && local_proxy='未开启'
|
||||||
|
[ -z "$local_proxy_type" ] && local_proxy_type='环境变量'
|
||||||
|
[ "$local_proxy" = "已开启" ] && proxy_set='禁用' || proxy_set='启用'
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e "\033[33m当前本机代理配置方式为:\033[32m$local_proxy_type\033[0m"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
echo -e " 1 \033[36m$proxy_set本机代理\033[0m"
|
||||||
|
echo -e " 2 使用\033[32m环境变量\033[0m方式配置"
|
||||||
|
echo -e " 3 使用\033[32mGNOME桌面API\033[0m配置"
|
||||||
|
echo -e " 4 使用\033[32mKDE桌面API\033[0m配置"
|
||||||
|
echo -e " 0 返回上级菜单"
|
||||||
|
echo -----------------------------------------------
|
||||||
|
read -p "请输入对应数字 > " num
|
||||||
|
if [ -z "$num" ]; then
|
||||||
|
errornum
|
||||||
|
elif [ "$num" = 1 ]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then
|
if [ "$local_proxy" = "未开启" ]; then
|
||||||
if [ -n "$authentication" ] && [ "$authentication" != "未设置" ] ;then
|
if [ -n "$authentication" ] && [ "$authentication" != "未设置" ] ;then
|
||||||
echo -e "\033[32m检测到您已经设置了Http/Sock5代理密码,请先取消密码!\033[0m"
|
echo -e "\033[32m检测到您已经设置了Http/Sock5代理密码,请先取消密码!\033[0m"
|
||||||
sleep 1
|
sleep 1
|
||||||
setport
|
setport
|
||||||
|
localproxy
|
||||||
else
|
else
|
||||||
local_proxy=已开启
|
local_proxy=已开启
|
||||||
$clashdir/start.sh set_proxy $mix_port $db_port
|
$clashdir/start.sh set_proxy $mix_port $db_port
|
||||||
echo -e "\033[32m已经成功配置本机代理~\033[0m"
|
echo -e "\033[32m已经成功使用$local_proxy_type方式配置本机代理~\033[0m"
|
||||||
echo -e "\033[36m如未生效,请重新启动终端或重新连接SSH!\033[0m"
|
[ "$local_proxy_type" = "环境变量" ] && echo -e "\033[36m如未生效,请重新启动终端或重新连接SSH!\033[0m" && sleep 1
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
local_proxy=未开启
|
local_proxy=未开启
|
||||||
$clashdir/start.sh unset_proxy
|
$clashdir/start.sh unset_proxy
|
||||||
echo -e "\033[33m已经停用本机代理规则!!\033[0m"
|
echo -e "\033[33m已经停用本机代理规则!!\033[0m"
|
||||||
echo -e "\033[36m如未生效,请重新启动终端或重新连接SSH!\033[0m"
|
[ "$local_proxy_type" = "环境变量" ] && echo -e "\033[36m如未生效,请重新启动终端或重新连接SSH!\033[0m" && sleep 1
|
||||||
fi
|
fi
|
||||||
setconfig local_proxy $local_proxy
|
setconfig local_proxy $local_proxy
|
||||||
|
elif [ "$num" = 2 ]; then
|
||||||
|
local_proxy_type="环境变量"
|
||||||
|
setconfig local_proxy_type $local_proxy_type
|
||||||
|
localproxy
|
||||||
|
elif [ "$num" = 3 ]; then
|
||||||
|
if gsettings --version >/dev/null 2>&1 ;then
|
||||||
|
local_proxy_type="GNOME"
|
||||||
|
setconfig local_proxy_type $local_proxy_type
|
||||||
|
else
|
||||||
|
echo -e "\033[31m没有找到GNOME桌面!\033[0m"
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
localproxy
|
||||||
|
elif [ "$num" = 4 ]; then
|
||||||
|
if kwriteconfig5 -h >/dev/null 2>&1 ;then
|
||||||
|
local_proxy_type="KDE"
|
||||||
|
setconfig local_proxy_type $local_proxy_type
|
||||||
|
else
|
||||||
|
echo -e "\033[31m没有找到KDE桌面!\033[0m"
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
localproxy
|
||||||
|
else
|
||||||
|
errornum
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
clashcfg(){
|
clashcfg(){
|
||||||
set_redir_mod(){
|
set_redir_mod(){
|
||||||
@@ -462,7 +507,7 @@ clashcfg(){
|
|||||||
echo " 0 返回上级菜单"
|
echo " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashcfg
|
clashcfg
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashcfg
|
clashcfg
|
||||||
@@ -509,7 +554,7 @@ clashcfg(){
|
|||||||
echo -e "PAC的使用教程请参考:\033[4;32mhttps://juewuy.github.io/ehRUeewcv\033[0m"
|
echo -e "PAC的使用教程请参考:\033[4;32mhttps://juewuy.github.io/ehRUeewcv\033[0m"
|
||||||
sleep 2
|
sleep 2
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashcfg
|
clashcfg
|
||||||
fi
|
fi
|
||||||
setconfig redir_mod $redir_mod
|
setconfig redir_mod $redir_mod
|
||||||
@@ -529,7 +574,7 @@ clashcfg(){
|
|||||||
echo " 0 返回上级菜单"
|
echo " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashcfg
|
clashcfg
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashcfg
|
clashcfg
|
||||||
@@ -538,7 +583,7 @@ clashcfg(){
|
|||||||
elif [ "$num" = 2 ]; then
|
elif [ "$num" = 2 ]; then
|
||||||
dns_mod=redir_host
|
dns_mod=redir_host
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashcfg
|
clashcfg
|
||||||
fi
|
fi
|
||||||
setconfig dns_mod $dns_mod
|
setconfig dns_mod $dns_mod
|
||||||
@@ -570,7 +615,7 @@ clashcfg(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashsh
|
clashsh
|
||||||
@@ -631,7 +676,7 @@ clashcfg(){
|
|||||||
clashcfg
|
clashcfg
|
||||||
|
|
||||||
elif [ "$num" = 7 ]; then
|
elif [ "$num" = 7 ]; then
|
||||||
set_local_proxy
|
localproxy
|
||||||
sleep 1
|
sleep 1
|
||||||
clashcfg
|
clashcfg
|
||||||
|
|
||||||
@@ -639,7 +684,7 @@ clashcfg(){
|
|||||||
clashstart
|
clashstart
|
||||||
clashsh
|
clashsh
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -668,7 +713,7 @@ clashadv(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashsh
|
clashsh
|
||||||
@@ -712,7 +757,7 @@ clashadv(){
|
|||||||
$clashdir/start.sh stop
|
$clashdir/start.sh stop
|
||||||
sleep 2
|
sleep 2
|
||||||
else
|
else
|
||||||
if [ -f /etc/init.d/clash -o -f /etc/systemd/system -o -f /usr/lib/systemd/system ];then
|
if [ -f /etc/init.d/clash -o -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
|
||||||
echo -e "\033[32m改为使用默认方式启动clash服务!!\033[0m"
|
echo -e "\033[32m改为使用默认方式启动clash服务!!\033[0m"
|
||||||
start_old=未开启
|
start_old=未开启
|
||||||
setconfig start_old $start_old
|
setconfig start_old $start_old
|
||||||
@@ -766,7 +811,7 @@ clashadv(){
|
|||||||
sleep 1
|
sleep 1
|
||||||
clashsh
|
clashsh
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -784,12 +829,13 @@ clashcron(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashcron
|
clashcron
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashcron
|
clashcron
|
||||||
elif [ "$num" = 9 ]; then
|
elif [ "$num" = 9 ]; then
|
||||||
crontab -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && crontab /tmp/conf && rm -f /tmp/conf
|
crontab -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && crontab /tmp/conf
|
||||||
|
rm -f /tmp/conf
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m定时任务:$cronname已删除!\033[0m"
|
echo -e "\033[31m定时任务:$cronname已删除!\033[0m"
|
||||||
clashcron
|
clashcron
|
||||||
@@ -806,10 +852,10 @@ clashcron(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入小时(0-23) > " num
|
read -p "请输入小时(0-23) > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
setcron
|
setcron
|
||||||
elif [ $num -gt 23 ] || [ $num -lt 0 ]; then
|
elif [ $num -gt 23 ] || [ $num -lt 0 ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
setcron
|
setcron
|
||||||
else
|
else
|
||||||
hour=$num
|
hour=$num
|
||||||
@@ -817,10 +863,10 @@ clashcron(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入分钟(0-60) > " num
|
read -p "请输入分钟(0-60) > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
setcron
|
setcron
|
||||||
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
|
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
setcron
|
setcron
|
||||||
else
|
else
|
||||||
min=$num
|
min=$num
|
||||||
@@ -830,7 +876,10 @@ clashcron(){
|
|||||||
read -p "是否确认添加定时任务?(1/0) > " res
|
read -p "是否确认添加定时任务?(1/0) > " res
|
||||||
if [ "$res" = '1' ]; then
|
if [ "$res" = '1' ]; then
|
||||||
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
|
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
|
||||||
crontab -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && echo "$cronwords" >> /tmp/conf && crontab /tmp/conf && rm -f /tmp/conf
|
crontab -l > /tmp/conf
|
||||||
|
sed -i "/$cronname/d" /tmp/conf
|
||||||
|
echo "$cronwords" >> /tmp/conf && crontab /tmp/conf
|
||||||
|
rm -f /tmp/conf
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
echo -e "\033[31m定时任务已添加!!!\033[0m"
|
||||||
fi
|
fi
|
||||||
@@ -852,7 +901,7 @@ clashcron(){
|
|||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
|
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
@@ -876,10 +925,11 @@ clashcron(){
|
|||||||
setcron
|
setcron
|
||||||
|
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
#主菜单
|
||||||
clashsh(){
|
clashsh(){
|
||||||
#############################
|
#############################
|
||||||
getconfig
|
getconfig
|
||||||
@@ -897,7 +947,7 @@ clashsh(){
|
|||||||
echo -e " 0 \033[0m退出脚本\033[0m"
|
echo -e " 0 \033[0m退出脚本\033[0m"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ];then
|
if [ -z "$num" ];then
|
||||||
echoerrornum
|
errornum
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
@@ -921,7 +971,7 @@ clashsh(){
|
|||||||
elif [ "$num" = 4 ]; then
|
elif [ "$num" = 4 ]; then
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
if [ "$start_old" = "已开启" ];then
|
if [ "$start_old" = "已开启" ];then
|
||||||
set_local_proxy
|
localproxy
|
||||||
elif [ "$autostart" = "enable_rc" ]; then
|
elif [ "$autostart" = "enable_rc" ]; then
|
||||||
/etc/init.d/clash disable
|
/etc/init.d/clash disable
|
||||||
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
echo -e "\033[33m已禁止Clash开机启动!\033[0m"
|
||||||
@@ -955,7 +1005,7 @@ clashsh(){
|
|||||||
source $clashdir/getdate.sh && update
|
source $clashdir/getdate.sh && update
|
||||||
|
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
exit;
|
exit;
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -964,19 +1014,23 @@ clashsh(){
|
|||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h)
|
-h)
|
||||||
echo -----------------------------------------
|
echo -----------------------------------------
|
||||||
echo "欢迎使用ShellClash"
|
echo "欢迎使用ShellClash"
|
||||||
echo -----------------------------------------
|
echo -----------------------------------------
|
||||||
echo " -t 测试模式"
|
echo " -t 测试模式"
|
||||||
echo " -h 帮助列表"
|
echo " -h 帮助列表"
|
||||||
echo -----------------------------------------
|
echo -----------------------------------------
|
||||||
echo "在线求助:t.me/clashfm"
|
echo "在线求助:t.me/clashfm"
|
||||||
echo "官方博客:juewuy.github.io"
|
echo "官方博客:juewuy.github.io"
|
||||||
echo "发布页面:github.com/juewuy/ShellClash"
|
echo "发布页面:github.com/juewuy/ShellClash"
|
||||||
echo -----------------------------------------
|
echo -----------------------------------------
|
||||||
;;
|
;;
|
||||||
-t)
|
-t)
|
||||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
|
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
|
||||||
$shtype -x $clashdir/clash.sh
|
$shtype -x $clashdir/clash.sh
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo " -t 测试模式"
|
||||||
|
echo " -h 帮助列表"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ webget(){
|
|||||||
fi
|
fi
|
||||||
export all_proxy=''
|
export all_proxy=''
|
||||||
}
|
}
|
||||||
|
#导入订阅、配置文件相关
|
||||||
linkconfig(){
|
linkconfig(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
echo -e "\033[44m 实验性功能,遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||||
@@ -39,7 +40,7 @@ linkconfig(){
|
|||||||
echo 0 返回上级菜单
|
echo 0 返回上级菜单
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ] || [ "$num" -gt 13 ];then
|
if [ -z "$num" ] || [ "$num" -gt 13 ];then
|
||||||
echoerrornum
|
errornum
|
||||||
elif [ "$num" = 0 ];then
|
elif [ "$num" = 0 ];then
|
||||||
echo
|
echo
|
||||||
elif [ "$num" -le 13 ];then
|
elif [ "$num" -le 13 ];then
|
||||||
@@ -64,7 +65,7 @@ linkserver(){
|
|||||||
echo 0 返回上级菜单
|
echo 0 返回上级菜单
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ] || [ "$num" -gt 5 ];then
|
if [ -z "$num" ] || [ "$num" -gt 5 ];then
|
||||||
echoerrornum
|
errornum
|
||||||
elif [ "$num" = 0 ];then
|
elif [ "$num" = 0 ];then
|
||||||
echo
|
echo
|
||||||
elif [ "$num" -le 5 ];then
|
elif [ "$num" -le 5 ];then
|
||||||
@@ -171,7 +172,7 @@ linkset(){
|
|||||||
setconfig skip_cert $skip_cert
|
setconfig skip_cert $skip_cert
|
||||||
linkset
|
linkset
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
linkset
|
linkset
|
||||||
fi
|
fi
|
||||||
clashlink
|
clashlink
|
||||||
@@ -276,7 +277,7 @@ clashlink(){
|
|||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ];then
|
if [ -z "$num" ];then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
elif [ "$num" = 1 ];then
|
elif [ "$num" = 1 ];then
|
||||||
if [ -n "$Url" ];then
|
if [ -n "$Url" ];then
|
||||||
@@ -370,10 +371,11 @@ clashlink(){
|
|||||||
elif [ "$num" = 0 ];then
|
elif [ "$num" = 0 ];then
|
||||||
clashsh
|
clashsh
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
#下载更新相关
|
||||||
gettar(){
|
gettar(){
|
||||||
webget /tmp/clashfm.tar.gz $tarurl
|
webget /tmp/clashfm.tar.gz $tarurl
|
||||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||||
@@ -480,7 +482,7 @@ getcore(){
|
|||||||
echo 0 返回上级菜单
|
echo 0 返回上级菜单
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
update
|
update
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
update
|
update
|
||||||
@@ -507,7 +509,7 @@ getcore(){
|
|||||||
fi
|
fi
|
||||||
getcore
|
getcore
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
update
|
update
|
||||||
fi
|
fi
|
||||||
#生成链接
|
#生成链接
|
||||||
@@ -595,7 +597,7 @@ getdb(){
|
|||||||
fi
|
fi
|
||||||
update
|
update
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
update
|
update
|
||||||
fi
|
fi
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
@@ -680,7 +682,7 @@ setserver(){
|
|||||||
echo -e " 0 返回上级菜单"
|
echo -e " 0 返回上级菜单"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
update
|
update
|
||||||
elif [ "$num" = 1 ]; then
|
elif [ "$num" = 1 ]; then
|
||||||
update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master'
|
update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master'
|
||||||
@@ -701,7 +703,7 @@ setserver(){
|
|||||||
elif [ "$num" = 9 ]; then
|
elif [ "$num" = 9 ]; then
|
||||||
update_url='http://192.168.31.30:8080/clash-for-Miwifi'
|
update_url='http://192.168.31.30:8080/clash-for-Miwifi'
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
update
|
update
|
||||||
fi
|
fi
|
||||||
#写入mark文件
|
#写入mark文件
|
||||||
@@ -745,7 +747,7 @@ update(){
|
|||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashsh
|
clashsh
|
||||||
@@ -802,11 +804,12 @@ update(){
|
|||||||
echo -e "\033[31m操作已取消!\033[0m"
|
echo -e "\033[31m操作已取消!\033[0m"
|
||||||
update
|
update
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
#新手引导
|
||||||
userguide(){
|
userguide(){
|
||||||
echo 欢迎使用ShellClash新手引导!
|
echo 欢迎使用ShellClash新手引导!
|
||||||
checkupdate
|
checkupdate
|
||||||
@@ -815,6 +818,7 @@ userguide(){
|
|||||||
getdb
|
getdb
|
||||||
clashlink
|
clashlink
|
||||||
}
|
}
|
||||||
|
#测试菜单
|
||||||
testcommand(){
|
testcommand(){
|
||||||
echo -----------------------------------------------
|
echo -----------------------------------------------
|
||||||
echo -e "\033[30;47m这里是测试命令菜单\033[0m"
|
echo -e "\033[30;47m这里是测试命令菜单\033[0m"
|
||||||
@@ -834,7 +838,7 @@ testcommand(){
|
|||||||
echo " 0 返回上级目录!"
|
echo " 0 返回上级目录!"
|
||||||
read -p "请输入对应数字 > " num
|
read -p "请输入对应数字 > " num
|
||||||
if [ -z "$num" ]; then
|
if [ -z "$num" ]; then
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
elif [ "$num" = 0 ]; then
|
elif [ "$num" = 0 ]; then
|
||||||
clashsh
|
clashsh
|
||||||
@@ -887,7 +891,7 @@ testcommand(){
|
|||||||
cat $clashdir/log
|
cat $clashdir/log
|
||||||
exit;
|
exit;
|
||||||
else
|
else
|
||||||
echoerrornum
|
errornum
|
||||||
clashsh
|
clashsh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
120
scripts/start.sh
120
scripts/start.sh
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) Juewuy
|
# Copyright (C) Juewuy
|
||||||
|
|
||||||
|
#相关工具
|
||||||
getconfig(){
|
getconfig(){
|
||||||
#加载配置文件
|
#加载配置文件
|
||||||
[ -z "$clashdir" ] && source /etc/profile > /dev/null
|
[ -z "$clashdir" ] && source /etc/profile > /dev/null
|
||||||
@@ -34,9 +35,18 @@ logger(){
|
|||||||
}
|
}
|
||||||
cronset(){
|
cronset(){
|
||||||
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
|
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
|
||||||
crontab -l > /tmp/conf && sed -i "/$1/d" /tmp/conf && echo "$2" >> /tmp/conf && crontab /tmp/conf
|
crontab -l > /tmp/conf
|
||||||
|
sed -i "/$1/d" /tmp/conf
|
||||||
|
echo "$2" >> /tmp/conf
|
||||||
|
crontab /tmp/conf
|
||||||
rm -f /tmp/conf
|
rm -f /tmp/conf
|
||||||
}
|
}
|
||||||
|
mark_time(){
|
||||||
|
start_time=`date +%s`
|
||||||
|
sed -i '/start_time*/'d $clashdir/mark
|
||||||
|
echo start_time=$start_time >> $clashdir/mark
|
||||||
|
}
|
||||||
|
#配置文件相关
|
||||||
getyaml(){
|
getyaml(){
|
||||||
[ -z "$rule_link" ] && rule_link=1
|
[ -z "$rule_link" ] && rule_link=1
|
||||||
[ -z "$server_link" ] && server_link=1
|
[ -z "$server_link" ] && server_link=1
|
||||||
@@ -209,11 +219,7 @@ EOF
|
|||||||
rm -f /tmp/clash/set.yaml
|
rm -f /tmp/clash/set.yaml
|
||||||
rm -f /tmp/clash/rule.yaml
|
rm -f /tmp/clash/rule.yaml
|
||||||
}
|
}
|
||||||
mark_time(){
|
#设置路由规则
|
||||||
start_time=`date +%s`
|
|
||||||
sed -i '/start_time*/'d $clashdir/mark
|
|
||||||
echo start_time=$start_time >> $clashdir/mark
|
|
||||||
}
|
|
||||||
start_redir(){
|
start_redir(){
|
||||||
#流量过滤规则
|
#流量过滤规则
|
||||||
iptables -t nat -N clash
|
iptables -t nat -N clash
|
||||||
@@ -241,6 +247,37 @@ start_redir(){
|
|||||||
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
|
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
start_dns(){
|
||||||
|
#允许tun网卡接受流量
|
||||||
|
if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
|
||||||
|
iptables -I FORWARD -o utun -j ACCEPT
|
||||||
|
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
|
||||||
|
fi
|
||||||
|
#设置dns转发
|
||||||
|
iptables -t nat -N clash_dns
|
||||||
|
for mac in $(cat $clashdir/mac); do
|
||||||
|
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
|
||||||
|
done
|
||||||
|
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to $dns_port
|
||||||
|
iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
|
||||||
|
iptables -t nat -A PREROUTING -p udp -j clash_dns
|
||||||
|
#Google home DNS特殊处理
|
||||||
|
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash_dns
|
||||||
|
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash_dns
|
||||||
|
#ipv6DNS
|
||||||
|
ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
|
||||||
|
if [ -n "ip6_nat" ];then
|
||||||
|
ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
|
||||||
|
for mac in $(cat $clashdir/mac); do
|
||||||
|
ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN > /dev/null 2>&1
|
||||||
|
done
|
||||||
|
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port > /dev/null 2>&1
|
||||||
|
ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
|
||||||
|
else
|
||||||
|
ip6tables -I INPUT -p tcp --dport 53 -j REJECT
|
||||||
|
ip6tables -I INPUT -p udp --dport 53 -j REJECT
|
||||||
|
fi
|
||||||
|
}
|
||||||
start_udp(){
|
start_udp(){
|
||||||
ip rule add fwmark 1 table 100
|
ip rule add fwmark 1 table 100
|
||||||
ip route add local default dev lo table 100
|
ip route add local default dev lo table 100
|
||||||
@@ -280,37 +317,7 @@ stop_iptables(){
|
|||||||
ip6tables -t nat -X clashv6_dns > /dev/null 2>&1
|
ip6tables -t nat -X clashv6_dns > /dev/null 2>&1
|
||||||
ip6tables -D FORWARD -o utun -j ACCEPT > /dev/null 2>&1
|
ip6tables -D FORWARD -o utun -j ACCEPT > /dev/null 2>&1
|
||||||
}
|
}
|
||||||
start_dns(){
|
#面板配置保存相关
|
||||||
#允许tun网卡接受流量
|
|
||||||
if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
|
|
||||||
iptables -I FORWARD -o utun -j ACCEPT
|
|
||||||
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
#设置dns转发
|
|
||||||
iptables -t nat -N clash_dns
|
|
||||||
for mac in $(cat $clashdir/mac); do
|
|
||||||
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
|
|
||||||
done
|
|
||||||
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to $dns_port
|
|
||||||
iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
|
|
||||||
iptables -t nat -A PREROUTING -p udp -j clash_dns
|
|
||||||
#Google home DNS特殊处理
|
|
||||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash_dns
|
|
||||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash_dns
|
|
||||||
#ipv6DNS
|
|
||||||
ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
|
|
||||||
if [ -n "ip6_nat" ];then
|
|
||||||
ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
|
|
||||||
for mac in $(cat $clashdir/mac); do
|
|
||||||
ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN > /dev/null 2>&1
|
|
||||||
done
|
|
||||||
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port > /dev/null 2>&1
|
|
||||||
ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
|
|
||||||
else
|
|
||||||
ip6tables -I INPUT -p tcp --dport 53 -j REJECT
|
|
||||||
ip6tables -I INPUT -p udp --dport 53 -j REJECT
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
web_save(){
|
web_save(){
|
||||||
get_save(){
|
get_save(){
|
||||||
if curl --version > /dev/null 2>&1;then
|
if curl --version > /dev/null 2>&1;then
|
||||||
@@ -359,11 +366,12 @@ web_restore(){
|
|||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
#启动相关
|
||||||
afstart(){
|
afstart(){
|
||||||
|
#读取配置文件
|
||||||
|
getconfig
|
||||||
$clashdir/clash -t -d $clashdir >/dev/null
|
$clashdir/clash -t -d $clashdir >/dev/null
|
||||||
if [ "$?" = 0 ];then
|
if [ "$?" = 0 ];then
|
||||||
#读取配置文件
|
|
||||||
getconfig
|
|
||||||
#修改iptables规则使流量进入clash
|
#修改iptables规则使流量进入clash
|
||||||
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ] && start_dns
|
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ] && start_dns
|
||||||
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
|
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
|
||||||
@@ -443,22 +451,20 @@ daemon)
|
|||||||
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"$(pidof clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
|
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"$(pidof clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
|
||||||
;;
|
;;
|
||||||
set_proxy)
|
set_proxy)
|
||||||
|
getconfig
|
||||||
#GNOME配置
|
#GNOME配置
|
||||||
if gsettings --version >/dev/null 2>&1 ;then
|
if [ "$local_proxy_type" = "GNOME" ];then
|
||||||
gsettings set org.gnome.system.proxy autoconfig-url "http://127.0.0.1:$3/ui/pac"
|
gsettings set org.gnome.system.proxy autoconfig-url "http://127.0.0.1:$db_port/ui/pac"
|
||||||
gsettings set org.gnome.system.proxy mode "auto"
|
gsettings set org.gnome.system.proxy mode "auto"
|
||||||
[ "$?" = 0 ] && check=$?
|
|
||||||
#KDE配置
|
#KDE配置
|
||||||
elif kwriteconfig5 -h >/dev/null 2>&1 ;then
|
elif [ "$local_proxy_type" = "KDE" ];then
|
||||||
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "Proxy Config Script" "http://127.0.0.1:$3/ui/pac"
|
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "Proxy Config Script" "http://127.0.0.1:$db_port/ui/pac"
|
||||||
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "ProxyType" 2
|
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "ProxyType" 2
|
||||||
[ "$?" = 0 ] && check=$?
|
|
||||||
#环境变量方式
|
#环境变量方式
|
||||||
fi
|
else
|
||||||
if [ -z "$check" ];then
|
|
||||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||||
[ -w /etc/profile ] && profile=/etc/profile
|
[ -w /etc/profile ] && profile=/etc/profile
|
||||||
echo 'export all_proxy=http://127.0.0.1:'"$2" >> $profile
|
echo 'export all_proxy=http://127.0.0.1:'"$mix_port" >> $profile
|
||||||
echo 'export ALL_PROXY=$all_proxy' >> $profile
|
echo 'export ALL_PROXY=$all_proxy' >> $profile
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -466,16 +472,16 @@ unset_proxy)
|
|||||||
#GNOME配置
|
#GNOME配置
|
||||||
if gsettings --version >/dev/null 2>&1 ;then
|
if gsettings --version >/dev/null 2>&1 ;then
|
||||||
gsettings set org.gnome.system.proxy mode "none"
|
gsettings set org.gnome.system.proxy mode "none"
|
||||||
#KDE配置
|
|
||||||
elif kwriteconfig5 -h >/dev/null 2>&1 ;then
|
|
||||||
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "ProxyType" 0
|
|
||||||
#环境变量方式
|
|
||||||
else
|
|
||||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
|
||||||
[ -w /etc/profile ] && profile=/etc/profile
|
|
||||||
sed -i '/all_proxy/'d $profile
|
|
||||||
sed -i '/ALL_PROXY/'d $profile
|
|
||||||
fi
|
fi
|
||||||
|
#KDE配置
|
||||||
|
if kwriteconfig5 -h >/dev/null 2>&1 ;then
|
||||||
|
kwriteconfig5 --file kioslaverc --group "Proxy Settings" --key "ProxyType" 0
|
||||||
|
fi
|
||||||
|
#环境变量方式
|
||||||
|
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||||
|
[ -w /etc/profile ] && profile=/etc/profile
|
||||||
|
sed -i '/all_proxy/'d $profile
|
||||||
|
sed -i '/ALL_PROXY/'d $profile
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user