不同操作系统CPU架构获取兼容性优化。
This commit is contained in:
parent
171fb0d37c
commit
e7a5055dd1
52
restart.sh
52
restart.sh
|
@ -27,12 +27,13 @@ action() {
|
||||||
|
|
||||||
# 函数,判断命令是否正常执行
|
# 函数,判断命令是否正常执行
|
||||||
if_success() {
|
if_success() {
|
||||||
if [ $? -eq 0 ]; then
|
local ReturnStatus=$3
|
||||||
action "$1" /bin/true
|
if [ $ReturnStatus -eq 0 ]; then
|
||||||
else
|
action "$1" /bin/true
|
||||||
action "$2" /bin/false
|
else
|
||||||
exit 1
|
action "$2" /bin/false
|
||||||
fi
|
exit 1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 定义路劲变量
|
# 定义路劲变量
|
||||||
|
@ -48,25 +49,38 @@ PID_NUM=`ps -ef | grep [c]lash-linux-a | wc -l`
|
||||||
PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
|
PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
|
||||||
if [ $PID_NUM -ne 0 ]; then
|
if [ $PID_NUM -ne 0 ]; then
|
||||||
kill -9 $PID
|
kill -9 $PID
|
||||||
|
ReturnStatus=$?
|
||||||
# ps -ef | grep [c]lash-linux-a | awk '{print $2}' | xargs kill -9
|
# ps -ef | grep [c]lash-linux-a | awk '{print $2}' | xargs kill -9
|
||||||
fi
|
fi
|
||||||
if_success $Text1 $Text2
|
if_success $Text1 $Text2 $ReturnStatus
|
||||||
|
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
## 重启启动clash服务
|
## 获取CPU架构
|
||||||
Text3="服务启动成功!"
|
if /bin/arch &>/dev/null; then
|
||||||
Text4="服务启动失败!"
|
CpuArch=`/bin/arch`
|
||||||
# 获取CPU架构 x86_64/aarch64
|
elif /usr/bin/arch &>/dev/null; then
|
||||||
get_arch=`/bin/arch`
|
CpuArch=`/usr/bin/arch`
|
||||||
if [[ $get_arch =~ "x86_64" ]]; then
|
elif /bin/uname -m &>/dev/null; then
|
||||||
nohup $Server_Dir/bin/clash-linux-amd64 -d $Conf_Dir &> $Log_Dir/clash.log &
|
CpuArch=`/bin/uname -m`
|
||||||
if_success $Text3 $Text4
|
|
||||||
elif [[ $get_arch =~ "aarch64" ]]; then
|
|
||||||
nohup $Server_Dir/bin/clash-linux-armv7 -d $Conf_Dir &> $Log_Dir/clash.log &
|
|
||||||
if_success $Text3 $Text4
|
|
||||||
else
|
else
|
||||||
echo -e "\033[31m[ERROR] Unsupported CPU Architecture!\033[0m"
|
echo -e "\033[31m\n[ERROR] Failed to obtain CPU architecture!\033[0m"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
## 重启启动clash服务
|
||||||
|
Text5="服务启动成功!"
|
||||||
|
Text6="服务启动失败!"
|
||||||
|
if [[ $CpuArch =~ "x86_64" ]]; then
|
||||||
|
nohup $Server_Dir/bin/clash-linux-amd64 -d $Conf_Dir &> $Log_Dir/clash.log &
|
||||||
|
ReturnStatus=$?
|
||||||
|
if_success $Text5 $Text6 $ReturnStatus
|
||||||
|
elif [[ $CpuArch =~ "aarch64" ]]; then
|
||||||
|
nohup $Server_Dir/bin/clash-linux-armv7 -d $Conf_Dir &> $Log_Dir/clash.log &
|
||||||
|
ReturnStatus=$?
|
||||||
|
if_success $Text5 $Text6 $ReturnStatus
|
||||||
|
else
|
||||||
|
echo -e "\033[31m\n[ERROR] Unsupported CPU Architecture!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
10
start.sh
10
start.sh
|
@ -99,10 +99,12 @@ sed -ri "s@^# external-ui:.*@external-ui: ${Dashboard_Dir}@g" $Conf_Dir/config.y
|
||||||
Secret=`grep '^secret: ' $Conf_Dir/config.yaml | grep -Po "(?<=secret: ').*(?=')"`
|
Secret=`grep '^secret: ' $Conf_Dir/config.yaml | grep -Po "(?<=secret: ').*(?=')"`
|
||||||
|
|
||||||
# 获取CPU架构
|
# 获取CPU架构
|
||||||
if arch &>/dev/null; then
|
if /bin/arch &>/dev/null; then
|
||||||
CpuArch=`arch`
|
CpuArch=`/bin/arch`
|
||||||
elif uname -m &>/dev/null; then
|
elif /usr/bin/arch &>/dev/null; then
|
||||||
CpuArch=`uname -m`
|
CpuArch=`/usr/bin/arch`
|
||||||
|
elif /bin/uname -m &>/dev/null; then
|
||||||
|
CpuArch=`/bin/uname -m`
|
||||||
else
|
else
|
||||||
echo -e "\033[31m\n[ERROR] Failed to obtain CPU architecture!\033[0m"
|
echo -e "\033[31m\n[ERROR] Failed to obtain CPU architecture!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user