From e7e4b3eec83958dad8a92fde50df55c605afb552 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 21 Jun 2020 14:01:30 +1000 Subject: [PATCH] Updates and now enabled using daemon mode --- Dockerfile | 7 ++++--- init | 12 ++++++++---- logrotate.d/sbbsecho | 2 ++ start.sh | 37 +++++++++++++++++++++++++++++++++++++ supervisord.d/sbbs.conf | 3 +++ 5 files changed, 54 insertions(+), 7 deletions(-) create mode 100755 start.sh create mode 100644 supervisord.d/sbbs.conf diff --git a/Dockerfile b/Dockerfile index fa3d5c6..8f70d1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,7 +36,7 @@ RUN apt-get update \ # Build SBBS RUN apt-get update \ - && apt-get install -yqq build-essential libnspr4-dev libncurses5-dev libmozjs185-dev cvs wget pkgconf sudo \ + && apt-get install -yqq build-essential libnspr4-dev libncurses5-dev libncursesw5-dev libmozjs185-dev cvs wget pkgconf libcap2-bin sudo \ && mkdir /opt/sbbs && cd /tmp \ && wget http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/GNUmakefile \ && make RELEASE=1 USE_DOSEMU=1 NO_X=1 JSINCLUDE=/usr/include/js JSLIB=mozjs185 SBBSDIR=/opt/sbbs install \ @@ -50,7 +50,7 @@ RUN apt-get update \ && ln -sf nodes/node4 /opt/sbbs/ \ && ln -sf nodes/node5 /opt/sbbs/ \ && find /opt/sbbs -name CVS -type d -exec rm -rf {} + \ - && SUDO_FORCE_REMOVE=yes apt-get -y purge build-essential libnspr4-dev libncurses5-dev libmozjs185-dev cvs wget pkgconf sudo \ + && SUDO_FORCE_REMOVE=yes apt-get -y purge build-essential libnspr4-dev libncurses5-dev libncursesw5-dev libmozjs185-dev cvs wget pkgconf libcap2-bin sudo \ && apt-get -y autoremove \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* @@ -60,6 +60,8 @@ ENV SBBSCTRL=/opt/sbbs/ctrl ENV SBBSEXEC=/opt/sbbs/exec ENV PATH=$PATH:${SBBSEXEC} +COPY start.sh ${SBBSEXEC}/ + VOLUME [ "/var/lib/zerotier-one" ] VOLUME [ "/opt/sbbs/data","/opt/sbbs/ctrl","/opt/sbbs/nodes","/opt/sbbs/fido","/opt/sbbs/text" ] @@ -69,4 +71,3 @@ COPY supervisord.d /etc/supervisor/conf.d/ COPY init /sbin/init ENTRYPOINT [ "/sbin/init" ] -CMD ["sbbs"] diff --git a/init b/init index 9ecf62b..114558d 100755 --- a/init +++ b/init @@ -26,7 +26,11 @@ 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 "$@" +if [ -n "$1" ]; then + echo "* Starting [$@]" + exec "$@" +else + # Start Supervisord + echo "* Starting supervisord" + exec /usr/bin/supervisord -nc /etc/supervisor/supervisord.conf +fi diff --git a/logrotate.d/sbbsecho b/logrotate.d/sbbsecho index e3d3c99..68d1295 100644 --- a/logrotate.d/sbbsecho +++ b/logrotate.d/sbbsecho @@ -7,4 +7,6 @@ missingok createolddir 775 root root notifempty + copytruncate + dateyesterday } diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..1c93a4d --- /dev/null +++ b/start.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +export SBBSCTRL=/opt/sbbs/ctrl +PIDFILE=/run/sbbs.pid + +# Proxy signals +function kill_app(){ + kill $(cat ${SBBS_PID}) + exit 0 # exit okay +} +trap "kill_app" SIGINT SIGTERM + +sbbs -d +sleep 5 + +SBBS_PID=$(cat ${PIDFILE}) +echo "* SBBS PID [${SBBS_PID}]" + +if [ -n ${SBBS_PID} ]; then + while [ -d /proc/${SBBS_PID} ]; do + NAME=$(cat /proc/${SBBS_PID}/cmdline |awk -F\00 '{print $1}') + #echo "* SBBS NAME [${NAME}]" + + if [ ${NAME} != 'sbbs' ]; then + echo "! Name not matching? [${NAME}]" + break; + fi + + sleep 15 + done + + echo "? SBBS stopped" +else + echo "? NO SBBS PID?" +fi + +exit 1 diff --git a/supervisord.d/sbbs.conf b/supervisord.d/sbbs.conf new file mode 100644 index 0000000..02a3c28 --- /dev/null +++ b/supervisord.d/sbbs.conf @@ -0,0 +1,3 @@ +[program:sbbs] +command=/opt/sbbs/exec/start.sh +stopwaitsecs=60