dot

packages and services management
Log | Files | Refs | README

commit e439c43ae6c54fec042f9397354a9c1904545914
parent d95e6767d09275a0aa3179f522c41ec3897153bb
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 16 Dec 2018 13:40:07 +0100

simplified service directory format

Diffstat:
Mbin/service-build | 17++++++++---------
Mbin/service-bundle | 1+
Mbin/service-compile | 15+++------------
Mbin/service-disable | 2+-
Mbin/service-init | 27++++++++++++++-------------
Mbin/service-list | 32++++++++++++++++++++++++++------
Mbin/service-log | 15++++++++++-----
Mbin/service-status | 4++--
Rs6/.s6-rc/service-log/env/SERVICE -> s6/.s6-log/env/SERVICE | 0
Rs6/.s6-rc/service-log/run -> s6/.s6-log/run | 0
Rs6/.s6-rc/s6-log/type -> s6/.s6-log/type | 0
Ds6/.s6-rc/s6-log/run | 6------
Ds6/.s6-rc/service-log/type | 1-
Ms6/qmail-smtpd/x/setup | 5+----
14 files changed, 66 insertions(+), 59 deletions(-)

diff --git a/bin/service-build b/bin/service-build @@ -16,20 +16,20 @@ 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 } +if { rm -rf ${sv} ${sv},log } -ifte { } { if { rm -rf ${sv},x ${sv},log } exit 1 } +ifte { } { if { rm -rf ${sv} ${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 + s6-hiercopy /etc/s6/${base}/${x} ${sv} } # build bundles recursively if { if -t { test ${type} = bundle } - backtick -i x { sed "s/^#.*//; /^[ \t]*$/ d" ${sv},x/contents } + backtick -i x { sed "s/^#.*//; /^[ \t]*$/ d" ${sv}/contents } importas -s -d "\n" x x service-build ${x} } @@ -39,13 +39,12 @@ 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-rc/service-log ${sv},log } - if { redirfd -a 1 ${sv},x/producer-for echo ${sv},log } + { s6-hiercopy /etc/s6/.s6-log ${sv},log } + if { redirfd -a 1 ${sv}/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 { redirfd -w 1 ${sv},log/consumer-for echo ${sv} } } -# run the setup script -cd ${sv},x +cd ${sv} if -t { test -e setup } ./setup diff --git a/bin/service-bundle b/bin/service-bundle @@ -9,6 +9,7 @@ forbacktickx -n x { } importas base x +if -t { if -t { test -f ${base}/type } if { grep longrun -Fxq ${base}/type } } if { mkdir -p ${base} } if { redirfd -w 1 ${base}/type echo bundle } diff --git a/bin/service-compile b/bin/service-compile @@ -1,5 +1,4 @@ #!/usr/bin/env execlineb -cd /var/s6 backtick -n x { s6-clock } importas time x @@ -7,14 +6,6 @@ importas time x backtick -n x { pwd } importas pwd x -if { s6-rc-compile .s6-rc/compiled${time} . } -if { s6-rc-update -l ${pwd}/.s6-rc/live ${pwd}/.s6-rc/compiled${time} } - -# build a bundle with a service and its logger (if any) -elglob -0 svlist *,x -forbacktickx -d "\n" -o 0 x { pipeline { printf "%s\n" ${svlist} } sed "s/,x$//" } -importas sv x - -ifthenelse { test -d ${sv},log } - { s6-rc-bundle -f -l .s6-rc/live add ${sv} ${sv},x ${sv},log } - { s6-rc-bundle -f -l .s6-rc/live add ${sv} ${sv},x } +if { mkdir -p /var/s6 /var/s6-rc/compiled } +if { s6-rc-compile /var/s6-rc/compiled/${time} /var/s6 } +if { s6-rc-update -l /var/s6-rc/live/live /var/s6-rc/compiled/${time} } diff --git a/bin/service-disable b/bin/service-disable @@ -2,6 +2,6 @@ cd /var/s6 elgetpositionals -P 1 -if { rm -rf ${@},x ${@},log } +if { rm -rf ${@} ${@},log } if { service-bundle } if { service-compile } diff --git a/bin/service-init b/bin/service-init @@ -1,24 +1,25 @@ #!/usr/bin/env execlineb -if { s6-rmrf /run/s6 /var/s6/.s6-rc/log } -if { s6-mkdir -p /run/s6 /var/log /var/s6/.s6-rc } - -cd /var/s6 - -if { s6-mkfifo .s6-rc/log } -if { s6-hiercopy /etc/s6/.s6-rc/s6-log .s6-rc/s6-log } -if { s6-ln -s /var/s6/.s6-rc/s6-log /run/s6 } +if { s6-rmrf /run/s6 /var/s6-rc/log } +if { s6-mkdir -p /run/s6 /var/s6-rc/log /var/s6-rc } +if { s6-mkfifo /var/s6-rc/log/fifo } +if { redirfd -w 0 /var/s6-rc/log/type echo "longrun" } +if { redirfd -w 0 /var/s6-rc/log/run echo "#!/usr/bin/env execlineb +fdmove -c 2 1 redirfd -rnb 0 /var/s6-rc/log/fifo s6-log -bp t /var/log/s6" } +if { s6-ln -s /var/s6-rc/log /run/s6 } background { backtick -n t { s6-clock } importas t t - if { s6-rc-compile .s6-rc/compiled$t . } + if { s6-rc-compile /var/s6-rc/compiled/${t} /var/s6 } + + # wait that s6-svscan starts + redirfd -w 1 /var/s6-rc/log - 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 s6rc-fdholder } - if { s6-rc -l .s6-rc/live -u change s6rc-oneshot-runner } + if { s6-rc-init -c /var/s6/.s6-rc/compiled/${t} -l /var/s6-rc/live/live /run/s6 } + if { s6-rc -l /var/s6-rc/live/live -u change s6rc-fdholder } + if { s6-rc -l /var/s6-rc/live/live -u change s6rc-oneshot-runner } if { echo service-init started } } diff --git a/bin/service-list b/bin/service-list @@ -1,9 +1,29 @@ #!/usr/bin/env execlineb -elgetpositionals -P 1 +elgetpositionals -pipeline { - ifelse { test ${#} = 0 } - { s6-rc-db -l /var/s6/.s6-rc/live list all } - s6-rc -l /var/s6/.s6-rc/live list $@ +forbacktickx -n -o 0 x { + pipeline { + ifthenelse { test ${#} = 0 } + { s6-rc-db -l /var/s6-rc/live/live list all } + { s6-rc -l /var/s6-rc/live/live list $@ } + } + pipeline { grep -v ",log$" } + sort } -sort +importas service x + +backtick -n x { + pipeline { s6-svstat -o up,wantedup /run/s6/${service} } + sed " + s/true true/+/ + s/true false/?/ + s/false true/!/ + s/false false/ / + " +} +importas flag x + +backtick -n x { s6-svstat -o updownfor /run/s6/${service} } +importas updownfor x + +printf " %s %-40s %10ds\n" ${flag} ${service} ${updownfor} diff --git a/bin/service-log b/bin/service-log @@ -1,11 +1,16 @@ #!/usr/bin/env execlineb -elgetpositionals -P 1 +elgetpositionals + +if -n { test ${#} = 0 } backtick x { - pipeline { s6-rc -l "/var/s6/.s6-rc/live" list $@ } - sed -n "s/,log$// p" + pipeline { s6-rc -l /var/s6-rc/live/live list ${@} } + pipeline { sed -n "s/,log$// p" } + sort } importas -ns -d "\n" sv x -pipeline { tail -n 100 -f "/var/log/${sv}/current" } -s6-tai64nlocal +pipeline { elglob x /var/log/${sv}/@* cat ${x} /var/log/${sv}/current } +pipeline { sort -t " " -k1,1 } +pipeline { s6-tai64nlocal } +less diff --git a/bin/service-status b/bin/service-status @@ -12,10 +12,10 @@ importas -n -d "\n" sv x if { heredoc 0 ${sv} sed -r "s/([^,]*),?(.*)/ \033[1m\\1\033[m (\\2)/; s/\\(\\)/(x)/" } if { printf " " } -if { s6-svstat /run/s6/${sv},x } +if { s6-svstat /run/s6/${sv} } if { printf "\n" } if { - backtick -n x { s6-svstat -o pid /run/s6/${sv},x } + backtick -n x { s6-svstat -o pid /run/s6/${sv} } importas x x pipeline { ps -ax -o ppid,user,pid,stat,comm,args } ptree -- ${x} diff --git a/s6/.s6-rc/service-log/env/SERVICE b/s6/.s6-log/env/SERVICE diff --git a/s6/.s6-rc/service-log/run b/s6/.s6-log/run diff --git a/s6/.s6-rc/s6-log/type b/s6/.s6-log/type diff --git a/s6/.s6-rc/s6-log/run b/s6/.s6-rc/s6-log/run @@ -1,6 +0,0 @@ -#!/usr/bin/env execlineb -fdmove -c 2 1 - - -redirfd -rnb 0 /var/s6/.s6-rc/log -s6-log -bp t /var/log/s6 diff --git a/s6/.s6-rc/service-log/type b/s6/.s6-rc/service-log/type @@ -1 +0,0 @@ -longrun diff --git a/s6/qmail-smtpd/x/setup b/s6/qmail-smtpd/x/setup @@ -1,6 +1,3 @@ #!/usr/bin/env execlineb -if { s6-hiercopy conf /var/qmail/ } - -s6-redirdfd -a run -elglob -0 data/* x cat ${x} +s6-hiercopy conf /var/qmail