dot

packages and services management
Log | Files | Refs | README

commit cdb98da58eec162b6c743fd04dc80ce83706df93
parent 42bba6bb92a1f63edd2a385836d8d20ca443f6ec
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 19 Nov 2018 23:33:03 +0100

bin/service-*: use ':' as segment delimiter and x instead of ok-all

Diffstat:
Mbin/service-disable | 10++++------
Mbin/service-enable | 45++++++++++++++++++++++++++++++---------------
Mbin/service-init | 2+-
Abin/service-list | 4++++
Mbin/service-load | 2+-
Mbin/service-log | 2+-
Mbin/service-reload | 2+-
Mbin/service-restart | 7+++----
Mbin/service-start | 2+-
Mbin/service-status | 4++--
Mbin/service-stop | 2+-
Rs6/.s6-rc/ok-all/contents -> s6/.s6-rc/x/contents | 0
Rs6/.s6-rc/ok-all/type -> s6/.s6-rc/x/type | 0
13 files changed, 49 insertions(+), 33 deletions(-)

diff --git a/bin/service-disable b/bin/service-disable @@ -1,10 +1,8 @@ #!/usr/bin/env execlineb cd /var/s6 -if { mkdir -p ok-all } -if { touch ok-all/contents } +backtick x { dollarat -n -d : } importas name x -backtick x { dollarat -n -d - } importas name x -if { rm -rf ${name} ${name}-log } -pipeline { grep -Fv -e ${name} -e ${name}-log ok-all/contents } - sort -u -o ok-all/contents - +if { rm -rf ${name} ${name}:log } +pipeline { grep -vFx -e ${name} -e ${name}:log x/contents } + sort -u -o x/contents - diff --git a/bin/service-enable b/bin/service-enable @@ -1,20 +1,35 @@ #!/usr/bin/env execlineb +elgetpositionals -P 1 cd /var/s6 -importas -n base 1 -backtick -n x { dollarat -n -d - } importas name x +backtick x { dollarat -n -d : } importas name x -if { rm -rf ${name} ${name}-log } -if { export 1 x - forbacktickx -n x { dollarat } importas x x - s6-hiercopy /etc/s6/${base}/${x} $name +# always import the base "x" module +export 1 x + +# check that all compounds are defined +if { forbacktickx -0 x { dollarat -0 } importas x x test -d /etc/s6/${1}/${x} } + +# start from scratch +if { service-disable $@ } + +# setup the logger if it is a longrun service +ifthenelse { 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} } } -if { cd $name if { test -f setup } ./setup } - -if { grep -qFx longrun /etc/s6/${base}/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} } -pipeline { printf "%s\n" ${name} ${name}-log } -sort -u -o ok-all/contents ok-all/contents - + +# append this service to the default service bundle +if { heredoc 0 "${name}\n" sort -u -o x/contents x/contents - } + +# add each part of the service +if { + forbacktickx -0 x { dollarat -0 } importas x x + if { s6-hiercopy /etc/s6/${1}/${x} ${name} } + 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 diff --git a/bin/service-init b/bin/service-init @@ -12,7 +12,7 @@ background { redirfd -w 1 .s6-rc/log # wait that s6-svscan start 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 ok-all } + if { s6-rc -l .s6-rc/live -u change x } if { echo service-init started } } diff --git a/bin/service-list b/bin/service-list @@ -0,0 +1,4 @@ +#!/usr/bin/env execlineb + +backtick x { dollarat -n -d : } importas name x +s6-rc -l /var/s6/.s6-rc/live listall $name diff --git a/bin/service-load b/bin/service-load @@ -3,4 +3,4 @@ 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 ok-all } +if { s6-rc -l /var/s6/.s6-rc/live -u change x } diff --git a/bin/service-log b/bin/service-log @@ -2,5 +2,5 @@ cd /var/log -backtick x { dollarat -n -d - } importas name x +backtick x { dollarat -n -d : } importas name x pipeline { tail -f ${name}/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,5 +1,4 @@ #!/usr/bin/env execlineb - -backtick -n x { dollarat -n -d - } importas name x -if { service-stop $name } -if { service-start $name } +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 -backtick x { dollarat -n -d - } importas name x +backtick x { dollarat -n -d : } importas name x s6-rc -l /var/s6/.s6-rc/live -u change $name diff --git a/bin/service-status b/bin/service-status @@ -1,4 +1,4 @@ #!/usr/bin/env execlineb -backtick x { dollarat -n -d - } importas name x -s6-rc -l /var/s6/.s6-rc/live listall $name +backtick x { dollarat -n -d : } importas name x +s6-svstat /run/s6/$name diff --git a/bin/service-stop b/bin/service-stop @@ -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-rc -l /var/s6/.s6-rc/live -d change $name diff --git a/s6/.s6-rc/ok-all/contents b/s6/.s6-rc/x/contents diff --git a/s6/.s6-rc/ok-all/type b/s6/.s6-rc/x/type