Add support for gpu-rent.vars and enhance git update functionality

- Updated .gitignore to include gpu-rent.vars.
- Modified env.example to introduce the UPDATE_GIT variable for controlling git updates during execution.
- Implemented Import-GpuRentVars function in gpu-rent.ps1 to load environment variables from gpu-rent.vars.
- Enhanced gpu-rent.sh to support loading variables from gpu-rent.vars and added logic for handling default and extra arguments.
- Updated CLI documentation to reflect the new gpu-rent.vars file and its usage in configuration.
- Improved bootstrap and provisioning logic to conditionally perform git updates based on the new configuration.
This commit is contained in:
Leonid Pershin
2026-08-21 05:01:53 +03:00
parent ec42830579
commit a9cf2e0f90
23 changed files with 515 additions and 39 deletions
+48 -1
View File
@@ -5,6 +5,37 @@ set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$ROOT"
load_vars_file() {
local file="$1"
[[ -f "$file" ]] || return 0
while IFS= read -r line || [[ -n "$line" ]]; do
line="${line#"${line%%[![:space:]]*}"}"
line="${line%"${line##*[![:space:]]}"}"
[[ -z "$line" || "$line" == \#* ]] && continue
if [[ "$line" == [eE][xX][pP][oO][rR][tT][[:space:]]* ]]; then
line="${line#*[eE][xX][pP][oO][rR][tT]}"
line="${line#"${line%%[![:space:]]*}"}"
fi
[[ "$line" != *=* ]] && continue
local key="${line%%=*}"
local val="${line#*=}"
key="${key%"${key##*[![:space:]]}"}"
key="${key#"${key%%[![:space:]]*}"}"
val="${val#"${val%%[![:space:]]*}"}"
val="${val%"${val##*[![:space:]]}"}"
if [[ ${#val} -ge 2 ]]; then
local q="${val:0:1}"
if [[ ( "$q" == '"' || "$q" == "'" ) && "${val: -1}" == "$q" ]]; then
val="${val:1:${#val}-2}"
fi
fi
[[ -z "$key" ]] && continue
if [[ -z "${!key+x}" || -z "${!key}" ]]; then
export "$key=$val"
fi
done <"$file"
}
ok_py() {
local exe="$1"
shift || true
@@ -64,5 +95,21 @@ if [[ ! -f "$ROOT/extensions.yaml" && -f "$ROOT/extensions.example.yaml" ]]; the
cp "$ROOT/extensions.example.yaml" "$ROOT/extensions.yaml"
echo "gpu-rent: created extensions.yaml"
fi
if [[ ! -f "$ROOT/gpu-rent.vars" && -f "$ROOT/gpu-rent.vars.example" ]]; then
cp "$ROOT/gpu-rent.vars.example" "$ROOT/gpu-rent.vars"
echo "gpu-rent: created gpu-rent.vars"
fi
exec "$VENV_PY" -m gpu_rent "$@"
load_vars_file "$ROOT/gpu-rent.vars"
ARGS=("$@")
if [[ ${#ARGS[@]} -eq 0 && -n "${GPU_RENT_DEFAULT_ARGS:-}" ]]; then
# shellcheck disable=SC2206
ARGS=(${GPU_RENT_DEFAULT_ARGS})
fi
if [[ -n "${GPU_RENT_EXTRA_ARGS:-}" ]]; then
# shellcheck disable=SC2206
ARGS+=(${GPU_RENT_EXTRA_ARGS})
fi
exec "$VENV_PY" -m gpu_rent "${ARGS[@]}"