mirror of
https://github.com/BaaRai/ARTEX.git
synced 2026-12-03 13:11:05 +00:00
fix(install): normalize a CRLF .env before reading it
A Windows checkout (core.autocrlf=true) materializes .env.example as CRLF, so every value carries a trailing CR. ensure_runner_token matched the empty ARTEX_RUNNER_TOKEN line through '.', left it empty, and compose failed the required-variable interpolation before the build. Both install.sh and update.sh now convert .env to LF first and require a non-whitespace value before treating the token as set. Found by the isolated fresh-install test: the copied .env reproduced the failure before the fix and installs cleanly after it.
This commit is contained in:
parent
7bfe3fa0b5
commit
ce10819cc8
3 changed files with 1375 additions and 1349 deletions
2695
CHANGELOG.md
2695
CHANGELOG.md
File diff suppressed because it is too large
Load diff
15
install.sh
15
install.sh
|
|
@ -43,12 +43,23 @@ stamp_version(){
|
|||
fi
|
||||
ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}"
|
||||
}
|
||||
# normalize_env rewrites a CRLF .env as LF. A Windows checkout with
|
||||
# core.autocrlf=true materializes CRLF, and every value then carries a trailing
|
||||
# \r: compose reports an empty required variable and PostgreSQL receives a
|
||||
# password with a stray CR. One conversion keeps the rest of the script simple.
|
||||
normalize_env(){
|
||||
[ -f .env ] || return 0
|
||||
grep -q $'\r' .env 2>/dev/null || return 0
|
||||
sed -i.bak 's/\r$//' .env && rm -f .env.bak
|
||||
ok ".env converted from CRLF to LF"
|
||||
}
|
||||
|
||||
# ensure_runner_token fills ARTEX_RUNNER_TOKEN in .env once. The panel and the
|
||||
# runner authenticate the internal execution API with it; an empty value makes
|
||||
# the panel fail closed, so the token is generated with the rest of the setup.
|
||||
ensure_runner_token(){
|
||||
[ -f .env ] || return 0
|
||||
grep -q '^ARTEX_RUNNER_TOKEN=.' .env && return 0
|
||||
grep -q '^ARTEX_RUNNER_TOKEN=[^[:space:]]' .env && return 0
|
||||
set_env ARTEX_RUNNER_TOKEN "$(rand)"
|
||||
ok "ARTEX_RUNNER_TOKEN generated"
|
||||
}
|
||||
|
|
@ -153,6 +164,7 @@ ensure_buildx(){
|
|||
install_docker(){
|
||||
ensure_docker
|
||||
ensure_buildx
|
||||
normalize_env
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.example .env 2>/dev/null || true
|
||||
local pw key
|
||||
|
|
@ -161,6 +173,7 @@ install_docker(){
|
|||
sed -i.bak "s|^POSTGRES_PASSWORD=.*|POSTGRES_PASSWORD=$(sed_repl "$pw")|" .env
|
||||
sed -i.bak "s|^ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=$(sed_repl "$key")|" .env
|
||||
rm -f .env.bak
|
||||
normalize_env
|
||||
ok ".env generated (POSTGRES_PASSWORD set)"
|
||||
else
|
||||
info "reusing existing .env"
|
||||
|
|
|
|||
14
update.sh
14
update.sh
|
|
@ -47,12 +47,23 @@ stamp_version(){
|
|||
ok "Build identity: ${BUILD_VERSION}${BUILD_REVISION:+ (${BUILD_REVISION:0:12})}"
|
||||
}
|
||||
|
||||
# normalize_env rewrites a CRLF .env as LF. A Windows checkout with
|
||||
# core.autocrlf=true materializes CRLF, and every value then carries a trailing
|
||||
# \r: compose reports an empty required variable and PostgreSQL receives a
|
||||
# password with a stray CR.
|
||||
normalize_env(){
|
||||
[ -f .env ] || return 0
|
||||
grep -q $'\r' .env 2>/dev/null || return 0
|
||||
sed -i.bak 's/\r$//' .env && rm -f .env.bak
|
||||
ok ".env converted from CRLF to LF"
|
||||
}
|
||||
|
||||
# ensure_runner_token fills ARTEX_RUNNER_TOKEN in .env once. The panel and the
|
||||
# runner authenticate the internal execution API with it; an empty value makes
|
||||
# the panel fail closed, so an existing .env gets one before the upgrade.
|
||||
ensure_runner_token(){
|
||||
[ -f .env ] || return 0
|
||||
grep -q '^ARTEX_RUNNER_TOKEN=.' .env && return 0
|
||||
grep -q '^ARTEX_RUNNER_TOKEN=[^[:space:]]' .env && return 0
|
||||
set_env ARTEX_RUNNER_TOKEN "$(rand)"
|
||||
ok "ARTEX_RUNNER_TOKEN generated"
|
||||
}
|
||||
|
|
@ -84,6 +95,7 @@ update_docker(){
|
|||
|| die "docker buildx not detected; the image build needs it (see the Docker section of the README)"
|
||||
[ -f .env ] || die ".env not found; run ./install.sh first to complete the initial deployment"
|
||||
|
||||
normalize_env
|
||||
ensure_runner_token
|
||||
# Touch only artex and artex-runner: postgres is pinned to 16-alpine and does not
|
||||
# need upgrading along (pulling it wastes bandwidth, and a major version bump
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue