dot

packages and services management
Log | Files | Refs | README

commit 1d30e3280f4de9bdd80284cb77cf16c69c7137b2
parent affc16744963a1fca4c20258df2dd916ee66cfb2
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 30 Dec 2018 22:55:18 +0100

monit system that is simple

Diffstat:
Mbin/lt | 2+-
Mbin/ltree | 16++++------------
Abin/ltree-html | 24++++++++++++++++++++++++
Detc/s6-mk/ii/default/env/NAME | 0
Detc/s6-mk/ii/default/env/NICK | 0
Detc/s6-mk/ii/default/env/PASS | 0
Aetc/s6-mk/ii/default/env/ROOT | 1+
Aetc/s6-mk/ii/default/setup | 10++++++++++
Detc/s6-mk/ii/irc.cyberia.is/env/PASS | 0
Detc/s6-mk/ii/irc.epitech.eu/env/PASS | 0
Detc/s6-mk/ii/irc.freenode.net/env/PASS | 0
Detc/s6-mk/ii/irc.oftc.net/env/PASS | 0
Aetc/s6-mk/ii/monit-bot/env/HOST | 1+
Aetc/s6-mk/ii/monit-bot/env/NAME | 1+
Aetc/s6-mk/ii/monit-bot/env/NICK | 1+
Aetc/s6-mk/ii/monit-bot/env/ROOT | 1+
Aetc/s6-mk/ii/monit-bot/env/USER | 1+
Metc/s6-mk/ii/tcp/run | 20++++++++++++--------
Metc/s6-mk/ii/tls/run | 28++++++++++++++++------------
Aetc/s6-mk/monit/default/data/alert/irc | 12++++++++++++
Aetc/s6-mk/monit/default/data/check/smtp | 11+++++++++++
Aetc/s6-mk/monit/default/data/uri/test | 1+
Aetc/s6-mk/monit/default/finish | 4++++
Metc/s6-mk/monit/default/run | 18+++++++++++++++++-
Aetc/s6-mk/monit/default/type | 1+
25 files changed, 119 insertions(+), 34 deletions(-)

