Created
February 8, 2023 14:35
-
-
Save aoirint/137cff3217d5823b50f9ac056d6301e2 to your computer and use it in GitHub Desktop.
既存のentrypointを置き換えてubuntu/bind9のログを永続化するシェルスクリプト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
{ | |
/usr/local/bin/docker-entrypoint.sh $@ | |
} \ | |
1> >(tee -a >(sed -u "s/^/[$(date -Ins)] /" >> /bind_logs/named_stdout.log) >&1) \ | |
2> >(tee -a >(sed -u "s/^/[$(date -Ins)] /" >> /bind_logs/named_stderr.log) >&2) |
Author
aoirint
commented
Feb 8, 2023
- https://www.techscore.com/blog/2012/12/06/grep-awk-sed-%E3%81%A7%E3%83%90%E3%83%83%E3%83%95%E3%82%A1%E3%81%97%E3%81%AA%E3%81%84%E6%96%B9%E6%B3%95/
- https://manpages.ubuntu.com/manpages/xenial/ja/man1/date.1.html
- https://qiita.com/kitamin/items/9ded5732d78003e104f3
- https://stackoverflow.com/a/74706759
services:
bind9:
image: ubuntu/bind9:9.18-22.04_beta
entrypoint: "/docker-entrypoint.sh"
volumes:
- "./docker-entrypoint.sh:/docker-entrypoint.sh:ro"
こんな感じで
named_stderr.log
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 starting BIND 9.18.1-1ubuntu1.3-Ubuntu (Stable Release) <id:>
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 running on Linux x86_64 5.4.0-137-generic #154-Ubuntu SMP Thu Jan 5 17:03:22 UTC 2023
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 built with '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--libdir=/usr/lib/x86_64-linux-gnu' '--sysconfdir=/etc/bind' '--with-python=python3' '--localstatedir=/' '--enable-threads' '--enable-largefile' '--with-libtool' '--enable-shared' '--disable-static' '--with-gost=no' '--with-openssl=/usr' '--with-gssapi=yes' '--with-libidn2' '--with-json-c' '--with-lmdb=/usr' '--with-gnu-ld' '--with-maxminddb' '--with-atf=no' '--enable-ipv6' '--enable-rrl' '--enable-filter-aaaa' '--disable-native-pkcs11' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -ffile-prefix-map=/build/bind9-dnYB1i/bind9-9.18.1=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -fno-strict-aliasing -fno-delete-null-pointer-checks -DNO_VERSION_DATE -DDIG_SIGCHASE' 'LDFLAGS=-Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2'
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 running as: named -u bind -g
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 compiled by GCC 11.3.0
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 compiled with OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 linked to OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 compiled with libxml2 version: 2.9.13
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 linked to libxml2 version: 20913
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 compiled with json-c version: 0.15
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 linked to json-c version: 0.15
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 compiled with zlib version: 1.2.11
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 linked to zlib version: 1.2.11
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 ----------------------------------------------------
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 BIND 9 is maintained by Internet Systems Consortium,
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 Inc. (ISC), a non-profit 501(c)(3) public-benefit
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 corporation. Support and training for BIND 9 are
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 available at https://www.isc.org/support
[2023-02-08T23:29:25,100600003+09:00] 08-Feb-2023 23:29:25.107 ----------------------------------------------------
named_stdout.log
[2023-02-08T23:33:30,104053049+09:00] Starting named...
[2023-02-08T23:33:30,104053049+09:00] exec /usr/sbin/named -u "bind" -g ""
Q. 秒以下と秒の区切りが,
になっているのを.
にできませんか?
GNU dateが区切りを,
にすることが原因ですが、変更するオプションはありません。個人的には,
にはなじみがないけれど、ISO 8601的には,
の方が推奨らしい(ISO文書のAbstractにある例も.
になってるけど、ほんとか??)。
- https://www.iso.org/iso-8601-date-and-time-format.html
- https://ja.wikipedia.org/w/index.php?title=ISO_8601&oldid=93550032#%E6%99%82%E5%88%BB
- https://en.wikipedia.org/w/index.php?title=ISO_8601&oldid=1137083292#Times
ISO原典読むの5万くらいする(166 + 187 CHF = 353 CHF ~ 50000 JPY)らしいのでWikipediaで許して...(RFC 3339を読めばいいのかもしれないけど)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment