chore: import.sh: read config from env

This commit is contained in:
Paul Pan 2024-01-05 15:03:04 +08:00
parent 99d8bd6b80
commit 2fe58482db
Signed by: Paul
GPG Key ID: D639BDF5BA578AF4

View File

@ -3,22 +3,37 @@
WORKSPACE=$(cd "$(dirname "$0")"/.. && pwd) WORKSPACE=$(cd "$(dirname "$0")"/.. && pwd)
. "$WORKSPACE"/scripts/common.sh . "$WORKSPACE"/scripts/common.sh
read -p "Enter HTTP API Endpoint: " -r endpoint if [ -z "$WOJ_ENDPOINT" ]; then
if [ -z "$endpoint" ]; then read -p "Enter HTTP API Endpoint: " -r endpoint
log_error "[-] HTTP API Endpoint cannot be empty" if [ -z "$endpoint" ]; then
exit 1 log_error "[-] HTTP API Endpoint cannot be empty"
exit 1
fi
else
endpoint="$WOJ_ENDPOINT"
log_info "[*] Using HTTP API Endpoint: $endpoint"
fi fi
read -p "Enter Token: " -r token if [ -z "$WOJ_TOKEN" ]; then
if [ -z "$token" ]; then read -p "Enter Token: " -r token
log_error "[-] Token cannot be empty" if [ -z "$token" ]; then
exit 1 log_error "[-] Token cannot be empty"
exit 1
fi
else
token="$WOJ_TOKEN"
log_info "[*] Using Token: $token"
fi fi
read -p "Enter Directory: " -r directory if [ -z "$WOJ_DIR" ]; then
if [ ! -d "$directory" ]; then read -p "Enter Directory: " -r directory
log_error "[-] Not a Directory" if [ ! -d "$directory" ]; then
exit 1 log_error "[-] Not a Directory"
exit 1
fi
else
directory="$WOJ_DIR"
log_info "[*] Using Directory: $directory"
fi fi
for problem in "$directory/"*; do for problem in "$directory/"*; do