不同操作系统CPU架构获取兼容性优化。
This commit is contained in:
parent
171fb0d37c
commit
e7a5055dd1
42
restart.sh
42
restart.sh
|
@ -27,7 +27,8 @@ action() {
|
|||
|
||||
# 函数,判断命令是否正常执行
|
||||
if_success() {
|
||||
if [ $? -eq 0 ]; then
|
||||
local ReturnStatus=$3
|
||||
if [ $ReturnStatus -eq 0 ]; then
|
||||
action "$1" /bin/true
|
||||
else
|
||||
action "$2" /bin/false
|
||||
|
@ -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}'`
|
||||
if [ $PID_NUM -ne 0 ]; then
|
||||
kill -9 $PID
|
||||
ReturnStatus=$?
|
||||
# ps -ef | grep [c]lash-linux-a | awk '{print $2}' | xargs kill -9
|
||||
fi
|
||||
if_success $Text1 $Text2
|
||||
if_success $Text1 $Text2 $ReturnStatus
|
||||
|
||||
sleep 3
|
||||
|
||||
## 重启启动clash服务
|
||||
Text3="服务启动成功!"
|
||||
Text4="服务启动失败!"
|
||||
# 获取CPU架构 x86_64/aarch64
|
||||
get_arch=`/bin/arch`
|
||||
if [[ $get_arch =~ "x86_64" ]]; then
|
||||
nohup $Server_Dir/bin/clash-linux-amd64 -d $Conf_Dir &> $Log_Dir/clash.log &
|
||||
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
|
||||
## 获取CPU架构
|
||||
if /bin/arch &>/dev/null; then
|
||||
CpuArch=`/bin/arch`
|
||||
elif /usr/bin/arch &>/dev/null; then
|
||||
CpuArch=`/usr/bin/arch`
|
||||
elif /bin/uname -m &>/dev/null; then
|
||||
CpuArch=`/bin/uname -m`
|
||||
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
|
||||
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: ').*(?=')"`
|
||||
|
||||
# 获取CPU架构
|
||||
if arch &>/dev/null; then
|
||||
CpuArch=`arch`
|
||||
elif uname -m &>/dev/null; then
|
||||
CpuArch=`uname -m`
|
||||
if /bin/arch &>/dev/null; then
|
||||
CpuArch=`/bin/arch`
|
||||
elif /usr/bin/arch &>/dev/null; then
|
||||
CpuArch=`/usr/bin/arch`
|
||||
elif /bin/uname -m &>/dev/null; then
|
||||
CpuArch=`/bin/uname -m`
|
||||
else
|
||||
echo -e "\033[31m\n[ERROR] Failed to obtain CPU architecture!\033[0m"
|
||||
exit 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user