initial working form

This commit is contained in:
KemoNine 2024-04-24 18:11:05 -04:00
parent c4fe803da4
commit 82b39aa012
24 changed files with 252 additions and 0 deletions

38
Dockerfile Normal file
View file

@ -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/ /

View file

@ -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
```

4
build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
git pull
sudo docker build --no-cache --pull -t munin:latest -f Dockerfile .

View file

@ -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

View file

@ -0,0 +1 @@
longrun

View file

@ -0,0 +1,3 @@
#!/command/with-contenv bash
lighttpd -D -f /opt/munin/lighttpd-munin.conf

View file

@ -0,0 +1 @@
longrun

View file

@ -0,0 +1,3 @@
#!/command/with-contenv bash
munin-node

View file

@ -0,0 +1 @@
longrun

View file

@ -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 <<EOF
dbdir /opt/munin/db
htmldir /opt/munin/www
logdir /opt/munin/log
rundir /opt/munin/run
cgitmpdir /opt/munin/cgi-tmp
graph_strategy cron
html_strategy cron
timeout 15
[munin.local]
address 127.0.0.1
use_node_name yes
EOF
fi
if [ ! -f "/opt/munin/munin-node.conf" ] ; then
cat > /opt/munin/munin-node.conf <<EOF
log_level 4
log_file /opt/munin/log/munin-node.log
pid_file /opt/munin/munin-node.pid
background 0
setsid 0
user munin
group munin
# Regexps for files to ignore
ignore_file [\#~]\$
ignore_file DEADJOE\$
ignore_file \.bak\$
ignore_file %\$
ignore_file \.dpkg-(tmp|new|old|dist)\$
ignore_file \.rpm(save|new)\$
ignore_file \.pod\$
allow ^127\.0\.0\.1\$
allow ^::1\$
host 127.0.0.1
port 4949
EOF
fi
rm /etc/munin/munin-node.conf
ln -sf /opt/munin/munin-node.conf /etc/munin/munin-node.conf
rm /etc/munin/munin.conf
ln -sf /opt/munin/munin.conf /etc/munin/munin.conf
echo "---------- Setting up munin directories ---------"
if [ ! -d "/opt/munin/log" ] ; then
mkdir /opt/munin/log
fi
chown munin: /opt/munin/log
if [ ! -d "/opt/munin/run" ] ; then
mkdir /opt/munin/run
fi
chown munin: /opt/munin/run
if [ ! -d "/opt/munin/db" ] ; then
mkdir /opt/munin/db
fi
chown munin: /opt/munin/db
if [ ! -d "/opt/munin/www" ] ; then
mkdir /opt/munin/www
fi
chown munin: /opt/munin/www
if [ ! -d "/opt/munin/cgi-tmp" ] ; then
mkdir /opt/munin/cgi-tmp
fi
chown munin: /opt/munin/cgi-tmp
if [ ! -f "/opt/munin/log/munin-update.log" ] ; then
touch /opt/munin/log/munin-update.log
chown munin: /opt/munin/log/munin-update.log
fi
echo "---------- Setting up lighttpd munin config ----------"
if [ ! -f "/opt/munin/lighttpd-munin.conf" ] ; then
cat > /opt/munin/lighttpd-munin.conf <<EOF
server.username = "munin"
server.groupname = "munin"
server.document-root = "/opt/munin/www"
server.port = 2813
server.errorlog = "/dev/stdout"
accesslog.filename = "/dev/stdout"
dir-listing.activate = "disable"
server.modules = (
"mod_access",
"mod_accesslog",
"mod_alias",
"mod_rewrite",
"mod_redirect",
"mod_cgi",
"mod_fastcgi",
"mod_auth",
"mod_authn_file",
)
server.pid-file = "/run/lighttpd-munin.pid"
server.follow-symlink = "enable"
index-file.names = ( "index.html", "index.htm" )
url.redirect += ( "^/*$" => "/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

View file

@ -0,0 +1 @@
oneshot

View file

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/setup/setup

24
run.sh Executable file
View file

@ -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

23
test.sh Executable file
View file

@ -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