From 567cb7d737023e26ec58403c6f28f109e212d379 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Tue, 14 Oct 2025 22:35:24 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20start.sh=E8=84=9A=E6=9C=AC=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=A0=B9=E6=8D=AE=E5=BD=93=E5=89=8D=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E4=BD=BF=E7=94=A8sudo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- start.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/start.sh b/start.sh index 1f3bb7ca9..cc06b7df1 100755 --- a/start.sh +++ b/start.sh @@ -1,6 +1,14 @@ # set -e + +# 设置SUDO命令 +if [[ "$(uname -s)" == "Linux" ]]; then + SUDO_CMD="sudo" +else + SUDO_CMD="" +fi + echo "即将删除packages下除ui之外的其他目录,按y确认(如果您没有修改过源码,按y即可)" read -p "y/n: " confirm if [ $confirm != "y" ]; then @@ -25,30 +33,30 @@ done echo "安装pnpm, 前提是已经安装了nodejs" -sudo npm install -g pnpm --registry https://registry.npmmirror.com +$SUDO_CMD npm install -g pnpm --registry https://registry.npmmirror.com echo "安装依赖" -sudo pnpm install --registry https://registry.npmmirror.com +$SUDO_CMD pnpm install --registry https://registry.npmmirror.com echo "开始构建" echo "构建certd-client" export NODE_OPTIONS=--max-old-space-size=32768 cd packages/ui/certd-client -sudo -E pnpm run build +$SUDO_CMD -E pnpm run build cp -r dist/* ../certd-server/public echo "构建certd-server" cd ../certd-server -sudo -E pnpm run build +$SUDO_CMD -E pnpm run build echo "构建完成" echo "启动服务" # 前台运行 if [ $confirmNohup != "y" ]; then echo "当前运行模式为前台运行,ctrl+c或者关闭ssh将会停止运行" - sudo pnpm run start + $SUDO_CMD pnpm run start else echo "当前运行模式为后台运行,可以通过tail -f ./certd.log 命令查看日志" - nohup sudo pnpm run start > certd.log & + nohup $SUDO_CMD pnpm run start > certd.log & fi