Add initial monit config as well as monit dashboard
This commit is contained in:
parent
b1fa1f65d7
commit
3311ca094d
72
Dockerfile
72
Dockerfile
|
@ -1,13 +1,47 @@
|
||||||
FROM ubuntu:latest
|
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
|
# Don't bother us for selections during install
|
||||||
ENV DEBIAN_FRONTEND="noninteractive"
|
ENV DEBIAN_FRONTEND="noninteractive"
|
||||||
|
|
||||||
# We work off /opt, the *nix way
|
# We work off /opt, the *nix way
|
||||||
WORKDIR /opt/
|
WORKDIR /opt/
|
||||||
|
|
||||||
# need to figure out if arm64/arm64 32bit multilib/arm
|
# need to figure out if arm64/arm64 32bit multilib/arm/x86-64
|
||||||
COPY piframefleet/arch_detect.sh /opt/
|
COPY arch_detect.sh /opt/
|
||||||
|
|
||||||
# Install and base setup all the things
|
# Install and base setup all the things
|
||||||
RUN apt update && apt upgrade -y && \
|
RUN apt update && apt upgrade -y && \
|
||||||
|
@ -32,6 +66,11 @@ RUN apt update && apt upgrade -y && \
|
||||||
make -C src -j$(nproc) && \
|
make -C src -j$(nproc) && \
|
||||||
make -C src install && \
|
make -C src install && \
|
||||||
cd /opt && \
|
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 ****" && \
|
echo "**** syncthing ****" && \
|
||||||
curl -s https://syncthing.net/release-key.txt | apt-key add - && \
|
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 && \
|
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/arch_detect.sh && \
|
||||||
rm /opt/s6-overlay.tar.gz && \
|
rm /opt/s6-overlay.tar.gz && \
|
||||||
rm -rf /opt/wireguard-tools && \
|
rm -rf /opt/wireguard-tools && \
|
||||||
|
rm /opt/get-pip.py && \
|
||||||
apt remove --purge -y build-essential pkg-config libelf-dev unzip && \
|
apt remove --purge -y build-essential pkg-config libelf-dev unzip && \
|
||||||
apt autoremove --purge -y && \
|
apt autoremove --purge -y && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
# Copy the s6 related 'stuff' to the container
|
# Copy the s6 related 'stuff' to the container
|
||||||
ADD /piframefleet/root/ /
|
ADD /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" ]
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ sudo docker run -it \
|
||||||
--cap-add=NET_ADMIN \
|
--cap-add=NET_ADMIN \
|
||||||
--cap-add=SYS_MODULE \
|
--cap-add=SYS_MODULE \
|
||||||
-e TZ=UTC \
|
-e TZ=UTC \
|
||||||
|
-e MONIT_CONFIG_USER=admin \
|
||||||
|
-e MONIT_CONFIG_PASS=apassword \
|
||||||
-e ENABLE_WIREGUARD=true \
|
-e ENABLE_WIREGUARD=true \
|
||||||
-e ENABLE_SYNCTHING=true \
|
-e ENABLE_SYNCTHING=true \
|
||||||
-e ENABLE_FILEBROWSER=true \
|
-e ENABLE_FILEBROWSER=true \
|
||||||
|
@ -20,10 +22,14 @@ sudo docker run -it \
|
||||||
-p 8384:8384/tcp \
|
-p 8384:8384/tcp \
|
||||||
-p 22000:22000/tcp \
|
-p 22000:22000/tcp \
|
||||||
-p 9191:9191/tcp \
|
-p 9191:9191/tcp \
|
||||||
|
-p 2812:2812/tcp \
|
||||||
|
-p 2811:2811/tcp \
|
||||||
-v /lib/modules:/lib/modules:ro \
|
-v /lib/modules:/lib/modules:ro \
|
||||||
-v /var/piframefleet/syncthing:/opt/syncthing \
|
-v /var/piframefleet/syncthing:/opt/syncthing \
|
||||||
-v /var/piframefleet/filebrowser:/opt/filebrowser \
|
-v /var/piframefleet/filebrowser:/opt/filebrowser \
|
||||||
-v /var/piframefleet/wireguard:/opt/wireguard \
|
-v /var/piframefleet/wireguard:/opt/wireguard \
|
||||||
-v /var/piframefleet/ansible:/opt/ansible \
|
-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 \
|
-v /var/piframefleet/pictures:/opt/pictures \
|
||||||
piframe/piframefleet:latest
|
piframe/piframefleet:latest
|
||||||
|
|
|
@ -6,6 +6,8 @@ Welcome to PiFrameFleet
|
||||||
This container includes the following
|
This container includes the following
|
||||||
- WireGuard VPN
|
- WireGuard VPN
|
||||||
- Ansible
|
- Ansible
|
||||||
|
- Monit
|
||||||
|
- Monit-Dashboard
|
||||||
- SyncThing
|
- SyncThing
|
||||||
- rclone
|
- rclone
|
||||||
- FileBrowser (admin/password)
|
- FileBrowser (admin/password)
|
||||||
|
|
|
@ -29,6 +29,65 @@ echo "-------------------------------------
|
||||||
"
|
"
|
||||||
fi
|
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
|
# WireGuard
|
||||||
####################
|
####################
|
||||||
|
|
|
@ -11,9 +11,9 @@ if [ "$ENABLE_WIREGUARD" = false ] ; then
|
||||||
s6-svc -od /var/run/s6/services/wireguard
|
s6-svc -od /var/run/s6/services/wireguard
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#if [ "$ENABLE_SYNCTHING" = false ] ; then
|
if [ "$ENABLE_SYNCTHING" = false ] ; then
|
||||||
# s6-svc -od /var/run/s6/services/syncthing
|
s6-svc -od /var/run/s6/services/syncthing
|
||||||
#fi
|
fi
|
||||||
|
|
||||||
if [ "$ENABLE_FILE_BROWSER" = false ] ; then
|
if [ "$ENABLE_FILE_BROWSER" = false ] ; then
|
||||||
s6-svc -od /var/run/s6/services/filebrowser
|
s6-svc -od /var/run/s6/services/filebrowser
|
||||||
|
|
4
root/etc/services.d/monit-dashboard/run
Executable file
4
root/etc/services.d/monit-dashboard/run
Executable 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
9
root/etc/services.d/monit/run
Executable 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
|
Loading…
Reference in a new issue