Merge pull request #728 from BaaRai/fix/install-env-crlf

fix(install): normalize a CRLF .env before reading it
This commit is contained in:
BaaRai
2026-12-01 02:09:44 +01:00
committed by GitHub
3 changed files with 1375 additions and 1349 deletions
+1348 -1347
View File
File diff suppressed because it is too large Load Diff
+14 -1
View File
@@ -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"
+13 -1
View File
@@ -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