#!/usr/bin/with-contenv bash #################### # Pictures storage #################### if [ ! -d "/opt/pictures" ] ; then mkdir /opt/pictures fi #################### # Email notifications #################### if [ ! -d "/opt/misc" ] ; then mkdir /opt/misc fi if [ ! -f "/opt/misc/msmtp.log" ] ; then touch /opt/misc/msmtp.log chown root: /opt/misc/msmtp.log chmod 666 /opt/misc/msmtp.log fi if [ ! -f "/opt/misc/aliases" ] ; then cat > /opt/misc/aliases < /opt/misc/msmtprc < /opt/rtty/rttys.conf < /opt/monit/monitrc < /opt/monit/conf.d/picturesfs < 80% then alert EOF fi #################### # Monit dashboard #################### if [ ! -d "/opt/monit-dashboard" ] ; then mkdir /opt/monit-dashboard fi if [ ! -d "/opt/monit-dashboard/.git" ] ; then git clone https://git.kemonine.info/PiFrame/monit-dashboard.git /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 < /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 munin-node-configure --shell # Prime the munin values so there isn't a 404 on initial view of page su - munin --shell=/bin/bash /usr/bin/munin-cron #################### # Dashboard #################### if [ ! -d "/opt/dashboard" ] ; then mkdir /opt/dashboard fi if [ ! -f "/opt/dashboard/lighttpd.conf" ] ; then cat > /opt/dashboard/lighttpd.conf < "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 if [ ! -d "/opt/dashboard/www" ] ; then mkdir /opt/dashboard/www chown www-data /opt/dashboard/www fi if [ ! -f "/opt/dashboard/www/index.html" ] ; then cat > /opt/dashboard/www/index.html < PiFrameFleet

Command Line

Monit Monitoring

Munin Monitoring

Syncthing Admin Interface

Picture File Browser

EOF chown www-data /opt/dashboard/www/index.html fi #################### # WireGuard #################### ip link del dev test 2>/dev/null if ip link add dev test type wireguard; then echo "**** It seems the wireguard module is already active :) ****" ip link del dev test else echo "**** The wireguard module is not active, please install wireguard on the host and activate the 'wg' kernel module ****" fi if [ ! -d "/opt/wireguard" ] ; then mkdir /opt/wireguard fi #################### # syncthing #################### if [ ! -d "/opt/syncthing" ]; then mkdir /opt/syncthing fi ST_CONF="/opt/syncthing/config.xml" if [ ! -f "$ST_CONF" ]; then echo "**** Initial Syncthing Config ****" /usr/bin/syncthing -generate /opt/syncthing sed -i 's/
127.0.0.1:8384<\/address>/
0.0.0.0:8384<\/address>/g' /opt/syncthing/config.xml sed -i 's///g' /opt/syncthing/config.xml if [ -d "/root/Sync" ]; then rm -r /root/Sync fi fi #################### # FileBrowser #################### if [ ! -d "/opt/filebrowser" ]; then mkdir /opt/filebrowser fi FB_DB="/opt/filebrowser/pictures.db" if [ ! -f "$FB_DB" ]; then echo "**** Initial FileBrowser Config ****" filebrowser -d $FB_DB \ config init 2>&1 > /dev/null filebrowser -d $FB_DB \ config set --address 0.0.0.0 2>&1 > /dev/null filebrowser -d $FB_DB \ config set --port 9191 2>&1 > /dev/null filebrowser -d $FB_DB \ config set --branding.name "PiFrameFleet - Pictures" 2>&1 > /dev/null filebrowser -d $FB_DB \ users add admin password 2>&1 > /dev/null fi