33 lines
791 B
Bash
33 lines
791 B
Bash
#!/bin/bash
|
|
|
|
# 定义文件和端口
|
|
FILE="index.js"
|
|
PORT=9001
|
|
|
|
# 检查 index.js 是否存在,如果存在则删除
|
|
if [ -f "$FILE" ]; then
|
|
echo "$FILE 存在,正在删除..."
|
|
rm -f "$FILE"
|
|
echo "$FILE 已删除"
|
|
fi
|
|
|
|
# 检查 9001 端口是否被占用
|
|
if lsof -i:$PORT; then
|
|
echo "端口 $PORT 被占用,正在杀死相关进程..."
|
|
# 获取占用端口的进程 ID 并杀死它
|
|
lsof -ti:$PORT | xargs kill -9
|
|
echo "端口 $PORT 已释放"
|
|
else
|
|
echo "端口 $PORT 未被占用"
|
|
fi
|
|
|
|
# 下载 index.js 并执行
|
|
echo "正在下载 index.js..."
|
|
curl -o $FILE https://x-mo.cn:9009/XiaoMo/alist-proxy/raw/branch/master/index.js
|
|
|
|
if [ $? -eq 0 ]; then
|
|
echo "下载完成,正在执行 $FILE..."
|
|
node $FILE port=$PORT
|
|
else
|
|
echo "下载失败"
|
|
fi |