v1.0.0beta6
~优化定时任务脚本,修复bug ~优化版本更新机制 ~重写启动脚本,全面兼容debian及centos ~支持linux的systemd方式启动 ~优化cdn下载链接
This commit is contained in:
29
install.sh
29
install.sh
@@ -7,7 +7,8 @@ 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')
|
||||
url="http://127.0.0.1:8080/clash-for-Miwifi/"
|
||||
#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')
|
||||
[ -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"
|
||||
@@ -45,7 +46,8 @@ fi
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
tarurl=$url@release_new/bin/clashfm.tar.gz
|
||||
#tarurl=$url@$release_new/bin/clashfm.tar.gz
|
||||
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
|
||||
@@ -59,18 +61,33 @@ echo 开始解压文件!
|
||||
mkdir -p $dir/clash > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
|
||||
#判断系统类型写入不同的启动文件
|
||||
if [ -n "$(cat /proc/version | grep -i openwrt)" ];then
|
||||
mv $dir/clash/clashservice /etc/init.d/clash #将rc服务文件移动到系统目录
|
||||
chmod 777 /etc/init.d/clash #授予权限
|
||||
rm -rf $dir/clash/clash.service
|
||||
else
|
||||
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/
|
||||
mv $dir/clash/clash.service $sysdir/clash.service #将service服务文件移动到系统目录
|
||||
sed -i "s%/etc/clash%${dir}/clash%g" $sysdir/clash.service
|
||||
rm -rf $dir/clash/clashservice
|
||||
rm -rf /etc/init.d/clash
|
||||
fi
|
||||
#初始化文件目录
|
||||
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
|
||||
chmod 777 /etc/init.d/clash #授予权限
|
||||
if [ ! -f "$dir/clash/mark" ]; then
|
||||
cat >$dir/clash/mark<<EOF
|
||||
#标识clash运行状态的文件,不明勿动!
|
||||
EOF
|
||||
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=$versionsh" $dir/clash/mark
|
||||
sed -i "1i\versionsh_l=$release_new" $dir/clash/mark
|
||||
#设置环境变量
|
||||
shtype=sh&&[ -n $(ls -l /bin/sh|grep -o dash) ]&&shtype=bash
|
||||
|
||||
sed -i '/alias clash=*/'d /etc/profile
|
||||
echo "alias clash=\"$shtype $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d /etc/profile
|
||||
|
||||
Reference in New Issue
Block a user