dot

packages and services management
Log | Files | Refs | README

commit 46668377b6c226bbbbb5c8dd1fea86f54e8b5b40
parent fc3740bcb2814c581c75c102d7c0988a4c5ae2fa
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat, 22 Dec 2018 21:53:51 +0100

use "host" as a definition for all services for this host

Diffstat:
Abin/service-build | 50++++++++++++++++++++++++++++++++++++++++++++++++++
Dbin/service-enable | 50--------------------------------------------------
Mbin/service-init | 25+++++++++++++------------
Mbin/service-list | 8++++----
Aconf/host | 17+++++++++++++++++
Aetc/s6/host/kuntur/contents | 9+++++++++
Aetc/s6/host/x/type | 1+
Metc/s6/httpfile/x/env/ROOT | 2+-
Ahost/kuntur/services | 9+++++++++
9 files changed, 104 insertions(+), 67 deletions(-)

diff --git a/bin/service-build b/bin/service-build @@ -0,0 +1,50 @@ +#!/usr/bin/env execlineb +elgetpositionals + +if { mkdir -p /var/s6/source } +cd /var/s6/source + +forx -o 0 x { ${@} } +importas sv x + +backtick -n x { heredoc 0 ${sv} cut -d , -f 1 } +importas base x + +backtick -n x { heredoc 0 ${sv} cut -s -d , -f 2- } +importas -s -d , mod x + +redirfd -r 0 /etc/s6/${base}/x/type +withstdinas x +importas -n type x + +if { cd /etc/s6/${base} redirfd -w 1 /dev/null ls -d ${mod} } +if { rm -rf ${sv},x ${sv},log } + +ifte { } { if { rm -rf ${sv},x ${sv},log } exit 1 } + +# copy all the modules +if { + forx -o 0 x { x ${mod} } importas x x + s6-hiercopy /etc/s6/${base}/${x} ${sv},x +} + +# build bundles recursively +if { + if -t { test ${type} = bundle } + backtick -i x { sed "s/^#.*//; /^[ \t]*$/ d; s/,x$//" ${sv},x/contents } + importas -s -d "\n" x x + service-build ${x} +} + +# setup the logger for longruns +if { + if -t { test ${type} = longrun } + ifthenelse { test -d /etc/s6/${sv}/log } + { s6-hiercopy /etc/s6/${sv}/log ${sv},log } + { s6-hiercopy /etc/s6/.s6-log ${sv},log } + if { redirfd -a 1 ${sv},x/producer-for echo ${sv},log } + if { redirfd -w 1 ${sv},log/env/SERVICE echo ${sv} } + if { redirfd -w 1 ${sv},log/consumer-for echo ${sv},x } +} + +if { cd ${sv},x if -t { test -x setup } ./setup } diff --git a/bin/service-enable b/bin/service-enable @@ -1,50 +0,0 @@ -#!/usr/bin/env execlineb -elgetpositionals - -if { mkdir -p /var/s6/source } -cd /var/s6/source - -forx -o 0 x { ${@} } -importas sv x - -backtick -n x { heredoc 0 ${sv} cut -d , -f 1 } -importas base x - -backtick -n x { heredoc 0 ${sv} cut -s -d , -f 2- } -importas -s -d , mod x - -redirfd -r 0 /etc/s6/${base}/x/type -withstdinas x -importas -n type x - -if { cd /etc/s6/${base} redirfd -w 1 /dev/null ls -d ${mod} } -if { rm -rf ${sv},x ${sv},log } - -ifte { } { if { rm -rf ${sv},x ${sv},log } exit 1 } - -# copy all the modules -if { - forx -o 0 x { x ${mod} } importas x x - s6-hiercopy /etc/s6/${base}/${x} ${sv},x -} - -# build bundles recursively -if { - if -t { test ${type} = bundle } - backtick -i x { sed "s/^#.*//; /^[ \t]*$/ d" ${sv},x/contents } - importas -s -d "\n" x x - service-build ${x} -} - -# setup the logger for longruns -if { - if -t { test ${type} = longrun } - ifthenelse { test -d /etc/s6/${sv}/log } - { s6-hiercopy /etc/s6/${sv}/log ${sv},log } - { s6-hiercopy /etc/s6/.s6-log ${sv},log } - if { redirfd -a 1 ${sv},x/producer-for echo ${sv},log } - if { redirfd -w 1 ${sv},log/env/SERVICE echo ${sv} } - if { redirfd -w 1 ${sv},log/consumer-for echo ${sv},x } -} - -if { cd ${sv},x if -t { test -x setup } ./setup } diff --git a/bin/service-init b/bin/service-init @@ -1,8 +1,9 @@ #!/usr/bin/env execlineb +if { rm -rf /run/s6 } if { mkdir -p /var/s6 } cd /var/s6 if { s6-mkdir -p source compiled live /run/s6 } -if { elglob -0 x live/* rm -rf /run/s6 ${x} } +if { elglob -0 x live/* rm -rf ${x} } # logger if { s6-mkdir -p /run/s6/logger } @@ -16,29 +17,29 @@ if { redirfd -w 1 /run/s6/logger/run printf "%s\n" if { s6-chmod 0755 /run/s6/logger/run } if { redirfd -w 1 /run/s6/logger/type echo "longrun" } -# ok-all -if { s6-mkdir -p source/ok-all } -if { touch source/ok-all/contents } -if { redirfd -w 1 source/ok-all/type echo "bundle" } +# host service +if { s6-mkdir -p source/host } +if { touch source/host/contents } +if { redirfd -w 1 source/host/type echo "bundle" } background { backtick -n x { s6-clock } importas t x - ifthenelse { test ! -h compiled/ current } { + ifthenelse { test ! -h compiled/current } { if { s6-rc-compile compiled/${t} source } - if { s6-ln -sfn compiled/${t} compiled/ current } + if { s6-ln -sfn compiled/${t} compiled/current } } { } # wait that s6-svscan starts redirfd -w 1 /run/s6/logger/log - if { s6-rc-init -d -c compiled/ current -l /var/s6/live /run/s6 } + if { s6-rc-init -d -c compiled/current -l /var/s6/live/live /run/s6 } if { s6-ln -sf /var/s6/live/live /run/s6-rc } - if { s6-rc -l live/live -u change s6rc-fdholder } - if { s6-rc -l live/live -u change s6rc-oneshot-runner } - if { s6-rc -l live/live -u change ok-all } - if { echo srv-init finished to boot } + if { s6-rc -u change s6rc-fdholder } + if { s6-rc -u change s6rc-oneshot-runner } + if { s6-rc -u change ok-all } + if { echo service-init finished to boot } } redirfd -r 0 /dev/null diff --git a/bin/service-list b/bin/service-list @@ -5,18 +5,18 @@ pipeline { forbacktickx -n -o 0 x { pipeline { ifthenelse { test ${#} = 0 } - { s6-rc-db -l /var/s6/live list longruns } - { s6-rc -l /var/s6/live list $@ } + { s6-rc-db list longruns } + { s6-rc list $@ } } pipeline { sed -n "s/,x$// p" } sort } importas service x - backtick -n x { s6-svstat -o up,wantedup /var/s6/scandir/${service},x } + backtick -n x { s6-svstat -o up,wantedup /run/s6/${service},x } importas up x - backtick -n x { s6-svstat -o updownfor /var/s6/scandir/${service},x } + backtick -n x { s6-svstat -o updownfor /run/s6/${service},x } importas since x if { printf "%10ds %s %s\n" ${since} ${up} ${service} } diff --git a/conf/host b/conf/host @@ -0,0 +1,17 @@ +#!/usr/bin/env execlineb +elgetpositionals + +backtick -n x { dirname ${0} } +importas basedir x + +backtick -n x { uname -n } +importas hostname x + +if { mkdir -p /var/s6/source/ok-all } +if { cp ${basedir}/host/${hostname}/services /var/s6/source/ok-all } + +ifthenelse { test -f host/${hostname}/services } { + backtick -n x host/${hostname}/services + importas -s -d "\n" svs x + service-enable ${svs} +} {} diff --git a/etc/s6/host/kuntur/contents b/etc/s6/host/kuntur/contents @@ -0,0 +1,9 @@ +geomyidae,ipv4,josuah.net,x +geomyidae,ipv6,josuah.net,x +git-daemon,x +httpfile,tcp,x +httpfile,tls,h-o.st,x +qmail-smtpd,tcp,josuah.net,x +qmail-smtpd,tls,josuah.net,x +tinysshd,x +transmission,x diff --git a/etc/s6/host/x/type b/etc/s6/host/x/type @@ -0,0 +1 @@ +bundle diff --git a/etc/s6/httpfile/x/env/ROOT b/etc/s6/httpfile/x/env/ROOT @@ -1 +1 @@ -/var/www +/var/httpfile diff --git a/host/kuntur/services b/host/kuntur/services @@ -0,0 +1,9 @@ +geomyidae,ipv4,josuah.net +geomyidae,ipv6,josuah.net +git-daemon +httpfile,tcp +httpfile,tls,h-o.st +qmail-smtpd,tcp,josuah.net +qmail-smtpd,tls,josuah.net +tinysshd +transmission