From e8f37e5df882f3b52b9d0554286aae6cd0939b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E5=B0=8F=E9=99=8C?= Date: Sun, 13 Oct 2024 16:12:32 +0800 Subject: [PATCH] 111 --- index.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 index.sh diff --git a/index.sh b/index.sh new file mode 100644 index 0000000..9fcfebc --- /dev/null +++ b/index.sh @@ -0,0 +1,33 @@ +#!/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 \ No newline at end of file