From 3311ca094d55566922ef961c502c4fa25f049a15 Mon Sep 17 00:00:00 2001 From: KemoNine Date: Sat, 8 Aug 2020 00:58:10 -0400 Subject: [PATCH] Add initial monit config as well as monit dashboard --- Dockerfile | 72 ++++++++++++++---------- piframefleet_run.sh | 6 ++ root/etc/cont-init.d/00-welcome | 2 + root/etc/cont-init.d/30-config | 59 +++++++++++++++++++ root/etc/services.d/_service_control/run | 6 +- root/etc/services.d/monit-dashboard/run | 4 ++ root/etc/services.d/monit/run | 9 +++ 7 files changed, 126 insertions(+), 32 deletions(-) create mode 100755 root/etc/services.d/monit-dashboard/run create mode 100755 root/etc/services.d/monit/run diff --git a/Dockerfile b/Dockerfile index e66e431..5391894 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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/ / diff --git a/piframefleet_run.sh b/piframefleet_run.sh index 8162457..9bd628e 100755 --- a/piframefleet_run.sh +++ b/piframefleet_run.sh @@ -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 diff --git a/root/etc/cont-init.d/00-welcome b/root/etc/cont-init.d/00-welcome index 660819f..29ec569 100755 --- a/root/etc/cont-init.d/00-welcome +++ b/root/etc/cont-init.d/00-welcome @@ -6,6 +6,8 @@ Welcome to PiFrameFleet This container includes the following - WireGuard VPN - Ansible + - Monit + - Monit-Dashboard - SyncThing - rclone - FileBrowser (admin/password) diff --git a/root/etc/cont-init.d/30-config b/root/etc/cont-init.d/30-config index cca0e8c..d072a69 100755 --- a/root/etc/cont-init.d/30-config +++ b/root/etc/cont-init.d/30-config @@ -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 < /opt/monit/conf.d/picturesfs < 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 <