From 2d8b3c6b8a20747cb1f287d836fdddfb2c4e09f4 Mon Sep 17 00:00:00 2001 From: Doctor Delpy Date: Thu, 11 Dec 2025 09:27:39 +0300 Subject: [PATCH] improve start sh --- start.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index b3f50bd..03e725c 100755 --- a/start.sh +++ b/start.sh @@ -5,6 +5,53 @@ echo "MY Network Node setup (interactive)" SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd) BASE_DIR=$(cd "$SCRIPT_DIR/.." && pwd) + +GIT_BASE_URL_DEFAULT="https://git.projscale.dev/my-dev" +GIT_BASE_URL="${GIT_BASE_URL:-$GIT_BASE_URL_DEFAULT}" + +ensure_git() { + if ! command -v git >/dev/null 2>&1; then + echo "git is required to clone dependent repositories (uploader-bot, web2-client, converter-module)." >&2 + echo "Please install git or clone these repositories manually under $BASE_DIR." >&2 + exit 1 + fi +} + +ensure_repo_required() { + local name="$1" + local dir="$2" + local url="$3" + + if [[ -d "$dir" ]]; then + echo "Found $name at $dir" + return + fi + + echo "Cloning $name from $url into $dir ..." + git clone "$url" "$dir" +} + +ensure_repo_optional() { + local name="$1" + local dir="$2" + local url="$3" + + if [[ -d "$dir" ]]; then + echo "Found optional $name at $dir" + return + fi + + echo "Cloning optional $name from $url into $dir ..." + if ! git clone "$url" "$dir"; then + echo "Warning: failed to clone optional repository $name from $url; continuing without it." >&2 + fi +} + +ensure_git +ensure_repo_required "uploader-bot" "$BASE_DIR/uploader-bot" "${GIT_BASE_URL}/uploader-bot.git" +ensure_repo_required "web2-client" "$BASE_DIR/web2-client" "${GIT_BASE_URL}/web2-client.git" +ensure_repo_optional "converter-module" "$BASE_DIR/converter-module" "${GIT_BASE_URL}/converter-module.git" + ENV_FILE="$SCRIPT_DIR/.env" PROJECT_EXAMPLE="$BASE_DIR/.env.example" if [[ ! -f "$SCRIPT_DIR/.env.example" && -f "$PROJECT_EXAMPLE" ]]; then @@ -16,8 +63,8 @@ if [[ ! -f "$ENV_FILE" ]]; then if [[ -f "$EXAMPLE_FILE" ]]; then cp "$EXAMPLE_FILE" "$ENV_FILE" else - echo "Missing .env.example; cannot continue" >&2 - exit 1 + echo "No .env or .env.example found; starting with a fresh .env for interactive setup." + touch "$ENV_FILE" fi fi