v1.0.0beta9

~修复部分设备启动时报错的bug
~修改更新脚本,优化更新流程
~安装systemd启动脚本时增加reload
~进一步优化安装脚本
This commit is contained in:
juewuy 2020-09-21 23:51:03 +08:00
parent 84cda4034a
commit 85af5ed310
8 changed files with 267 additions and 242 deletions

Binary file not shown.

View File

@ -1,2 +1,2 @@
GeoIP_v=20200917
versionsh=1.0.0beta9
versionsh=1.0.0beta9fix1

View File

@ -1,28 +1,86 @@
#! /bin/bash
# Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=0
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** ShellClash **"
echo "** by Juewuy **"
echo "***********************************************"
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
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')
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"
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
echo -e "最新版本:\033[32m$release_new\033[0m"
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
}
#输出
$echo "最新版本:\033[32m$release_new\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[37m支持各种基于openwrt的路由器设备"
echo -e "\033[33m有限兼容debian、centos等Linux系统\033[0m"
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
$echo "\033[37m支持各种基于openwrt的路由器设备"
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m 1 在默认目录(/etc)安装ShellClash"
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
echo -e "\033[0m 0 退出安装"
$echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录"
$echo "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入相应数字 > " num
#设置目录
if [ -z $num ];then
echo 安装已取消
exit;
@ -42,66 +100,16 @@ else
echo 安装已取消
exit;
fi
#下载文件包
clashdir=$dir/clash
#输出
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tarurl=$url@$release_new/bin/clashfm.tar.gz
if command -v curl &> /dev/null; then
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
else $result
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
[ $? -eq 0 ] && result="200"
fi
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
if [ ! -f "$dir/clash/mark" ]; then
cat >$dir/clash/mark<<EOF
#标识clash运行状态的文件不明勿动
EOF
fi
#判断系统类型写入不同的启动文件
if [ -f /etc/rc.common ];then
mv $dir/clash/clashservice /etc/init.d/clash #将rc服务文件移动到系统目录
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
mv $dir/clash/clash.service $sysdir/clash.service #将service服务文件移动到系统目录
sed -i "s%/etc/clash%${dir}/clash%g" $sysdir/clash.service
rm -rf /etc/init.d/clash
else
#设为保守模式
sed -i '/start_old=*/'d $dir/clash/mark
sed -i "1i\start_old=已开启" $dir/clash/mark
fi
fi
#修饰文件及版本号
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
sed -i "s%#!/bin/sh%#!/bin/$shtype%g" $dir/clash/start.sh
chmod 777 $dir/clash/start.sh
sed -i '/versionsh_l=*/'d $dir/clash/mark
sed -i "1i\versionsh_l=$release_new" $dir/clash/mark
#设置环境变量
sed -i '/alias clash=*/'d /etc/profile
echo "alias clash=\"$shtype $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
sed -i '/export clashdir=*/'d /etc/profile
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
rm -rf $dir/clash/clashservice
rm -rf $dir/clash/clash.service
#提示
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,28 +1,86 @@
#! /bin/bash
# Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=0
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** ShellClash **"
echo "** by Juewuy **"
echo "***********************************************"
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
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')
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"
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
echo -e "最新版本:\033[32m$release_new\033[0m"
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
}
#输出
$echo "最新版本:\033[32m$release_new\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[37m支持各种基于openwrt的路由器设备"
echo -e "\033[33m有限兼容debian、centos等Linux系统\033[0m"
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
$echo "\033[37m支持各种基于openwrt的路由器设备"
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m 1 在默认目录(/etc)安装ShellClash"
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
echo -e "\033[0m 0 退出安装"
$echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录"
$echo "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入相应数字 > " num
#设置目录
if [ -z $num ];then
echo 安装已取消
exit;
@ -42,66 +100,16 @@ else
echo 安装已取消
exit;
fi
#下载文件包
clashdir=$dir/clash
#输出
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tarurl=$url@$release_new/bin/clashfm.tar.gz
if command -v curl &> /dev/null; then
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
else $result
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
[ $? -eq 0 ] && result="200"
fi
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
if [ ! -f "$dir/clash/mark" ]; then
cat >$dir/clash/mark<<EOF
#标识clash运行状态的文件不明勿动
EOF
fi
#判断系统类型写入不同的启动文件
if [ -f /etc/rc.common ];then
mv $dir/clash/clashservice /etc/init.d/clash #将rc服务文件移动到系统目录
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
mv $dir/clash/clash.service $sysdir/clash.service #将service服务文件移动到系统目录
sed -i "s%/etc/clash%${dir}/clash%g" $sysdir/clash.service
rm -rf /etc/init.d/clash
else
#设为保守模式
sed -i '/start_old=*/'d $dir/clash/mark
sed -i "1i\start_old=已开启" $dir/clash/mark
fi
fi
#修饰文件及版本号
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
sed -i "s%#!/bin/sh%#!/bin/$shtype%g" $dir/clash/start.sh
chmod 777 $dir/clash/start.sh
sed -i '/versionsh_l=*/'d $dir/clash/mark
sed -i "1i\versionsh_l=$release_new" $dir/clash/mark
#设置环境变量
sed -i '/alias clash=*/'d /etc/profile
echo "alias clash=\"$shtype $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
sed -i '/export clashdir=*/'d /etc/profile
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
rm -rf $dir/clash/clashservice
rm -rf $dir/clash/clash.service
#提示
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -1,32 +1,86 @@
#! /bin/bash
# Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=1
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** ShellClash **"
echo "** by Juewuy **"
echo "***********************************************"
url="http://192.168.31.30:8080/clash-for-Miwifi"
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
#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')
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"
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" ] && release_new=$(wget-ssl -q --no-check-certificate --tries=1 --timeout=10 $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
[ -z "$release_new" ] && echo "无法连接服务器!" && exit
echo -e "最新版本:\033[32m$release_new\033[0m"
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
}
#输出
$echo "最新版本:\033[32m$release_new\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[37m支持各种基于openwrt的路由器设备"
echo -e "\033[33m有限兼容debian、centos等Linux系统\033[0m"
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
$echo "\033[37m支持各种基于openwrt的路由器设备"
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m 1 在默认目录(/etc)安装ShellClash"
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
echo -e "\033[0m 0 退出安装"
$echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录"
$echo "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入相应数字 > " num
#设置目录
if [ -z $num ];then
echo 安装已取消
exit;
@ -46,67 +100,16 @@ else
echo 安装已取消
exit;
fi
#下载文件包
clashdir=$dir/clash
#输出
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tarurl=$url/bin/clashfm.tar.gz
if command -v curl &> /dev/null; then
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
else $result
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
[ $? -eq 0 ] && result="200"
fi
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
if [ ! -f "$dir/clash/mark" ]; then
cat >$dir/clash/mark<<EOF
#标识clash运行状态的文件不明勿动
EOF
fi
#判断系统类型写入不同的启动文件
if [ -f /etc/rc.common ];then
mv $dir/clash/clashservice /etc/init.d/clash #将rc服务文件移动到系统目录
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
mv $dir/clash/clash.service $sysdir/clash.service #将service服务文件移动到系统目录
sed -i "s%/etc/clash%${dir}/clash%g" $sysdir/clash.service
rm -rf /etc/init.d/clash
else
#设为保守模式
sed -i '/start_old=*/'d $dir/clash/mark
sed -i "1i\start_old=已开启" $dir/clash/mark
fi
fi
#修饰文件及版本号
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
sed -i "s%#!/bin/sh%#!/bin/$shtype%g" $dir/clash/start.sh
chmod 777 $dir/clash/start.sh
sed -i '/versionsh_l=*/'d $dir/clash/mark
sed -i "1i\versionsh_l=$release_new" $dir/clash/mark
#设置环境变量
sed -i '/alias clash=*/'d /etc/profile
echo "alias clash=\"$shtype $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
sed -i '/export clashdir=*/'d /etc/profile
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
rm -rf $dir/clash/clashservice
rm -rf $dir/clash/clash.service
#提示
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -694,25 +694,25 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
elif [[ $num == 8 ]]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "感谢:\033[32mClash \033[0m作者\033[36m Dreamacro\033[0m 项目地址:\033[32mhttps://github.com/Dreamacro/clash\033[0m"
echo -e "感谢:\033[32malecthw大神提供的GeoIP数据库\033[0m 项目地址:\033[32mhttps://github.com/alecthw/mmdb_china_ip_list\033[0m"
echo -e "感谢:\033[32msubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
echo -e "感谢:\033[32malecthw提供的GeoIP数据库\033[0m 项目地址:\033[32mhttps://github.com/alecthw/mmdb_china_ip_list\033[0m"
echo -e "感谢:\033[32m更多的帮助过我的人\033[0m"
update
update
elif [[ $num == 9 ]]; then
read -p "确认卸载clash警告该操作不可逆[1/0] " res
if [ "$res" = '1' ]; then
/etc/init.d/clash disable
/etc/init.d/clash stop
$clashdir/start.sh stop
rm -rf $clashdir
rm -rf /etc/init.d/clash
rm -rf /etc/systemd/system/clash.service
rm -rf /usr/lib/systemd/system/clash.service
rm -rf /www/clash
rm -rf $csh
sed -i '/alias clash=*/'d /etc/profile
sed -i '/export clashdir=*/'d /etc/profile
source /etc/profile > /dev/null 2>&1
echo 已卸载clash相关文件
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 已卸载clash相关文件有缘再会
exit
fi
echo -e "\033[31m操作已取消\033[0m"

