dot

packages and services management
Log | Files | Refs | README

commit 4e4caa0897d0c827d9e223df415cc9b4fed4449f
parent cd173518e2e9328933906e963643e2145772c0e1
Author: Josuah Demangeon <mail@josuah.net>
Date:   Thu,  8 Nov 2018 22:49:52 +0100

adapt service-* scripts, in particular, service-init

Diffstat:
Mbin/service-disable | 4++--
Mbin/service-enable | 8+++-----
Mbin/service-init | 34+++++++++++++++++++---------------
Mbin/service-load | 2+-
Mbin/service-reload | 4++--
Mbin/service-restart | 6+++---
Mbin/service-start | 4++--
Mbin/service-status | 3++-
Mbin/service-stop | 4++--
Aconf/etc | 4++++
Ms6/ii-tls/x/run | 2+-
Ms6/ok/minimal/contents | 1+
Ms6/ok/server/contents | 7++++---
As6/s6-log/x/env/SERVICE | 0
As6/s6-log/x/run | 7+++++++
As6/s6-log/x/type | 1+
Ds6/s6-logger/x/run | 8--------
As6/s6-svscan/log/run | 8++++++++
As6/s6-svscan/log/type | 1+
19 files changed, 63 insertions(+), 45 deletions(-)

diff --git a/bin/service-disable b/bin/service-disable @@ -5,5 +5,5 @@ if { mkdir -p ok-all } if { touch ok-all/contents } forbacktickx -n x { pipeline { dollarat } tr / - } importas x x -if { rm -rf $x } -pipeline { grep -Fv $x ok-all/contents } sort -u -o ok-all/contents - +if { rm -rf ${x} ${x}-log } +pipeline { grep -Fv -e ${x} -e ${x}-log ok-all/contents } sort -u -o ok-all/contents - diff --git a/bin/service-enable b/bin/service-enable @@ -1,6 +1,5 @@ #!/usr/bin/env execlineb cd /var/s6/source -define SERVICE /root/dot/s6 importas SERVICE SERVICE ifelse { pipeline { dollarat } grep -Evq "^[^/]+/[^/]+\$" } { foreground { echo "usage: service-enable service/version..." } @@ -8,15 +7,14 @@ ifelse { pipeline { dollarat } grep -Evq "^[^/]+/[^/]+\$" } { } forbacktickx -n src { dollarat } importas src src - backtick -n dir { dirname $src } importas dir dir backtick -n dst { pipeline { echo $src } tr / - } importas dst dst define -n log ${dst}-log importas log log if { rm -rf $dst $log } -if { s6-hiercopy ${SERVICE}/s6-log/x $log } -if { s6-hiercopy ${SERVICE}/${dir}/x $dst } -if { s6-hiercopy ${SERVICE}/${src} $dst } +if { s6-hiercopy /etc/s6/s6-log/x $log } +if { s6-hiercopy /etc/s6/${dir}/x $dst } +if { s6-hiercopy /etc/s6/${src} $dst } if { redirfd -w 1 ${dst}/env/SERVICE echo $dst } if { redirfd -w 1 ${dst}/producer-for echo $log } if { redirfd -w 1 ${log}/consumer-for echo $dst } diff --git a/bin/service-init b/bin/service-init @@ -1,27 +1,31 @@ #!/usr/bin/env execlineb if { s6-rmrf /run/s6 /var/s6/init } -if { s6-mkdir -p /run/s6 /var/s6 /var/log } -if { s6-ln -sf /var/s6/s6-logger /run/s6 } +if { s6-mkdir -p /run/s6 /var/log /var/s6/init /var/s6/source } +if { s6-mkfifo /var/s6/init/fifo } +cd /var/s6 +if { cp -r /etc/s6/s6-svscan/log /var/s6/source/s6-svscan-log } background { - # wait until s6-svscan starts - redirfd -w 1 /var/s6/s6-logger/fifo + redirfd -r 1 init/fifo + s6-log /var/log/s6-svscan t +} - s6-setsid -- - fdmove -c 1 2 +background { + backtick -n t { s6-clock } importas t t + if { s6-rc-compile compiled$t source } + if { s6-rc-init -c /var/s6/compiled$t -l /var/s6/live /run/s6 } + if { s6-ln -nsf compiled$t compiled } - backtick -n t { s6-clock } - importas t t - if { s6-rc-compile /var/s6/compiled${t} /etc/s6 } - if { s6-rc-init -c /var/s6/compiled${t} -l /var/s6/live /run/s6 } - if { s6-ln -nsf /var/s6/compiled${t} /var/s6/compiled } - if { s6-rc -l /var/s6/live -u change ok-all } + redirfd -w 1 init/fifo # wait that s6-svscan start + if { importas ! ! kill $! } # then kill s6-log + if { s6-rc -l live -u change s6-svscan-log } + if { s6-rc -l live -u change ok-all } if { echo ok } } -cd /var/s6 +redirfd -wnb 1 init/fifo +redirfd -wnb 2 init/fifo redirfd -r 0 /dev/null -redirfd -wnb 1 /var/s6/s6-logger/fifo -fdmove -c 2 1 + s6-svscan -t0 /run/s6 diff --git a/bin/service-load b/bin/service-load @@ -1,7 +1,7 @@ #!/usr/bin/env execlineb backtick t { s6-clock } importas -n t t -if { s6-rc-compile /var/s6/compiled$t /etc/s6 } +if { s6-rc-compile /var/s6/compiled$t /var/s6/source } if { s6-rc-update -l /var/s6/live /var/s6/compiled$t } if { s6-ln -nsf /var/s6/compiled$t /var/s6/compiled } if { s6-rc -l /var/s6/live -u change ok-all } diff --git a/bin/service-reload b/bin/service-reload @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb -importas 1 1 -s6-svc -h /run/s6/$1 +forbacktickx x { pipeline { dollarat } tr / - } importas -n x x +s6-svc -h /run/s6/$x diff --git a/bin/service-restart b/bin/service-restart @@ -1,5 +1,5 @@ #!/usr/bin/env execlineb -importas 1 1 -if { service-stop $1 } -if { service-start $1 } +backtick @ { pipeline { dollarat } tr / - } importas -n @ @ +if { service-stop $@ } +if { service-start $@ } diff --git a/bin/service-start b/bin/service-start @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb -importas 1 1 -s6-rc -l /var/s6/live -u change $1 +backtick @ { pipeline { dollarat } tr / - } importas @ @ +s6-rc -l /var/s6/live -u change $@ diff --git a/bin/service-status b/bin/service-status @@ -1,3 +1,4 @@ #!/usr/bin/env execlineb -dollarat s6-rc -l /var/s6/live listall +backtick @ { pipeline { dollarat } tr / - } importas @ @ +s6-rc -l /var/s6/live listall $@ diff --git a/bin/service-stop b/bin/service-stop @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb -importas 1 1 -s6-rc -l /var/s6/live -d change $1 +backtick @ { pipeline { dollarat } tr / - } importas @ @ +s6-rc -l /var/s6/live -d change $@ diff --git a/conf/etc b/conf/etc @@ -0,0 +1,4 @@ +#!/bin/sh -e + +cd "$(dirname "$0")/.." +ln -sf "$PWD/s6" /etc diff --git a/s6/ii-tls/x/run b/s6/ii-tls/x/run @@ -12,7 +12,7 @@ s6-envdir env multisubstitute { ifelse -n { test -f ${CAFILE} } { redirfd -r 0 /dev/null redirfd -w 1 ${CAFILE} - openssl s_client -showcerts -connect ${HOST}:6697 + openssl s_client -showcerts -connect ${HOST}:${PORT} } s6-setuidgid ${USER} diff --git a/s6/ok/minimal/contents b/s6/ok/minimal/contents @@ -1,2 +1,3 @@ +s6-svscan-log s6rc-fdholder s6rc-oneshot-runner diff --git a/s6/ok/server/contents b/s6/ok/server/contents @@ -1,8 +1,9 @@ +acme-client +curvevpn httpfile +ngircd qmail +s6-svscan-log s6rc-fdholder s6rc-oneshot-runner tinysshd -ngircd -curvevpn -acme-client diff --git a/s6/s6-log/x/env/SERVICE b/s6/s6-log/x/env/SERVICE diff --git a/s6/s6-log/x/run b/s6/s6-log/x/run @@ -0,0 +1,7 @@ +#!/usr/bin/env execlineb +fdmove -c 2 1 +s6-envdir env multisubstitute { + importas SERVICE SERVICE +} + +s6-log -bp -- t /var/log/$SERVICE diff --git a/s6/s6-log/x/type b/s6/s6-log/x/type @@ -0,0 +1 @@ +longrun diff --git a/s6/s6-logger/x/run b/s6/s6-logger/x/run @@ -1,8 +0,0 @@ -#!/usr/bin/env execlineb -redirfd -w 2 /dev/console -redirfd -w 1 /dev/null -redirfd -rnb 0 fifo - -s6-applyuidgid -u 0 -g 0 - -s6-log -bp -- t /var/log/s6 diff --git a/s6/s6-svscan/log/run b/s6/s6-svscan/log/run @@ -0,0 +1,8 @@ +#!/usr/bin/env execlineb +redirfd -w 2 /dev/console +redirfd -w 1 /dev/null +redirfd -rnb 0 /var/s6/init/fifo + +#s6-applyuidgid -u 0 -g 0 + +s6-log -bp t /var/log/s6 diff --git a/s6/s6-svscan/log/type b/s6/s6-svscan/log/type @@ -0,0 +1 @@ +longrun