From 5dcdfd07050b7acbcbf8240823d9497ade493dc4 Mon Sep 17 00:00:00 2001 From: Deon George Date: Wed, 14 Aug 2019 20:56:48 +1000 Subject: [PATCH] Added supervisor/logrotate and startup dirs use symlinks --- Dockerfile | 18 +++++++++++------- init | 12 ++++++++++-- logrotate.d/sbbsecho | 10 ++++++++++ supervisord.d/cron.conf | 2 ++ 4 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 logrotate.d/sbbsecho create mode 100644 supervisord.d/cron.conf diff --git a/Dockerfile b/Dockerfile index dca4634..878a2b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,11 +5,14 @@ FROM debian:stretch-slim # Base utilities RUN apt-get update \ - && apt-get install -yqq curl procps less zip unzip arj unrar-free lhasa arc zoo logrotate libmozjs185-1.0 cron \ + && apt-get install -yqq curl supervisor procps less zip unzip arj unrar-free lhasa arc zoo logrotate libmozjs185-1.0 cron \ && apt-get -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* +# Set the default timezone for the container +RUN ln -sf /usr/share/zoneinfo/Australia/Melbourne /etc/localtime + # Add in Leenooks' apt repository RUN curl -s http://apt.leenooks.net/setup.sh | sh @@ -31,6 +34,7 @@ RUN apt-get update \ && make RELEASE=1 USE_DOSEMU=1 NO_X=1 JSINCLUDE=/usr/include/js JSLIB=mozjs185 SBBSDIR=/opt/sbbs install \ && rm -rf /opt/sbbs/3rdp /opt/sbbs/src \ && mv /opt/sbbs/ctrl /opt/sbbs/ctrl.orig \ + && mv /opt/sbbs/text /opt/sbbs/text.orig \ && mkdir /opt/sbbs/nodes.orig && mv /opt/sbbs/node[1-4] /opt/sbbs/nodes.orig \ && ln -sf nodes/node1 /opt/sbbs/ \ && ln -sf nodes/node2 /opt/sbbs/ \ @@ -47,12 +51,12 @@ ENV SBBSCTRL=/opt/sbbs/ctrl ENV SBBSEXEC=/opt/sbbs/exec ENV PATH=$PATH:${SBBSEXEC} +VOLUME [ "/var/lib/zerotier-one" ] +VOLUME [ "/opt/sbbs/data","/opt/sbbs/ctrl","/opt/sbbs/nodes","/opt/sbbs/fido","/opt/sbbs/text" ] + +COPY logrotate.d /etc/logrotate.d/ +COPY supervisord.d /etc/supervisor/conf.d/ + COPY init /sbin/init ENTRYPOINT [ "/sbin/init" ] CMD ["sbbs"] - -VOLUME [ "/var/lib/zerotier-one" ] -VOLUME [ "/opt/sbbs/data","/opt/sbbs/ctrl","/opt/sbbs/nodes","/opt/sbbs/fido" ] - -# Set the default timezone for the container -RUN ln -sf /usr/share/zoneinfo/Australia/Melbourne /etc/localtime diff --git a/init b/init index 9d92dc3..9ecf62b 100755 --- a/init +++ b/init @@ -7,12 +7,17 @@ export PATH=$PATH:${SBBSEXEC} if [ ! -e "${SBBSCTRL}/sbbs.ini" ]; then echo "* Installing SBBS ctrl files into ${SBBSCTRL}" - cp -a ${SBBSCTRL}.orig/* ${SBBSCTRL} + cp -Ras ${SBBSCTRL}.orig/* ${SBBSCTRL} fi if [ ! -d "${SBBSCTRL}/../nodes/node1" ]; then echo "* Installing SBBS nodes files into ${SBBSCTRL}/../nodes" - cp -Ra ${SBBSCTRL}/../nodes.orig/* ${SBBSCTRL}/../nodes/ + cp -Ras ${SBBSCTRL}/../nodes.orig/* ${SBBSCTRL}/../nodes/ +fi + +if [ ! -e "${SBBSCTRL}/../text/answer.msg" ]; then + echo "* Installing SBBS text files into ${SBBSCTRL}/../text" + cp -Ras ${SBBSCTRL}/../text.orig/* ${SBBSCTRL}/../text/ fi if [ -x /usr/sbin/zerotier-one -a -n "${ENABLE_ZT}" ]; then @@ -21,4 +26,7 @@ if [ -x /usr/sbin/zerotier-one -a -n "${ENABLE_ZT}" ]; then /usr/sbin/zerotier-one -d fi +# Start Supervisord +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf + exec "$@" diff --git a/logrotate.d/sbbsecho b/logrotate.d/sbbsecho new file mode 100644 index 0000000..3c59bf5 --- /dev/null +++ b/logrotate.d/sbbsecho @@ -0,0 +1,10 @@ +/opt/sbbs/data/*.log { + daily + compress + rotate 31 + dateext + olddir /opt/sbbs/data/old + missingok + createolddir 775 root root + notifempty +} diff --git a/supervisord.d/cron.conf b/supervisord.d/cron.conf new file mode 100644 index 0000000..c072909 --- /dev/null +++ b/supervisord.d/cron.conf @@ -0,0 +1,2 @@ +[program:cron] +command=/usr/sbin/cron -f