View File

@ -223,39 +223,33 @@ else
echo -e "\033[31m请输入正确的链接地址\033[0m"
fi
}
getsh(){
echo -----------------------------------------------
echo -e "当前脚本版本为:\033[33m $versionsh_l \033[0m"
echo -e "最新脚本版本为:\033[32m $release_new \033[0m"
echo -----------------------------------------------
read -p "是否更新脚本?[1/0] > " res
if [ "$res" = '1' ]; then
if command -v curl &> /dev/null; then
echo 正在获取更新文件
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $update_url/bin/clashfm.tar.gz)
else $result
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $update_url/bin/clashfm.tar.gz
[ $? -eq 0 ] && result="200"
fi
gettar(){
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压
echo -----------------------------------------------
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $clashdir > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $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
mv $clashdir/clashservice /etc/init.d/clash #将rc服务文件移动到系统目录
chmod 777 /etc/init.d/clash #授予权限
#设为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
mv $clashdir/clash.service $sysdir/clash.service #将service服务文件移动到系统目录
sed -i "s%/etc/clash%${dir}/clash%g" $sysdir/clash.service
#设为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
@ -264,18 +258,35 @@ if [ "$res" = '1' ]; then
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 $ccfg
sed -i "1i\versionsh_l=$release_new" $ccfg
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 /tmp/clashversion
rm -rf $clashdir/clashservice
rm -rf $clashdir/clash.service
}
getsh(){
echo -----------------------------------------------
echo -e "当前脚本版本为:\033[33m $versionsh_l \033[0m"
echo -e "最新脚本版本为:\033[32m $release_new \033[0m"
echo -----------------------------------------------
read -p "是否更新脚本?[1/0] > " res
if [ "$res" = '1' ]; then
tarurl=$update_url/bin/clashfm.tar.gz
#下载更新
gettar
#提示
echo -----------------------------------------------
echo -e "\033[32m管理脚本更新成功!\033[0m"
echo -----------------------------------------------
exit;
else
update
else
update
fi
}
getcore(){

View File

@ -198,7 +198,7 @@ exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
#预删除需要添加的项目
i=$(grep -n "^proxies:" $clashdir/config.yaml | head -1 | cut -d ":" -f 1)
i=$(($i-1))
sed -i '1,'$i'd' $clashdir/config.yaml
sed -i "1,${i}d" $clashdir/config.yaml
#添加配置
sed -i "1i$mix" $clashdir/config.yaml
sed -i "1a$redir" $clashdir/config.yaml
@ -304,12 +304,7 @@ checkcron(){
}
daemon(){
checkcron
echo '*/1 * * * * test -z "$(pidof clash)" && /etc/init.d/clash start #clash守护进程' >> $cronpath
chmod 600 $cronpath
}
daemon_old(){
checkcron
echo '*/1 * * * * test -z "$(pidof clash)" && '"$clashdir/clash -d $clashdir >/dev/null 2>&1 & #clash守护进程" >> $cronpath
echo '*/1 * * * * test -z "$(pidof clash)" && /etc/init.d/clash restart #clash守护进程' >> $cronpath
chmod 600 $cronpath
}
afstart(){
@ -336,7 +331,7 @@ start)
#使用不同方式启动clash服务
if [ "$start_old" = "已开启" ];then
$clashdir/clash -d $clashdir >/dev/null 2>&1 &
daemon_old
daemon
afstart
elif [ -f /etc/rc.common ];then
/etc/init.d/clash start
@ -347,7 +342,7 @@ start)
stop)
#删除守护
checkcron
sed -i /clash守护进程/d $cronpath
sed -i /clash守护进程/d $cronpath >/dev/null 2>&1
#多种方式结束进程
if [ -f /etc/rc.common ];then
/etc/init.d/clash stop >/dev/null 2>&1