diff --git a/Dockerfile b/Dockerfile index 4d9c3eb..3cdab04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,12 @@ MAINTAINER Andrey Arapov RUN apk update && \ apk upgrade && \ - apk add tzdata rsyslog postfix runit ca-certificates + apk add postfix runit socklog tzdata ca-certificates && \ + rm -rf /etc/service # tzdata - for passing TZ environment variable. -# rsyslog - to log postfix service into /var/log/maillog file. +# socklog - collect all logs which come to /dev/log. -COPY service /etc/service/ +COPY service /etc/service ENTRYPOINT runsvdir -P /etc/service +#ENTRYPOINT chpst -Unobody socklog unix /dev/log & postfix start-fg diff --git a/service-disabled/rsyslogd/finish b/service-disabled/rsyslogd/finish new file mode 100755 index 0000000..6a83bc5 --- /dev/null +++ b/service-disabled/rsyslogd/finish @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "${PWD##*/}: Exitted with $1 (signal: $2)" +[ $1 -ne 0 ] && ( echo "${PWD##*/}: rc != 0, sleeping for 5 seconds ..."; sleep 5 ) diff --git a/service/rsyslogd/log/run b/service-disabled/rsyslogd/log/run similarity index 100% rename from service/rsyslogd/log/run rename to service-disabled/rsyslogd/log/run diff --git a/service/rsyslogd/run b/service-disabled/rsyslogd/run similarity index 68% rename from service/rsyslogd/run rename to service-disabled/rsyslogd/run index 6387ba9..d45e55c 100755 --- a/service/rsyslogd/run +++ b/service-disabled/rsyslogd/run @@ -1,3 +1,6 @@ #!/bin/sh + +echo "${PWD##*/}: started." + touch /var/log/maillog exec /usr/sbin/rsyslogd -n 2>&1 diff --git a/service/logger/finish b/service/logger/finish new file mode 100755 index 0000000..6a83bc5 --- /dev/null +++ b/service/logger/finish @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "${PWD##*/}: Exitted with $1 (signal: $2)" +[ $1 -ne 0 ] && ( echo "${PWD##*/}: rc != 0, sleeping for 5 seconds ..."; sleep 5 ) diff --git a/service/logger/run b/service/logger/run new file mode 100755 index 0000000..202f60a --- /dev/null +++ b/service/logger/run @@ -0,0 +1,10 @@ +#!/bin/sh +# Collect all logs which come to /dev/log +exec 2>&1 + +echo "${PWD##*/}: started." + +set -x +exec chpst -Unobody socklog unix /dev/log +# exec socklog unix /dev/log +# exec socat UNIX-LISTEN:/dev/log,reuseaddr,fork - diff --git a/service/postfix/finish b/service/postfix/finish index 8d7ce6a..6a83bc5 100755 --- a/service/postfix/finish +++ b/service/postfix/finish @@ -1,3 +1,4 @@ #!/bin/sh -[ $1 -ne 0 ] && ( echo "${PWD##*/}: Exitted with $1 (signal: $2)"; sleep 5 ) +echo "${PWD##*/}: Exitted with $1 (signal: $2)" +[ $1 -ne 0 ] && ( echo "${PWD##*/}: rc != 0, sleeping for 5 seconds ..."; sleep 5 ) diff --git a/service/postfix/run b/service/postfix/run index 66abfc7..74232fb 100755 --- a/service/postfix/run +++ b/service/postfix/run @@ -1,5 +1,7 @@ #!/bin/sh +echo "${PWD##*/}: started." + # WORKAROUND: # postfix has to be aware of the DNS servers # without this workaround it uses 127.0.0.1:53 for some unknown (yet) reason... @@ -13,6 +15,8 @@ set -e postfix check 2>&1 # run Postfix -# exec /usr/lib/postfix/master 2>&1 -# after postfix 3.3.0 use postfix start-fg command -exec postfix start-fg 2>&1 +exec /usr/lib/postfix/master 2>&1 + +# Do not use 'postfix start-fg' command since it does not handle the signals, +# e.g. if you do 'sv restart postfix', postfix/master will NOT receive the +# SIGTERM signal. diff --git a/service/rsyslogd/finish b/service/rsyslogd/finish deleted file mode 100755 index 8d7ce6a..0000000 --- a/service/rsyslogd/finish +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -[ $1 -ne 0 ] && ( echo "${PWD##*/}: Exitted with $1 (signal: $2)"; sleep 5 )