diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..45b8984 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,38 @@ +FROM ubuntu:latest + +# Munin specific +VOLUME /opt/munin +EXPOSE 2813 + +# Run s6-overlay as the init so we get services and similar +ENTRYPOINT [ "/init" ] + +# Don't bother us for selections during install +ENV DEBIAN_FRONTEND="noninteractive" + +# We work off /opt, the *nix way +WORKDIR /opt/ + +# Install and base setup all the things +RUN apt update && apt upgrade -y && \ + apt install -y curl jq xz-utils lm-sensors && \ + S6_RELEASE=$(curl -sX GET "https://api.github.com/repos/just-containers/s6-overlay/tags" \ + | jq -r .[0].name); \ + echo "**** s6-overlay release: ${S6_RELEASE} ****" && \ + echo "**** Installing s6-overlay ****" && \ + curl -L https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-x86_64.tar.xz \ + -o /opt/s6-overlay-x86_64.tar.xz && \ + curl -L https://github.com/just-containers/s6-overlay/releases/latest/download/s6-overlay-noarch.tar.xz \ + -o /opt/s6-overlay-noarch.tar.xz && \ + tar -C / -Jxpf /opt/s6-overlay-x86_64.tar.xz && \ + tar -C / -Jxpf /opt/s6-overlay-noarch.tar.xz && \ + echo "**** munin related ****" && \ + apt install -y munin lighttpd && \ + echo "**** cleanup ****" && \ + rm /opt/s6-overlay*.tar.xz && \ + apt remove --purge -y jq xz-utils && \ + apt autoremove --purge -y && \ + rm -rf /var/lib/apt/lists/* + +# Copy the s6 related 'stuff' to the container +ADD /root/ / diff --git a/README.md b/README.md index d875d11..9d911e7 100644 --- a/README.md +++ b/README.md @@ -1 +1,9 @@ Simple container with munin leveraging s6 init for services/cron + +Host config: + +``` +pacman -S lm_sensors +sensors-detect # walk through this completely +systemctl enable --now lm_sensors +``` diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..b926241 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +git pull +sudo docker build --no-cache --pull -t munin:latest -f Dockerfile . diff --git a/root/etc/s6-overlay/s6-rc.d/cron/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/cron/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/cron/dependencies.d/setup b/root/etc/s6-overlay/s6-rc.d/cron/dependencies.d/setup new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/cron/run b/root/etc/s6-overlay/s6-rc.d/cron/run new file mode 100755 index 0000000..75c0d01 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/cron/run @@ -0,0 +1,6 @@ +#!/command/with-contenv sh + +# this line here is what we should have to get rid of the hard link error +touch /etc/crontab /etc/cron.*/* + +cron -f diff --git a/root/etc/s6-overlay/s6-rc.d/cron/type b/root/etc/s6-overlay/s6-rc.d/cron/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/cron/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/dependencies.d/setup b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/dependencies.d/setup new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/run b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/run new file mode 100755 index 0000000..b1abdd4 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/run @@ -0,0 +1,3 @@ +#!/command/with-contenv bash + +lighttpd -D -f /opt/munin/lighttpd-munin.conf diff --git a/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/type b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/munin-lighttpd/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/munin-node/dependencies.d/base b/root/etc/s6-overlay/s6-rc.d/munin-node/dependencies.d/base new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/munin-node/dependencies.d/setup b/root/etc/s6-overlay/s6-rc.d/munin-node/dependencies.d/setup new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/munin-node/run b/root/etc/s6-overlay/s6-rc.d/munin-node/run new file mode 100755 index 0000000..1ea5822 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/munin-node/run @@ -0,0 +1,3 @@ +#!/command/with-contenv bash + +munin-node diff --git a/root/etc/s6-overlay/s6-rc.d/munin-node/type b/root/etc/s6-overlay/s6-rc.d/munin-node/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/munin-node/type @@ -0,0 +1 @@ +longrun diff --git a/root/etc/s6-overlay/s6-rc.d/setup/setup b/root/etc/s6-overlay/s6-rc.d/setup/setup new file mode 100755 index 0000000..a75829c --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/setup/setup @@ -0,0 +1,138 @@ +#!/command/with-contenv bash + +#################### +# Munin +#################### +echo "---------- Setting up munin config ----------" +if [ ! -d "/opt/munin" ] ; then + mkdir /opt/munin +fi +if [ ! -f "/opt/munin/munin.conf" ] ; then +cat > /opt/munin/munin.conf < /opt/munin/munin-node.conf < /opt/munin/lighttpd-munin.conf < "/munin/" ) + +\$HTTP["url"] =~ "/munin-cgi/munin-cgi-graph" { + alias.url += ( "/munin-cgi/munin-cgi-graph" => "/usr/lib/munin/cgi/munin-cgi-graph" ) + cgi.assign = ( "" => "" ) +} + +alias.url += ( "/munin/static" => "/etc/munin/static" ) +alias.url += ( "/munin" => "/opt/munin/www" ) + +mimetype.assign = ( + ".html" => "text/html", + ".txt" => "text/plain", + ".css" => "text/css", + ".js" => "application/x-javascript", + ".jpg" => "image/jpeg", + ".jpeg" => "image/jpeg", + ".gif" => "image/gif", + ".png" => "image/png", + "" => "application/octet-stream" + ) +EOF +fi +echo "---------- Munin node setup ----------" +rm /etc/munin/plugin-conf.d/* +munin-node-configure --shell --remove-also --debug | sh -x +#su - munin --shell=/bin/sh /usr/bin/munin-cron diff --git a/root/etc/s6-overlay/s6-rc.d/setup/type b/root/etc/s6-overlay/s6-rc.d/setup/type new file mode 100644 index 0000000..bdd22a1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/setup/type @@ -0,0 +1 @@ +oneshot diff --git a/root/etc/s6-overlay/s6-rc.d/setup/up b/root/etc/s6-overlay/s6-rc.d/setup/up new file mode 100644 index 0000000..f6dc8d1 --- /dev/null +++ b/root/etc/s6-overlay/s6-rc.d/setup/up @@ -0,0 +1 @@ +/etc/s6-overlay/s6-rc.d/setup/setup diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/cron b/root/etc/s6-overlay/s6-rc.d/user/contents.d/cron new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/munin-lighttpd b/root/etc/s6-overlay/s6-rc.d/user/contents.d/munin-lighttpd new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/munin-node b/root/etc/s6-overlay/s6-rc.d/user/contents.d/munin-node new file mode 100644 index 0000000..e69de29 diff --git a/root/etc/s6-overlay/s6-rc.d/user/contents.d/setup b/root/etc/s6-overlay/s6-rc.d/user/contents.d/setup new file mode 100644 index 0000000..e69de29 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..58f40ee --- /dev/null +++ b/run.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "**** Building latest Munin container ****" +$(pwd)/build.sh + +echo "**** Deleting Original Container ****" +sudo docker rm -f munin + +echo "**** Running Munin ****" +sudo docker run -itd \ + --restart unless-stopped \ + --network services \ + --name munin \ + -e TZ=UTC \ + -e DEBUG=1 \ + -p 2813:2813/tcp \ + -l diun.enable=true \ + -l traefik.enable=false \ + -v /var/munin:/opt/munin \ + --mount type=tmpfs,destination=/opt/munin/www \ + --mount type=tmpfs,destination=/opt/munin/log \ + --mount type=tmpfs,destination=/opt/munin/run \ + --mount type=tmpfs,destination=/opt/munin/cgi-tmp \ + munin:latest diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..d4584b3 --- /dev/null +++ b/test.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +echo "**** Building latest Munin container ****" +$(pwd)/build.sh + +echo "**** Deleting Original Container ****" +sudo docker rm -f munin + +echo "**** Running Munin ****" +sudo docker run -it \ + --restart unless-stopped \ + --network services \ + --name munin \ + -e TZ=UTC \ + -e DEBUG=1 \ + -p 2813:2813/tcp \ + -l diun.enable=true \ + -l traefik.enable=false \ + --mount type=tmpfs,destination=/opt/munin/www \ + --mount type=tmpfs,destination=/opt/munin/log \ + --mount type=tmpfs,destination=/opt/munin/run \ + --mount type=tmpfs,destination=/opt/munin/cgi-tmp \ + munin:latest