From 0264a6e81f1206d17a48b7da31b275d1544f7d40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Val=C3=AD=C4=8Dek=20=28YCNet=29?= Date: Wed, 20 Jan 2021 12:55:06 +0100 Subject: [PATCH] Upgrade to debian-based rootfs --- Dockerfile | 36 +++++++++++++++++++++++++++--------- crontab | 5 +++-- executor-conf | 16 ---------------- logcat.service | 13 +++++++++++++ logdump.service | 12 ++++++++++++ startup-logcat | 12 ++++++++++++ startup-logdump | 4 ++++ syslog.logrotate | 12 ++++++++++++ 8 files changed, 83 insertions(+), 27 deletions(-) delete mode 100755 executor-conf create mode 100644 logcat.service create mode 100644 logdump.service create mode 100755 startup-logcat create mode 100755 startup-logdump create mode 100644 syslog.logrotate diff --git a/Dockerfile b/Dockerfile index 47e00db..4d4d9e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,23 +1,41 @@ -# Alpine base image -FROM registry.sw3.cz/valicek1/lxc-alpine +# Debian base image +FROM registry.sw3.cz/valicek1/lxcbian-bullseye VOLUME /data -RUN apk add --no-cache git bash openssh parallel openssh-keygen vim shadow +# install dependencies +RUN apt-get update +RUN apt-get full-upgrade -y --no-install-recommends +RUN apt-get install -y --no-install-recommends \ + git bash openssh-server parallel vim cron npm nodejs logrotate +RUN apt-get clean + +# create executor user RUN useradd --uid 10000 -ms /bin/bash executor -ADD crontab /etc/crontabs/executor -RUN apk del shadow + +# install crontab, enable cron +ADD crontab /etc/cron.d/repo-cloner-executor +RUN bash -c "dpkg -l | grep cron" +RUN systemctl enable ssh cron ADD dockerbin/* checker/* src/* /usr/local/bin/ -ADD executor-conf /etc/init.d -RUN rc-update add executor-conf default # remove tty autospawn from inittab -RUN sed 's/^tty.*$//g' -i /etc/inittab # disable motd RUN echo > /etc/motd # install tail logger -RUN apk add npm RUN npm i frontail -g +# enable frontail at startup +ADD startup-logcat /usr/local/bin +ADD logcat.service /etc/systemd/system +RUN systemctl enable logcat + +# enable log dumping & rotation +ADD startup-logdump /usr/local/bin +ADD syslog.logrotate /etc/logrotate.d/syslog +ADD logdump.service /etc/systemd/system +RUN systemctl enable logdump + +RUN ln -fs /usr/share/zoneinfo/Europe/Prague /etc/localtime CMD [ "/sbin/init" ] diff --git a/crontab b/crontab index f2681d0..a27540f 100644 --- a/crontab +++ b/crontab @@ -1,3 +1,4 @@ # executor crontab -* * * * * /usr/local/bin/cron-command >> /home/executor/cron.log -0 0 * * * mv /home/executor/cron.log /home/executor/cron.old +MAILTO="" +* * * * * executor /usr/local/bin/cron-command >> /home/executor/cron.log 2>&1 +0 0 * * * executor mv /home/executor/cron.log /home/executor/cron.old diff --git a/executor-conf b/executor-conf deleted file mode 100755 index 48a643c..0000000 --- a/executor-conf +++ /dev/null @@ -1,16 +0,0 @@ -#!/sbin/openrc-run - -description="Sets executor initial evironment" - -start() { - # make parallel citation shut up - mkdir -p ~executor/.parallel - touch ~executor/.parallel/will-cite - # repair ownership - find /data \! -user executor -exec chown executor:executor {} \; - # pidfile - touch /var/run/cloner.pid - chown executor:executor /var/run/cloner.pid - frontail /var/log/messages /home/executor/cron.log --daemonize --url-path /logs -} - diff --git a/logcat.service b/logcat.service new file mode 100644 index 0000000..6fef530 --- /dev/null +++ b/logcat.service @@ -0,0 +1,13 @@ +[Unit] +Description=Logcat service startup +Documentation=Fix ownership and start logcat +After=network.target + +[Service] +Type=forking +User=root +ExecStart=/usr/local/bin/startup-logcat +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/logdump.service b/logdump.service new file mode 100644 index 0000000..2f2ef74 --- /dev/null +++ b/logdump.service @@ -0,0 +1,12 @@ +[Unit] +Description=Dumps journalctl to syslog file +After=network.target + +[Service] +Type=simple +User=root +ExecStart=/usr/local/bin/startup-logdump +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/startup-logcat b/startup-logcat new file mode 100755 index 0000000..24851b8 --- /dev/null +++ b/startup-logcat @@ -0,0 +1,12 @@ +#!/bin/bash + +# make parallel citation shut up +mkdir -p ~executor/.parallel +touch ~executor/.parallel/will-cite + +# repair ownership +find /data \! -user executor -exec chown executor:executor {} \; + +frontail /var/log/syslog /home/executor/cron.log --daemonize --url-path /logs + + diff --git a/startup-logdump b/startup-logdump new file mode 100755 index 0000000..5833353 --- /dev/null +++ b/startup-logdump @@ -0,0 +1,4 @@ +#!/bin/bash + +journalctl -f > /var/log/syslog + diff --git a/syslog.logrotate b/syslog.logrotate new file mode 100644 index 0000000..51c34f4 --- /dev/null +++ b/syslog.logrotate @@ -0,0 +1,12 @@ +/var/log/syslog { + daily + missingok + rotate 10 + compress + delaycompress + notifempty + nocreate + copytruncate +} + +