summaryrefslogtreecommitdiff
path: root/mail/entrypoint.sh
diff options
context:
space:
mode:
authoryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-01 21:28:55 +0900
committeryyamashita <yyamashita@hetzner.yyamashita.com>2026-06-01 21:28:55 +0900
commite95b343d694acba88cc08fb8e7092d54b3ee6cd3 (patch)
treeb07183dbc1e6e75dbfbbcb7f3d84c39a99d0a9a5 /mail/entrypoint.sh
parent665f6a7d34643aee0b2aefe00fdd7ca1c5ff593d (diff)
entrypoint: use python3 for resolv.conf edit (sed -i fails on bind mount)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'mail/entrypoint.sh')
-rwxr-xr-xmail/entrypoint.sh11
1 files changed, 8 insertions, 3 deletions
diff --git a/mail/entrypoint.sh b/mail/entrypoint.sh
index 49d8d64..a8b87b4 100755
--- a/mail/entrypoint.sh
+++ b/mail/entrypoint.sh
@@ -15,9 +15,14 @@ if [[ ! -f "$KEY_FILE" ]]; then
fi
# Docker の embedded DNS (127.0.0.11) は MX クエリを解決できないことがあるため
-# 外部 DNS に差し替える(コンテナ内の名前解決は不要なので問題なし)
-sed -i 's/nameserver 127.0.0.11/nameserver 8.8.8.8/' /etc/resolv.conf
-echo 'nameserver 1.1.1.1' >> /etc/resolv.conf
+# 外部 DNS に差し替える(sed -i は bind mount で失敗するため python3 で書き換え)
+python3 - << 'PYEOF'
+path = '/etc/resolv.conf'
+content = open(path).read().replace('nameserver 127.0.0.11', 'nameserver 8.8.8.8')
+if '1.1.1.1' not in content:
+ content += 'nameserver 1.1.1.1\n'
+open(path, 'w').write(content)
+PYEOF
# Start rsyslog for Postfix logging
rsyslogd