Skip to content

Commit 0344aed

Browse files
mbolognaclaude
andcommitted
fix: disable pipefail around tr|head token generation
tr gets SIGPIPE (exit 141) when head exits after reading enough bytes. With set -euo pipefail this aborted the entrypoint on first run, causing the container to stop immediately after "First run detected". Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 535b96a commit 0344aed

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

entrypoint.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ mkdir -p "${CONDUWUIT_DIR}/db" "${MAUTRIX_DIR}"
2727
if [ ! -f "${MAUTRIX_DIR}/registration.yaml" ]; then
2828
echo "[init] First run detected — generating mautrix-meta registration tokens..."
2929

30-
# Generate 64-char hex tokens without openssl (coreutils only)
30+
# Generate 64-char hex tokens without openssl (coreutils only).
31+
# pipefail must be off here: tr gets SIGPIPE (exit 141) when head exits,
32+
# which would abort the script under set -euo pipefail.
33+
set +o pipefail
3134
AS_TOKEN=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 64)
3235
HS_TOKEN=$(tr -dc 'a-f0-9' < /dev/urandom | head -c 64)
36+
set -o pipefail
3337

3438
# Appservice registration — read by conduwuit at startup.
3539
# The regex defines which Matrix user IDs the bridge is allowed to create
@@ -130,8 +134,11 @@ fi
130134
if [ ! -f "${CONDUWUIT_DIR}/conduwuit.toml" ]; then
131135
echo "[init] Generating conduwuit config..."
132136

133-
# Allow overriding the registration token via environment variable
137+
# Allow overriding the registration token via environment variable.
138+
# pipefail off for the same SIGPIPE reason as the token generation above.
139+
set +o pipefail
134140
REG_TOKEN="${MATRIX_REGISTRATION_TOKEN:-$(tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c 32)}"
141+
set -o pipefail
135142

136143
cat > "${CONDUWUIT_DIR}/conduwuit.toml" <<EOF
137144
[global]

0 commit comments

Comments
 (0)