mirror of
https://github.com/juewuy/ShellCrash.git
synced 2024-11-16 03:32:34 +08:00
v1.0.0beta14fix3
~修复部分ssr节点不可用的bug ~mac过滤功能增加移除单个设备以及添加全部设备功能 ~修复设置本机代理时直接跳出的bug ~优化安装脚本,增加root用户检测
This commit is contained in:
parent
156d9193ee
commit
87ae8b78be
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +0,0 @@
|
|||
version=1.0.0
|
|
@ -1,4 +1,4 @@
|
|||
clash_v=1.2.0
|
||||
clashpre_v=2020.10.09
|
||||
GeoIP_v=20201010
|
||||
versionsh=1.0.0beta14fix2
|
||||
versionsh=1.0.0beta14fix3
|
||||
|
|
14
install.sh
14
install.sh
|
@ -2,7 +2,7 @@
|
|||
# Copyright (C) Juewuy
|
||||
|
||||
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
|
||||
test=1
|
||||
[ -z "$1" ] && test=0 || test=$1
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
|
@ -10,18 +10,22 @@ echo "** ShellClash **"
|
|||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
#检查root权限
|
||||
[ "$USER" != "root" ] && echo 请使用root用户执行安装!&& exit 1
|
||||
|
||||
#检查更新
|
||||
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
|
||||
if [ $test -ge 1 ];then
|
||||
if [ "$test" -eq 1 ];then
|
||||
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
|
||||
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
|
||||
[ $test -ge 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
|
||||
[ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
|
||||
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
|
||||
else
|
||||
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
|
||||
fi
|
||||
[ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
|
||||
[ -z "$release_new" ] && echo "无法连接服务器!" && exit
|
||||
tarurl=$url@$release_new/bin/clashfm.tar.gz
|
||||
[ $test -ge 1 ] && tarurl=$url/bin/clashfm.tar.gz
|
||||
[ "$test" -eq 1 ] && tarurl=$url/bin/clashfm.tar.gz
|
||||
gettar(){
|
||||
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright (C) Juewuy
|
||||
|
||||
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
|
||||
test=0
|
||||
test=$1
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
|
@ -10,11 +10,15 @@ echo "** ShellClash **"
|
|||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
#检查root权限
|
||||
[ "$USER" != "root" ] && echo 请使用root用户执行安装!&& exit 1
|
||||
|
||||
#检查更新
|
||||
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
|
||||
if [ $test -ge 1 ];then
|
||||
if [ $test -eq 1 ];then
|
||||
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
|
||||
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
|
||||
[ $test -ge 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
|
||||
[ $test -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
|
||||
[ $test -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
|
||||
else
|
||||
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
|
||||
fi
|
||||
|
@ -39,7 +43,7 @@ gettar(){
|
|||
mv $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 777 /etc/init.d/clash
|
||||
else
|
||||
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -d /etc/systemd/system/ ] && sysdir=/etc/systemd/system/
|
||||
[ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/
|
||||
if [ -n "$sysdir" ];then
|
||||
#设为systemd方式启动
|
||||
|
|
140
install_test.sh
140
install_test.sh
|
@ -1,140 +0,0 @@
|
|||
#! /bin/bash
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
|
||||
test=2
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
echo "** ShellClash **"
|
||||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
|
||||
if [ $test -ge 1 ];then
|
||||
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
|
||||
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
|
||||
[ $test -ge 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
|
||||
else
|
||||
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
|
||||
fi
|
||||
[ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
|
||||
[ -z "$release_new" ] && echo "无法连接服务器!" && exit
|
||||
tarurl=$url@$release_new/bin/clashfm.tar.gz
|
||||
[ $test -ge 1 ] && tarurl=$url/bin/clashfm.tar.gz
|
||||
gettar(){
|
||||
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
#解压
|
||||
echo -----------------------------------------------
|
||||
echo 开始解压文件!
|
||||
mkdir -p $clashdir > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
|
||||
#初始化文件目录
|
||||
[ -f "$clashdir/mark" ] || echo '#标识clash运行状态的文件,不明勿动!' > $clashdir/mark
|
||||
#判断系统类型写入不同的启动文件
|
||||
if [ -f /etc/rc.common ];then
|
||||
#设为init.d方式启动
|
||||
mv $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 777 /etc/init.d/clash
|
||||
else
|
||||
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/
|
||||
if [ -n "$sysdir" ];then
|
||||
#设为systemd方式启动
|
||||
mv $clashdir/clash.service $sysdir/clash.service
|
||||
sed -i "s%/etc/clash%$clashdir%g" $sysdir/clash.service
|
||||
systemctl daemon-reload
|
||||
rm -rf /etc/init.d/clash
|
||||
else
|
||||
#设为保守模式启动
|
||||
sed -i '/start_old=*/'d $clashdir/mark
|
||||
sed -i "1i\start_old=已开启" $clashdir/mark
|
||||
fi
|
||||
fi
|
||||
#修饰文件及版本号
|
||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
|
||||
sed -i "s%#!/bin/sh%#!/bin/$shtype%g" $clashdir/start.sh
|
||||
chmod 777 $clashdir/start.sh
|
||||
sed -i '/versionsh_l=*/'d $clashdir/mark
|
||||
sed -i "1i\versionsh_l=$release_new" $clashdir/mark
|
||||
#设置环境变量
|
||||
sed -i '/alias clash=*/'d /etc/profile
|
||||
echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d /etc/profile
|
||||
echo "export clashdir=\"$clashdir\"" >> /etc/profile #设置clash路径环境变量
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
rm -rf $clashdir/clashservice
|
||||
rm -rf $clashdir/clash.service
|
||||
}
|
||||
#下载及安装
|
||||
install(){
|
||||
echo -----------------------------------------------
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo -----------------------------------------------
|
||||
gettar
|
||||
echo -----------------------------------------------
|
||||
echo ShellClash 已经安装成功!
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理!!!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
}
|
||||
setdir(){
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[32m 1 在默认目录(/etc)安装"
|
||||
$echo "\033[33m 2 手动设置安装目录"
|
||||
$echo "\033[0m 0 退出安装"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入相应数字 > " num
|
||||
#设置目录
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [ "$num" = "1" ];then
|
||||
dir=/etc
|
||||
elif [ "$num" = "2" ];then
|
||||
echo -----------------------------------------------
|
||||
echo '可用路径 剩余空间:'
|
||||
df -h | awk '{print $6,$2}'| sed 1d
|
||||
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
|
||||
read -p "请输入自定义路径 > " dir
|
||||
if [ -z "$dir" ];then
|
||||
$echo "\033[31m路径错误!已取消安装!\033[0m"
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
echo 安装已取消!!!
|
||||
exit;
|
||||
fi
|
||||
clashdir=$dir/clash
|
||||
install
|
||||
}
|
||||
|
||||
#输出
|
||||
$echo "最新版本:\033[32m$release_new\033[0m"
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[44m如遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||
$echo "\033[37m支持各种基于openwrt的路由器设备"
|
||||
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
|
||||
|
||||
if [ -n "$clashdir" ];then
|
||||
echo -----------------------------------------------
|
||||
$echo "检测到旧的安装目录\033[36m$clashdir\033[0m,是否覆盖安装?"
|
||||
$echo "\033[32m覆盖安装时不会移除配置文件!\033[0m"
|
||||
read -p "覆盖安装/卸载旧版本?(1/0) > " res
|
||||
if [ "$res" = "1" ];then
|
||||
install
|
||||
elif [ "$res" = "0" ];then
|
||||
rm -rf $clashdir
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[31m 旧版本文件已卸载!\033[0m"
|
||||
setdir
|
||||
else
|
||||
$echo "\033[31m输入错误!已取消安装!\033[0m"
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
setdir
|
||||
fi
|
|
@ -725,18 +725,16 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
|
|||
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then
|
||||
sed -i "1i\local_proxy=已开启" $ccfg
|
||||
local_proxy=已开启
|
||||
source $clashdir/start.sh
|
||||
set_proxy
|
||||
$clashdir/start.sh set_proxy $mix_port
|
||||
echo -e "\033[32m已经将代理参数写入环境变量~\033[0m"
|
||||
echo -e "\033[36m如未生效,请重新登录或者重启设备!\033[0m"
|
||||
sleep 1
|
||||
echo -e "\033[36m如未生效,请重新启动终端或重新连接SSH!\033[0m"
|
||||
else
|
||||
sed -i "1i\local_proxy=未开启" $ccfg
|
||||
local_proxy=未开启
|
||||
source $clashdir/start.sh
|
||||
unset_proxy
|
||||
$clashdir/start.sh unset_proxy
|
||||
echo -e "\033[33m已经将代理参数从环境变量移除!!\033[0m"
|
||||
fi
|
||||
sleep 1
|
||||
clashadv
|
||||
elif [[ $num == 5 ]]; then
|
||||
setport
|
||||
|
|
|
@ -285,16 +285,6 @@ daemon(){
|
|||
echo 请进入定时任务菜单手动指定系统定时任务文件路径!!!
|
||||
fi
|
||||
}
|
||||
set_proxy(){
|
||||
echo 'export http_proxy=http://127.0.0.1:'"$mix_port" >> /etc/profile
|
||||
echo 'export https_proxy=$http_proxy' >> /etc/profile
|
||||
echo 'export HTTP_PROXY=$http_proxy' >> /etc/profile
|
||||
echo 'export HTTPS_PROXY=$http_proxy' >> /etc/profile
|
||||
}
|
||||
unset_proxy(){
|
||||
sed -i '/http*_proxy/'d /etc/profile
|
||||
sed -i '/HTTP*_PROXY/'d /etc/profile
|
||||
}
|
||||
web_save(){
|
||||
#使用curl获取面板节点设置
|
||||
curl -s -H "Authorization: Bearer ${secret}" -H "Content-Type:application/json" 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' > $clashdir/web_save
|
||||
|
@ -338,7 +328,7 @@ afstart(){
|
|||
#标记启动时间
|
||||
mark_time
|
||||
#设置本机代理
|
||||
[ "$local_proxy" = "已开启" ] && set_proxy
|
||||
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port
|
||||
#启用面板配置自动保存
|
||||
web_save_auto
|
||||
#后台还原面板配置
|
||||
|
@ -385,7 +375,7 @@ stop)
|
|||
#清理iptables
|
||||
stop_iptables
|
||||
#禁用本机代理
|
||||
[ "$local_proxy" = "已开启" ] && unset_proxy
|
||||
[ "$local_proxy" = "已开启" ] && $0 unset_proxy
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
|
@ -402,9 +392,13 @@ web_save)
|
|||
getconfig
|
||||
web_save
|
||||
;;
|
||||
web_restore)
|
||||
getconfig
|
||||
web_restore
|
||||
set_proxy)
|
||||
echo 'export all_proxy=http://127.0.0.1:'"$2" >> /etc/profile
|
||||
echo 'export ALL_PROXY=$all_proxy' >> /etc/profile
|
||||
;;
|
||||
unset_proxy)
|
||||
sed -i '/all_proxy/'d /etc/profile
|
||||
sed -i '/ALL_PROXY/'d /etc/profile
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user