improve start sh

This commit is contained in:
Doctor Delpy 2025-12-11 09:27:39 +03:00
parent 87a5e1c656
commit 2d8b3c6b8a
1 changed files with 49 additions and 2 deletions

View File

@ -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