dot

packages and services management
Log | Files | Refs | README

commit b1fed13fa8eee39ce3a4185639bea1e971ee0405
parent 035e2e8681cecb4fe9a00e66a27699328e55ea35
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 24 Nov 2018 23:15:43 +0100

bin/service-*: huge usability improvement

Diffstat:
Abin/service-build | 29+++++++++++++++++++++++++++++
Mbin/service-disable | 9+++++----
Mbin/service-enable | 36++++--------------------------------
Mbin/service-init | 5+++--
Mbin/service-list | 4++--
Dbin/service-load | 6------
Mbin/service-log | 10+++++++---
Mbin/service-reload | 2+-
Mbin/service-restart | 1+
Mbin/service-start | 4++--
Mbin/service-status | 12++++++++----
Mbin/service-stop | 4++--
Ds6/.s6-rc/x/contents | 2--
Ds6/.s6-rc/x/type | 1-
Ds6/curvevpn-client/x/data/Makefile | 4----
Ds6/curvevpn-client/x/env/EXT | 1-
Ds6/curvevpn-client/x/env/IP | 1-
Ds6/curvevpn-client/x/env/NAME | 1-
Ds6/curvevpn-client/x/env/PORT | 1-
Ds6/curvevpn-client/x/env/PUBKEY | 1-
Ds6/curvevpn-client/x/env/ROOT | 1-
Ds6/curvevpn-client/x/env/SERVER | 2--
Ds6/curvevpn-client/x/run | 10----------
Ds6/curvevpn-client/x/type | 1-
Ds6/curvevpn-server/x/data/Makefile | 7-------
Ds6/curvevpn-server/x/data/data | 13-------------
Ds6/curvevpn-server/x/data/data.cdb | 0
Ds6/curvevpn-server/x/env/EXT | 1-
Ds6/curvevpn-server/x/env/IP | 1-
Ds6/curvevpn-server/x/env/NAME | 1-
Ds6/curvevpn-server/x/env/PORT | 1-
Ds6/curvevpn-server/x/env/ROOT | 1-
Ds6/curvevpn-server/x/make-key | 2--
Ds6/curvevpn-server/x/run | 14--------------
Ds6/curvevpn-server/x/type | 1-
Ms6/ffingerd-tcp/x/run | 4++--
Ms6/geomyidae/x/run | 4++--
Ms6/git-daemon/x/run | 4++--
Ms6/ntpclient/x/run | 4++--
Ms6/qmail-pop3d/x/run | 6+++---
Ms6/tapio/server/run | 4++--
Ms6/tinysshd/x/run | 4++--
Ms6/warp-vpn/server/run | 4++--
43 files changed, 81 insertions(+), 143 deletions(-)

