Add initial monit config as well as monit dashboard

This commit is contained in:
KemoNine 2020-08-08 00:58:10 -04:00
parent b1fa1f65d7
commit 3311ca094d
7 changed files with 126 additions and 32 deletions

View File

@ -1,13 +1,47 @@
FROM ubuntu:latest
# Ansible related 'stuff'
VOLUME /opt/ansible
# Monit related 'stuff'
ENV MONIT_CONFIG_USER=admin
ENV MONIT_CONFIG_PASS=apassword
EXPOSE 2812/tcp
EXPOSE 2811/tcp
VOLUME /opt/monit
VOLUME /opt/monit-dashboard
# Wireguard related 'stuff'
ENV ENABLE_WIREGUARD=false
EXPOSE 51820/udp
VOLUME /lib/modules
VOLUME /opt/wireguard
# SyncThing related 'stuff'
ENV ENABLE_SYNCTHING=false
EXPOSE 8384/tcp
EXPOSE 22000/tcp
VOLUME /opt/syncthing
# FileBrowser related 'stuff'
ENV ENABLE_FILEBROWSER=false
EXPOSE 9191/tcp
VOLUME /opt/filebrowser
# General 'stuff'
VOLUME /opt/pictures
# 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/
# need to figure out if arm64/arm64 32bit multilib/arm
COPY piframefleet/arch_detect.sh /opt/
# need to figure out if arm64/arm64 32bit multilib/arm/x86-64
COPY arch_detect.sh /opt/
# Install and base setup all the things
RUN apt update && apt upgrade -y && \
@ -32,6 +66,11 @@ RUN apt update && apt upgrade -y && \
make -C src -j$(nproc) && \
make -C src install && \
cd /opt && \
echo "**** monit related ***" && \
apt install -y monit python2 && \
curl https://bootstrap.pypa.io/get-pip.py -o /opt/get-pip.py && \
python2 /opt/get-pip.py && \
pip install setuptools==40.8.0 xmltodict==0.11.0 requests==2.21.0 xlsxwriter==1.3.2 web.py==0.51 && \
echo "**** syncthing ****" && \
curl -s https://syncthing.net/release-key.txt | apt-key add - && \
echo "deb https://apt.syncthing.net/ syncthing stable" | tee /etc/apt/sources.list.d/syncthing.list && \
@ -46,35 +85,10 @@ RUN apt update && apt upgrade -y && \
rm /opt/arch_detect.sh && \
rm /opt/s6-overlay.tar.gz && \
rm -rf /opt/wireguard-tools && \
rm /opt/get-pip.py && \
apt remove --purge -y build-essential pkg-config libelf-dev unzip && \
apt autoremove --purge -y && \
rm -rf /var/lib/apt/lists/*
# Copy the s6 related 'stuff' to the container
ADD /piframefleet/root/ /
# Ansible related 'stuff'
VOLUME /opt/ansible
# Wireguard related 'stuff'
ENV ENABLE_WIREGUARD=false
EXPOSE 51820/udp
VOLUME /lib/modules
VOLUME /opt/wireguard
# SyncThing related 'stuff'
ENV ENABLE_SYNCTHING=false
EXPOSE 8384/tcp
EXPOSE 22000/tcp
VOLUME /opt/syncthing
# FileBrowser related 'stuff'
ENV ENABLE_FILEBROWSER=false
EXPOSE 9191/tcp
VOLUME /opt/filebrowser
# General 'stuff'
VOLUME /opt/pictures
# Run s6-overlay as the init so we get services and similar
ENTRYPOINT [ "/init" ]
ADD /root/ /

View File

@ -13,6 +13,8 @@ sudo docker run -it \
--cap-add=NET_ADMIN \
--cap-add=SYS_MODULE \
-e TZ=UTC \
-e MONIT_CONFIG_USER=admin \
-e MONIT_CONFIG_PASS=apassword \
-e ENABLE_WIREGUARD=true \
-e ENABLE_SYNCTHING=true \
-e ENABLE_FILEBROWSER=true \
@ -20,10 +22,14 @@ sudo docker run -it \
-p 8384:8384/tcp \
-p 22000:22000/tcp \
-p 9191:9191/tcp \
-p 2812:2812/tcp \
-p 2811:2811/tcp \
-v /lib/modules:/lib/modules:ro \
-v /var/piframefleet/syncthing:/opt/syncthing \
-v /var/piframefleet/filebrowser:/opt/filebrowser \
-v /var/piframefleet/wireguard:/opt/wireguard \
-v /var/piframefleet/ansible:/opt/ansible \
-v /var/piframefleet/monit:/opt/monit \
-v /var/piframefleet/monit-dashboard:/opt/monit-dashboard \
-v /var/piframefleet/pictures:/opt/pictures \
piframe/piframefleet:latest

View File

@ -6,6 +6,8 @@ Welcome to PiFrameFleet
This container includes the following
- WireGuard VPN
- Ansible
- Monit
- Monit-Dashboard
- SyncThing
- rclone
- FileBrowser (admin/password)

View File

@ -29,6 +29,65 @@ echo "-------------------------------------
"
fi
####################
# Monit
####################
if [ ! -d "/opt/monit/conf.d" ] ; then
mkdir /opt/monit/conf.d
fi
if [ ! -f "/opt/monit/monitrc" ] ; then
cat > /opt/monit/monitrc <<EOF
set daemon 120
set log /opt/monit/monit.log
set idfile /opt/monit/id
set statefile /opt/monit/state
set eventqueue
basedir /opt/monit/events # set the base directory where events will be stored
slots 100 # optionally limit the queue size
set httpd port 2812 and
use address 0.0.0.0
allow ${MONIT_CONFIG_USER}:${MONIT_CONFIG_PASS}
include /opt/monit/conf.d/*
EOF
chmod 600 /opt/monit/monitrc
if [ ! -f "/opt/monit/conf.d/picturesfs" ] ; then
cat > /opt/monit/conf.d/picturesfs <<EOF
check filesystem rootfs with path /opt/pictures
if space usage > 80% then alert
EOF
fi
fi
####################
# Monit dashboard
####################
if [ ! -d "/opt/monit-dashboard" ] ; then
mkdir /opt/monit-dashboard
fi
if [ ! -d "/opt/monit-dashboard/.git" ] ; then
git clone https://github.com/adriaaah/monit-dashboard /opt/monit-dashboard
sed -i 's/app.run(port=8080)/app.run(port=2811)/g' /opt/monit-dashboard/bin/monit-dashboard.py
else
cd /opt/monit-dashboard
git stash
git pull
sed -i 's/app.run(port=8080)/app.run(port=2811)/g' /opt/monit-dashboard/bin/monit-dashboard.py
fi
cd /opt/monit-dashboard
if [ ! -f "/opt/monit-dashboard/conf/servers.json" ] ; then
cat > conf/servers.json <<EOF
{
"dispatcher": {
"url": "http://127.0.0.1:2812",
"user": "${MONIT_CONFIG_USER}",
"passwd": "${MONIT_CONFIG_PASS}"
}
}
EOF
fi
####################
# WireGuard
####################

View File

@ -11,9 +11,9 @@ if [ "$ENABLE_WIREGUARD" = false ] ; then
s6-svc -od /var/run/s6/services/wireguard
fi
#if [ "$ENABLE_SYNCTHING" = false ] ; then
# s6-svc -od /var/run/s6/services/syncthing
#fi
if [ "$ENABLE_SYNCTHING" = false ] ; then
s6-svc -od /var/run/s6/services/syncthing
fi
if [ "$ENABLE_FILE_BROWSER" = false ] ; then
s6-svc -od /var/run/s6/services/filebrowser

View File

@ -0,0 +1,4 @@
#!/usr/bin/with-contenv bash
cd /opt/monit-dashboard
/usr/bin/python2 /opt/monit-dashboard/bin/monit-dashboard.py

9
root/etc/services.d/monit/run Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
if [ ! -f "/opt/monit/monitrc" ] ; then
exit
fi
cd /opt/monit
/usr/bin/monit -I \
-c /opt/monit/monitrc