diff --git a/bin/lt b/bin/lt @@ -1,7 +1,7 @@ #!/usr/bin/env execlineb elgetpositionals -pipeline { lr -GG -f "%M %Ty-%Tm-%Td %g %u %S\1\t%p\n" "${@}" } +pipeline { lr -GG -f "%M %Ty-%Tm-%Td %u %g %S\1\t%p\n" "${@}" } pipeline { sed -r "s,(\t[^\033]*)((\033\\[[;0-9]+m)+),\\2\\1," } pipeline { ltree } pipeline { sed -r "s,\1((\033\\[[0-9;]+m)+)(.*─ ),\\3\\1," } diff --git a/bin/ltree b/bin/ltree @@ -19,8 +19,8 @@ BEGIN { TAIL = "└─ "; VOID = " "; FS = "\t"; - - HTML = ARGV[1]; ARGC = 0; + FULL = ARGV[1]; + ARGC = 0; } # Get a recursive list of all list into list[] with list[i:j] @@ -42,13 +42,6 @@ BEGIN { # [ 1:[ 1:LINE, 2:LINE, 3:LINE, 4:LINE, 5:NODE, 6:"filename" ] ] { - if (HTML) { - gsub("&", "\\&amp;", $0); - gsub("<", "\\&lt;", $0); - gsub(">", "\\&gt;", $0); - gsub("\"", "\\&quote;", $0); - } - count = split($2, paths, "/"); for (i = 2; i < count; i++) LIST[NR":"i] = LINE; @@ -80,8 +73,7 @@ END { for (nr = 1; nr <= NR; nr++) { for (nf = 1; LIST[nr":"nf] != ""; nf++) printf "%s", LIST[nr":"nf]; - if (HTML) { - print "<a href=\"" HTML "/" LIST[nr"path"] "\">" LIST[nr"name"] "</a>"; - } else print LIST[nr"name"]; + if (FULL) print "\t" LIST[nr"path"]; + else print LIST[nr"name"]; } } diff --git a/bin/ltree-html b/bin/ltree-html @@ -0,0 +1,24 @@ +#!/bin/sh -e + +cat <<EOF +<title>$1</title> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> +<meta charset="UTF-8"> + +<pre> +EOF + +lr -f '%AY-%Am-%Ad %S %y\t%P\n' "$1" | sed -r ' + 1 d + / index.[a-z]+$/ d + s/&/\&amp;/g + s/</\&lt;/g + s/>/\&gt;/g + s/"/\&quot;/g + +' | ltree full | +while IFS=' ' read -r text path; do + echo "${text}<a href=\"${path}\">${path##*/}</a>" +done + +echo '</pre>' diff --git a/etc/s6-mk/ii/default/env/NAME b/etc/s6-mk/ii/default/env/NAME diff --git a/etc/s6-mk/ii/default/env/NICK b/etc/s6-mk/ii/default/env/NICK diff --git a/etc/s6-mk/ii/default/env/PASS b/etc/s6-mk/ii/default/env/PASS diff --git a/etc/s6-mk/ii/default/env/ROOT b/etc/s6-mk/ii/default/env/ROOT @@ -0,0 +1 @@ +irc diff --git a/etc/s6-mk/ii/default/setup b/etc/s6-mk/ii/default/setup @@ -0,0 +1,10 @@ +#!/usr/bin/env execlineb + +s6-envdir env +multisubstitute { + importas -i host HOST + importas -i nick NICK +} + +redirfd -w 1 env/PASS +pass irc/${host}/${nick} diff --git a/etc/s6-mk/ii/irc.cyberia.is/env/PASS b/etc/s6-mk/ii/irc.cyberia.is/env/PASS diff --git a/etc/s6-mk/ii/irc.epitech.eu/env/PASS b/etc/s6-mk/ii/irc.epitech.eu/env/PASS diff --git a/etc/s6-mk/ii/irc.freenode.net/env/PASS b/etc/s6-mk/ii/irc.freenode.net/env/PASS diff --git a/etc/s6-mk/ii/irc.oftc.net/env/PASS b/etc/s6-mk/ii/irc.oftc.net/env/PASS diff --git a/etc/s6-mk/ii/monit-bot/env/HOST b/etc/s6-mk/ii/monit-bot/env/HOST @@ -0,0 +1 @@ +irc.freenode.net diff --git a/etc/s6-mk/ii/monit-bot/env/NAME b/etc/s6-mk/ii/monit-bot/env/NAME @@ -0,0 +1 @@ +Bot that sends alerts diff --git a/etc/s6-mk/ii/monit-bot/env/NICK b/etc/s6-mk/ii/monit-bot/env/NICK @@ -0,0 +1 @@ +iiost-bot diff --git a/etc/s6-mk/ii/monit-bot/env/ROOT b/etc/s6-mk/ii/monit-bot/env/ROOT @@ -0,0 +1 @@ +. diff --git a/etc/s6-mk/ii/monit-bot/env/USER b/etc/s6-mk/ii/monit-bot/env/USER @@ -0,0 +1 @@ +irc diff --git a/etc/s6-mk/ii/tcp/run b/etc/s6-mk/ii/tcp/run @@ -3,13 +3,17 @@ fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST - importas PORT PORT - importas USER USER - importas NICK NICK - importas NAME NAME + importas -i host HOST + importas -i port PORT + importas -i user USER + importas -i nick NICK + importas -i name NAME + importas -i root ROOT } -s6-setuidgid $USER -s6-tcpclient $HOST $PORT -ii -s $HOST -n $NICK -f $NAME -k PASS +backtick -n x { homeof ${user} } +importas home x + +s6-setuidgid ${user} +s6-tcpclient ${host} ${port} +ii -i ${home}/${root} -s ${host} -n ${nick} -f ${name} -k PASS diff --git a/etc/s6-mk/ii/tls/run b/etc/s6-mk/ii/tls/run @@ -3,20 +3,24 @@ fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST - importas PORT PORT - importas USER USER - importas NICK NICK - importas NAME NAME - importas CAFILE CAFILE + importas -i host HOST + importas -i port PORT + importas -i user USER + importas -i nick NICK + importas -i name NAME + importas -i root ROOT + importas -i cafile CAFILE } -ifelse -n { test -f ${CAFILE} } { +backtick -n x { homeof ${user} } +importas home x + +ifelse -n { test -f ${cafile} } { redirfd -r 0 /dev/null - redirfd -w 1 $CAFILE - openssl s_client -showcerts -connect ${HOST}:${PORT} + redirfd -w 1 ${cafile} + openssl s_client -showcerts -connect ${host}:${port} } -s6-setuidgid $USER -s6-tlsclient $HOST $PORT -ii -s $HOST -n $NICK -f $NAME -k PASS +s6-setuidgid ${user} +s6-tlsclient ${host} ${port} +ii -i ${home}/${root} -s ${host} -n ${nick} -f ${name} -k PASS diff --git a/etc/s6-mk/monit/default/data/alert/irc b/etc/s6-mk/monit/default/data/alert/irc @@ -0,0 +1,12 @@ +#!/usr/bin/env execlineb +elgetpositionals #@ message + +importas -i host IRC_HOST +importas -i chan IRC_CHAN + +if -n { + redirfd -wn 1 /var/irc/${host}/${chan} + echo "[alert]" "${@}" +} + +echo "no irc bot is listenning at /var/irc/${host}/${chan}" diff --git a/etc/s6-mk/monit/default/data/check/smtp b/etc/s6-mk/monit/default/data/check/smtp @@ -0,0 +1,11 @@ +#!/usr/bin/env execlineb +elgetpositionals #0 scheme - #1 user - #2 host - #3 port - #4 path + +backtick -n x { s6-tcpclient -t 20 ${2} ${3} fdmove -c 0 6 sed q } +importas hello x + +if -n { heredoc 0 ${hello} grep "^220 " } + +backtick x { heredoc 0 ${hello} tr -d "\\n\\r" } +importas hello-print x +alert/irc "[${0}] ${host:port}: \"${hello-print}\"" diff --git a/etc/s6-mk/monit/default/data/uri/test b/etc/s6-mk/monit/default/data/uri/test @@ -0,0 +1 @@ +smtp://josuah.net:25 diff --git a/etc/s6-mk/monit/default/finish b/etc/s6-mk/monit/default/finish @@ -0,0 +1,4 @@ +#!/usr/bin/env execlineb +fdmove -c 2 1 + +snooze -H * -M * -S 20 diff --git a/etc/s6-mk/monit/default/run b/etc/s6-mk/monit/default/run @@ -1,2 +1,18 @@ #!/usr/bin/env execlineb -redirfd -c 2 1 +fdmove -c 2 1 + +s6-envdir env +cd data + +ifte { if { echo so... } if { wait -t 300 { } } if { echo ok } } { exit 1 } + +forbacktickx -n -d "\n" x { + elglob -0 x uri/* + sed -r "s,([^@:/#]+)://(([^@:/#]*)@)?([^:/#]*)?(:([^/#]*))?(/([^#]*))?(#(.*))?,\\1\t\\3\t\\4\t\\6\t\\8," ${x} +} +importas -s -d "\t" parts x + +# the uri in data/uri/<uri> are now split into 5 arguments: +#0 scheme - #1 user - #2 host - #3 port - #4 path + +background { snooze -H * -M * -S * -R 10 check/${parts} } diff --git a/etc/s6-mk/monit/default/type b/etc/s6-mk/monit/default/type @@ -0,0 +1 @@ +longrun