diff --git a/bin/service-build b/bin/service-build @@ -0,0 +1,29 @@ +#!/usr/bin/env execlineb +if { mkdir -p /var/s6 } cd /var/s6 + +forbacktickx -0 x { dollarat -0 } importas s x +backtick -n x { heredoc 0 $s cut -d , -f 1 } importas base x + +ifelse { grep -qFx bundle /etc/s6/${base}/x/type } { + if { s6-hiercopy /etc/s6/ } + forbacktickx -n -d "\n" x { sed "s/^#.*//; /^[ \t]*$/ d" } importas x x + $0 $x +} + +backtick -n x { heredoc 0 $s cut -s -d , -f 2- } importas -s -d , mod x + +if { forx -o 0 x { x $mod } importas x x test -d /etc/s6/${base}/${x} } +if { rm -rf ${s} ${s},x } +if { forx -o 0 x { x $mod } importas x x s6-hiercopy /etc/s6/${base}/${x} ${s},x } + +ifelse { grep -qFx longrun /etc/s6/${base}/x/type } { + if { s6-hiercopy /etc/s6/.s6-rc/service-log ${s},log } + if { redirfd -a 1 ${s},x/producer-for echo ${s},log } + if { redirfd -w 1 ${s},log/consumer-for echo ${s},x } + if { redirfd -w 1 ${s},log/env/SERVICE echo ${s} } + if { redirfd -w 1 ${s},log/pipeline-name echo ${s} } + + cd ${s},x if -t { test -e setup } ./setup +} + +cd ${s} if -t { test -e setup } ./setup diff --git a/bin/service-disable b/bin/service-disable @@ -1,8 +1,9 @@ #!/usr/bin/env execlineb cd /var/s6 -backtick x { dollarat -n -d : } importas name x +backtick x { dollarat -n -d , } importas name x -if { rm -rf ${name} ${name}:log } -pipeline { grep -vFx -e ${name} -e ${name}:log x/contents } - sort -u -o x/contents - +if { rm -rf ${name},x ${name},log } +backtick -n t { s6-clock } importas t t +if { s6-rc-compile /var/s6/.s6-rc/compiled$t /var/s6 } +if { s6-rc-update -l /var/s6/.s6-rc/live /var/s6/.s6-rc/compiled$t } diff --git a/bin/service-enable b/bin/service-enable @@ -2,35 +2,7 @@ elgetpositionals -P 1 cd /var/s6 -backtick x { dollarat -n -d : } importas name x - -# always import the base "x" module -export 1 x - -# check that all compounds are defined -if { forbacktickx -0 -o 0 x { dollarat -0 } importas x x - test -d /etc/s6/${1}/${x} -} - -# start from scratch -if { service-disable $@ } - -# add each part of the service -if { forbacktickx -0 -o 0 x { dollarat -0 } importas x x - s6-hiercopy /etc/s6/${1}/${x} ${name} -} - -# setup the logger if it is a longrun service -if { if -t { grep -qFx longrun /etc/s6/${1}/x/type } - if { s6-hiercopy /etc/s6/.s6-rc/service-log ${name}:log } - if { redirfd -a 1 ${name}/producer-for echo ${name}:log } - if { redirfd -w 1 ${name}:log/consumer-for echo ${name} } - if { redirfd -w 1 ${name}:log/env/SERVICE echo ${name} } -} - -# append this service to the default service bundle -if { heredoc 0 "${name}\n" sort -u -o x/contents x/contents - } - -# execute into the setup script if there is one -cd $name -if -t { test -e setup } ./setup +if { service-build $@ } +backtick -n t { s6-clock } importas t t +if { s6-rc-compile /var/s6/.s6-rc/compiled$t /var/s6 } +if { s6-rc-update -l /var/s6/.s6-rc/live /var/s6/.s6-rc/compiled$t } diff --git a/bin/service-init b/bin/service-init @@ -10,9 +10,10 @@ background { backtick -n t { s6-clock } importas t t if { s6-rc-compile .s6-rc/compiled$t . } - redirfd -w 1 .s6-rc/log # wait that s6-svscan start + redirfd -w 1 .s6-rc/log # wait that s6-svscan starts if { s6-rc-init -c /var/s6/.s6-rc/compiled$t -l /var/s6/.s6-rc/live /run/s6 } - if { s6-rc -l .s6-rc/live -u change x } + if { s6-rc -l .s6-rc/live -u change s6rc-fdholder } + if { s6-rc -l .s6-rc/live -u change s6rc-oneshot-runner } if { echo service-init started } } diff --git a/bin/service-list b/bin/service-list @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb +elgetpositionals -P 1 -backtick x { dollarat -n -d : } importas name x -s6-rc -l /var/s6/.s6-rc/live listall $name +s6-rc -l /var/s6/.s6-rc/live list $@ diff --git a/bin/service-load b/bin/service-load @@ -1,6 +0,0 @@ -#!/usr/bin/env execlineb - -backtick -n t { s6-clock } importas t t -if { s6-rc-compile /var/s6/.s6-rc/compiled$t /var/s6 } -if { s6-rc-update -l /var/s6/.s6-rc/live /var/s6/.s6-rc/compiled$t } -if { s6-rc -l /var/s6/.s6-rc/live -u change x } diff --git a/bin/service-log b/bin/service-log @@ -1,6 +1,10 @@ #!/usr/bin/env execlineb - +elgetpositionals -P 1 cd /var/log -backtick x { dollarat -n -d : } importas name x -pipeline { tail -f ${name}/current } s6-tai64nlocal +backtick x { + pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } + sed -n "s/,log$// p" +} importas -ns -d "\n" x x + +pipeline { tail -f ${x}/current } s6-tai64nlocal diff --git a/bin/service-reload b/bin/service-reload @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb -backtick x { dollarat -n -d : } importas name x +backtick x { dollarat -n -d , } importas name x s6-svc -h /run/s6/$name diff --git a/bin/service-restart b/bin/service-restart @@ -1,4 +1,5 @@ #!/usr/bin/env execlineb elgetpositionals -P 1 + if { service-stop $@ } if { service-start $@ } diff --git a/bin/service-start b/bin/service-start @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb +elgetpositionals -P 1 -backtick x { dollarat -n -d : } importas name x -s6-rc -l /var/s6/.s6-rc/live -u change $name +s6-rc -l /var/s6/.s6-rc/live -u change $@ diff --git a/bin/service-status b/bin/service-status @@ -1,10 +1,14 @@ #!/usr/bin/env execlineb +elgetpositionals -P 1 -backtick x { dollarat -n -d : } importas name x +backtick x { + pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } + sed -n "s/,x$// p" +} importas -ns -d "\n" s x if { printf " " } -if { s6-svstat /run/s6/$name } +if { s6-svstat /run/s6/${s},x } if { printf "\n" } -if { backtick -n x { s6-svstat -o pid /run/s6/$name } importas x x ptree $x } +if { backtick -n x { s6-svstat -o pid /run/s6/${s},x } importas x x ptree $x } if { printf "\n" } -pipeline { tail /var/log/${name}/current } s6-tai64nlocal +pipeline { tail /var/log/${s}/current } s6-tai64nlocal diff --git a/bin/service-stop b/bin/service-stop @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb +elgetpositionals -P 1 -backtick x { dollarat -n -d : } importas name x -s6-rc -l /var/s6/.s6-rc/live -d change $name +s6-rc -l /var/s6/.s6-rc/live -d change $@ diff --git a/s6/.s6-rc/x/contents b/s6/.s6-rc/x/contents @@ -1,2 +0,0 @@ -s6rc-fdholder -s6rc-oneshot-runner diff --git a/s6/.s6-rc/x/type b/s6/.s6-rc/x/type @@ -1 +0,0 @@ -bundle diff --git a/s6/curvevpn-client/x/data/Makefile b/s6/curvevpn-client/x/data/Makefile @@ -1,4 +0,0 @@ -all: key - -key: - curvevpn-makekey key diff --git a/s6/curvevpn-client/x/env/EXT b/s6/curvevpn-client/x/env/EXT @@ -1 +0,0 @@ -00000000000000000000000000000000 diff --git a/s6/curvevpn-client/x/env/IP b/s6/curvevpn-client/x/env/IP @@ -1 +0,0 @@ -127.0.0.1 diff --git a/s6/curvevpn-client/x/env/NAME b/s6/curvevpn-client/x/env/NAME @@ -1 +0,0 @@ -vpn.josuah.net diff --git a/s6/curvevpn-client/x/env/PORT b/s6/curvevpn-client/x/env/PORT @@ -1 +0,0 @@ -1665 diff --git a/s6/curvevpn-client/x/env/PUBKEY b/s6/curvevpn-client/x/env/PUBKEY @@ -1 +0,0 @@ -0000000000000000000000000000000000000000000000000000000000000000 diff --git a/s6/curvevpn-client/x/env/ROOT b/s6/curvevpn-client/x/env/ROOT @@ -1 +0,0 @@ -. diff --git a/s6/curvevpn-client/x/env/SERVER b/s6/curvevpn-client/x/env/SERVER @@ -1 +0,0 @@ -IP- \ No newline at end of file diff --git a/s6/curvevpn-client/x/run b/s6/curvevpn-client/x/run @@ -1,10 +0,0 @@ -#!/usr/bin/env execlineb -fdmove -c 2 1 s6-envdir env multisubstitute { - importas NAME NAME - importas PUBKEY PUBKEY - importas IP IP - importas PORT PORT - importas EXT EXT -} - -curvevpn-client $NAME $PUBKEY $IP $PORT $EXT curvevpn diff --git a/s6/curvevpn-client/x/type b/s6/curvevpn-client/x/type @@ -1 +0,0 @@ -longrun diff --git a/s6/curvevpn-server/x/data/Makefile b/s6/curvevpn-server/x/data/Makefile @@ -1,7 +0,0 @@ -all: data.cdb key - -data.cdb: data - curvevpn-data - -key: - curvevpn-makekey key diff --git a/s6/curvevpn-server/x/data/data b/s6/curvevpn-server/x/data/data @@ -1,13 +0,0 @@ -# -- EXAMPLE ------------------------------------------------------------------------------------------------------------------ -# #defaut routes -# r::192.168.0.0:255.255.0.0 -# r::10.2.0.0:255.255.0.0 -# r::172.16.85.0:255.255.255.0 -# -# #IP address for the first user with public key 84fb6a942b1bcddff2cfd231d012d5d586b710ff180b6841da721eea5ee4004e -# i:84fb6a942b1bcddff2cfd231d012d5d586b710ff180b6841da721eea5ee4004e:172.16.85.3:172.16.85.4 -# -# #IP address for the second user with public key 68585b65041498f7b9f300ef890169cbc4b55927e9d15f9b3651109f338bf35e + extra route -# i:68585b65041498f7b9f300ef890169cbc4b55927e9d15f9b3651109f338bf35e:172.16.85.5:172.16.85.6 -# r:68585b65041498f7b9f300ef890169cbc4b55927e9d15f9b3651109f338bf35e:10.0.0.0:255.255.0.0 -# -- EXAMPLE ------------------------------------------------------------------------------------------------------------------ diff --git a/s6/curvevpn-server/x/data/data.cdb b/s6/curvevpn-server/x/data/data.cdb Binary files differ. diff --git a/s6/curvevpn-server/x/env/EXT b/s6/curvevpn-server/x/env/EXT @@ -1 +0,0 @@ -00000000000000000000000000000000 diff --git a/s6/curvevpn-server/x/env/IP b/s6/curvevpn-server/x/env/IP @@ -1 +0,0 @@ -0.0.0.0 diff --git a/s6/curvevpn-server/x/env/NAME b/s6/curvevpn-server/x/env/NAME @@ -1 +0,0 @@ -vpn.josuah.net diff --git a/s6/curvevpn-server/x/env/PORT b/s6/curvevpn-server/x/env/PORT @@ -1 +0,0 @@ -1665 diff --git a/s6/curvevpn-server/x/env/ROOT b/s6/curvevpn-server/x/env/ROOT @@ -1 +0,0 @@ -data diff --git a/s6/curvevpn-server/x/make-key b/s6/curvevpn-server/x/make-key @@ -1,2 +0,0 @@ -#!/usr/bin/env execline -curvevpn-makekey key diff --git a/s6/curvevpn-server/x/run b/s6/curvevpn-server/x/run @@ -1,14 +0,0 @@ -#!/usr/bin/env execlineb -fdmove -c 2 1 s6-envdir env multisubstitute { - importas NAME NAME - importas IP IP - importas PORT PORT - importas BASE BASE - importas EXT EXT -} - -cd $BASE -if { rm -f lock/???????????????????????????????????????????????????????????????? } -curvevpn-server $NAME data/key $IP $PORT $EXT -curvevpn-message -curvevpn -s ................................................................ diff --git a/s6/curvevpn-server/x/type b/s6/curvevpn-server/x/type @@ -1 +0,0 @@ -longrun diff --git a/s6/ffingerd-tcp/x/run b/s6/ffingerd-tcp/x/run @@ -1,7 +1,7 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT } -s6-tcpclient $HOST $PORT ffingerd +s6-tcpclient $BIND $PORT ffingerd diff --git a/s6/geomyidae/x/run b/s6/geomyidae/x/run @@ -1,9 +1,9 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT importas ROOT ROOT importas IPV IPV } -geomyidae -d -b $ROOT -h $HOST -p $PORT -$IPV +geomyidae -d -b $ROOT -h $BIND -p $PORT -$IPV diff --git a/s6/git-daemon/x/run b/s6/git-daemon/x/run @@ -1,11 +1,11 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT importas ROOT ROOT } -s6-tcpserver $HOST $PORT +s6-tcpserver $BIND $PORT git daemon --inetd --base-path=$ROOT diff --git a/s6/ntpclient/x/run b/s6/ntpclient/x/run @@ -1,6 +1,6 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND } -ntpclient -h $HOST +ntpclient -h $BIND diff --git a/s6/qmail-pop3d/x/run b/s6/qmail-pop3d/x/run @@ -1,9 +1,9 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT importas MAILDIR MAILDIR } -s6-tlsserver $HOST $PORT -qmail-popup $HOST checkpassword qmail-pop3d $MAILDIR +s6-tlsserver $BIND $PORT +qmail-popup $BIND checkpassword qmail-pop3d $MAILDIR diff --git a/s6/tapio/server/run b/s6/tapio/server/run @@ -1,10 +1,10 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT importas MODE MODE importas IFACE IFACE } -s6-tcpserver $HOST $PORT +s6-tcpserver $BIND $PORT tapio $IFACE mode $MODE diff --git a/s6/tinysshd/x/run b/s6/tinysshd/x/run @@ -1,8 +1,8 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT } -s6-tcpserver $HOST $PORT +s6-tcpserver $BIND $PORT tinysshd -sovv data/key diff --git a/s6/warp-vpn/server/run b/s6/warp-vpn/server/run @@ -1,8 +1,8 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { - importas HOST HOST + importas BIND BIND importas PORT PORT importas DEVTYPE DEVTYPE } -warp-vpn -d -b $HOST -t $DEVTYPE +warp-vpn -d -b $BIND -t $DEVTYPE