From b21fbad8a33a9eb6daf58edd83722af3ad969a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Mon, 13 May 2024 16:57:03 +0800 Subject: [PATCH] refactor: boot scipt --- script/napcat.sh | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/script/napcat.sh b/script/napcat.sh index 70553086..a8058e66 100644 --- a/script/napcat.sh +++ b/script/napcat.sh @@ -1,4 +1,21 @@ #!/bin/bash -SCRIPT_DIR=$(realpath $(dirname "${BASH_SOURCE[0]}")) -export ELECTRON_RUN_AS_NODE=1 -/opt/QQ/qq ${SCRIPT_DIR}/napcat.cjs $@ + +get_script_dir() { + local script_path="${1:-$0}" + local script_dir + script_path=$(readlink -f "$script_path") + script_dir=$(dirname "$script_path") + + echo "$script_dir" +} + +SCRIPT_DIR=$(get_script_dir) + +ELECTRON_RUN_AS_NODE=1 + +if ! [ -x /opt/QQ/qq ]; then + echo "Error: /opt/QQ/qq is not executable or does not exist." >&2 + exit 1 +fi + +/opt/QQ/qq "${SCRIPT_DIR}/napcat.cjs" "$@"