dot

packages and services management
Log | Files | Refs | README

commit 868debb2a6dff677ddade2e487b2fc7d6cec8627
parent a7aef80c559be4d7dd3d671d13ce18d69e47505b
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 25 Nov 2018 20:21:59 +0100

various fixups, no time to explain

Diffstat:
Mbin/pack-http | 2+-
Mbin/pack-tar | 9+++++----
Mbin/service-build | 51+++++++++++++++++++++++++++++++--------------------
Mbin/service-disable | 7++++---
Mbin/service-enable | 16+++++++++++++---
Mbin/service-init | 9+++++++--
Mbin/service-log | 6++++--
Mbin/service-reload | 4+++-
Mbin/service-status | 26+++++++++++++++++++-------
Apack/bird/dependencies/oyacc | 2++
Dpack/bird/dependencies/yacc | 2--
Mpack/libcurses/build | 6++++--
Ms6/httpfile/tcp/run | 4++--
Ms6/httpfile/tls/run | 4++--
As6/tinydns/himalaya-solaire.org/conf/alias/himalaya-solaire.org | 2++
As6/tinydns/himalaya-solaire.org/conf/alias/www.himalaya-solaire.org | 2++
As6/tinydns/himalaya-solaire.org/conf/alias6/git.josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/alias6/irc.josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/alias6/josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/alias6/mail.josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/alias6/www.josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/mx/himalaya-solaire.org | 2++
As6/tinydns/himalaya-solaire.org/conf/ns/josuah.net | 1+
As6/tinydns/himalaya-solaire.org/conf/txt/himalaya-solaire.org | 1+
Ms6/tinydns/x/setup | 1+
25 files changed, 111 insertions(+), 51 deletions(-)

diff --git a/bin/pack-http b/bin/pack-http @@ -6,7 +6,7 @@ trap "rm -f '/etc/pack/tar/$pack/$version.tar'" INT TERM EXIT mkdir -p "$PACK/src/$pack/$version" "$PACK/tar/$pack" if [ ! -f "$PACK/tar/$pack/$version.tar" ]; then - wget -O- "$url" | pack-extract "$url" >/var/pack/tar/$pack/$version.tar + wget --no-check-certificate -O- "$url" | pack-extract "$url" >/var/pack/tar/$pack/$version.tar fi trap - INT TERM EXIT diff --git a/bin/pack-tar b/bin/pack-tar @@ -6,9 +6,10 @@ trap "rm -rf '$PACK/src/$pack/$version'" EXIT TERM INT mkdir -p "$PACK/src/$pack/$version" tar -xv -f "$PACK/tar/$pack/$version.tar" -C "$PACK/src/$pack/$version" -echo archive extracted correctly -! mv "$PACK/src/$pack/$version/"*/* "$PACK/src/$pack/$version" -! rmdir "$PACK/src/$pack/$version"/* 2>/dev/null +if [ "$(ls "$PACK/src/$pack/$version" | wc -l | tr -cd 0-9)" = 1 ]; then + ! mv "$PACK/src/$pack/$version/"*/* "$PACK/src/$pack/$version" + ! rmdir "$PACK/src/$pack/$version"/* 2>/dev/null +fi trap - EXIT TERM INT -echo ok +echo archive extracted correctly diff --git a/bin/service-build b/bin/service-build @@ -1,34 +1,45 @@ #!/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 -backtick -n x { heredoc 0 $s cut -s -d , -f 2- } importas -s -d , mod x +forbacktickx -o 0 -0 x { dollarat -0 } +importas sv x -if { forx -o 0 x { x $mod } importas x x test -d /etc/s6/${base}/${x} } -if { rm -rf ${s} ${s},x } +backtick -n x { heredoc 0 $sv cut -d , -f 1 } +importas base x -ifelse { grep -qFx longrun /etc/s6/${base}/x/type } { - if { forx -o 0 x { x $mod } importas x x s6-hiercopy /etc/s6/${base}/${x} ${s},x } +backtick -n x { heredoc 0 $sv cut -s -d , -f 2- } +importas -s -d , mod x - 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} } +redirfd -r 0 /etc/s6/${base}/x/type +withstdinas x +importas -n type x - cd ${s},x if -t { test -e setup } ./setup +if { cd /etc/s6/${base} fdclose 1 ls x ${mod} } + +backtick -n x { if -t { test $type = longrun } echo ,x } +importas ext x + +if { rm -rf ${sv} ${sv},x } + +if { + forx -o 0 x { x $mod } importas x x + s6-hiercopy /etc/s6/${base}/${x} ${sv}${ext} } -ifelse { grep -qFx bundle /etc/s6/${base}/x/type } { - if { forx -o 0 x { x $mod } importas x x s6-hiercopy /etc/s6/${base}/${x} ${s} } +if { if -t { test $type = bundle } + forbacktickx -n -d "\n" x { sed "s/^#.*//; /^[ \t]*$/ d" ${sv}/contents } + importas x x - forbacktickx -n -d "\n" x { sed "s/^#.*//; /^[ \t]*$/ d" ${s}/contents } importas x x service-build $x } -ifelse { grep -qFx oneshot /etc/s6/${base}/x/type } { - if { forx -o 0 x { x $mod } importas x x s6-hiercopy /etc/s6/${base}/${x} ${s} } - - cd ${s},x if -t { test -e setup } ./setup +if { if -t { test $type = longrun } + if { s6-hiercopy /etc/s6/.s6-rc/service-log ${sv},log } + if { redirfd -a 1 ${sv},x/producer-for echo ${sv},log } + if { redirfd -w 1 ${sv},log/consumer-for echo ${sv},x } + if { redirfd -w 1 ${sv},log/env/SERVICE echo ${sv} } + if { redirfd -w 1 ${sv},log/pipeline-name echo ${sv} } } + +cd ${sv}${ext} +if -t { test -e setup } ./setup diff --git a/bin/service-disable b/bin/service-disable @@ -1,9 +1,10 @@ #!/usr/bin/env execlineb cd /var/s6 -backtick x { dollarat -n -d , } importas name x +if { rm -rf ${@} ${@},x ${@},log } + +backtick -n t { s6-clock } +importas t t -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 @@ -3,6 +3,16 @@ elgetpositionals -P 1 cd /var/s6 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 } + +backtick -n x { s6-clock } +importas time x + +if { s6-rc-compile .s6-rc/compiled${time} . } +if { s6-rc-update -l /var/s6/.s6-rc/live /var/s6/.s6-rc/compiled${time} } + +# bundle all variants of a base service together +forbacktickx -n x { pipeline { s6-ls . } pipeline { sed "s/,.*//" } sort -u } +importas base x + +elglob x ${base},* +s6-rc-bundle -f -l .s6-rc/live add $base $x diff --git a/bin/service-init b/bin/service-init @@ -1,13 +1,18 @@ #!/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-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 } background { - backtick -n t { s6-clock } importas t t + 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 starts diff --git a/bin/service-log b/bin/service-log @@ -5,6 +5,8 @@ cd /var/log backtick x { pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } sed -n "s/,log$// p" -} importas -ns -d "\n" x x +} +importas -ns -d "\n" x x -pipeline { tail -f ${x}/current } s6-tai64nlocal +pipeline { tail -f ${x}/current } +s6-tai64nlocal diff --git a/bin/service-reload b/bin/service-reload @@ -1,4 +1,6 @@ #!/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-status b/bin/service-status @@ -1,14 +1,26 @@ #!/usr/bin/env execlineb elgetpositionals -P 1 +fdmove -c 2 1 forbacktickx x { - pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } - sed -n "s/,x$// p" -} importas -n -d "\n" s x + pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } + sed -n "s/,x$// p" +} +importas -n -d "\n" sv x + +if { printf "\n \033[1m%s\033[m\n " ${sv} } +if { s6-svstat /run/s6/${sv},x } + +if { printf "\n" } + +if { + backtick -n x { s6-svstat -o pid /run/s6/${sv},x } + importas x x + ptree ${x} +} -if { printf " " } -if { s6-svstat /run/s6/${s},x } if { printf "\n" } -if { backtick -n x { s6-svstat -o pid /run/s6/${s},x } importas x x ptree $x } + +if { pipeline { tail /var/log/${sv}/current } s6-tai64nlocal } + if { printf "\n" } -pipeline { tail /var/log/${s}/current } s6-tai64nlocal diff --git a/pack/bird/dependencies/oyacc b/pack/bird/dependencies/oyacc @@ -0,0 +1 @@ +../../oyacc/version+ \ No newline at end of file diff --git a/pack/bird/dependencies/yacc b/pack/bird/dependencies/yacc @@ -1 +0,0 @@ -../../yacc/version- \ No newline at end of file diff --git a/pack/libcurses/build b/pack/libcurses/build @@ -1,5 +1,7 @@ #!/bin/sh -ex +export CFLAGS="-D_BSD_SOURCE" + for f in \ libcurses/get_wstr.c \ libcurses/getstr.c \ @@ -26,8 +28,8 @@ do -e '^__[a-z]*_alias' \ -e 'warning: this program uses .*, which is unsafe.' \ -e '__warn_references' \ - "$f" >$f.grep - mv "$f.grep" "$f" + "$f" >$$ + mv "$$" "$f" done sed -r 's,^static (int fpurge),\1,' libcurses/tty.c >libcurses/tty.c.sed diff --git a/s6/httpfile/tcp/run b/s6/httpfile/tcp/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 USER USER } s6-envuidgid $USER -s6-tcpserver -vD -b50 -c100 $HOST $PORT +s6-tcpserver -vD -b50 -c100 $BIND $PORT httpfile-httpd diff --git a/s6/httpfile/tls/run b/s6/httpfile/tls/run @@ -1,13 +1,13 @@ #!/usr/bin/env execlineb fdmove -c 2 1 s6-envdir env multisubstitute { importas ACCESSFILE ACCESSFILE - importas HOST HOST + importas BIND BIND importas PORT PORT importas USER USER } s6-envuidgid $USER unexport ACCESSFILE -s6-tlsserver -vD -b50 -c100 $HOST $PORT +s6-tlsserver -vD -b50 -c100 $BIND $PORT export ACCESSFILE $ACCESSFILE httpfile-httpd diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias/himalaya-solaire.org b/s6/tinydns/himalaya-solaire.org/conf/alias/himalaya-solaire.org @@ -0,0 +1 @@ +../host/glaphyrae.himalaya-solaire.org+ \ No newline at end of file diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias/www.himalaya-solaire.org b/s6/tinydns/himalaya-solaire.org/conf/alias/www.himalaya-solaire.org @@ -0,0 +1 @@ +../host/glaphyrae.himalaya-solaire.org+ \ No newline at end of file diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias6/git.josuah.net b/s6/tinydns/himalaya-solaire.org/conf/alias6/git.josuah.net @@ -0,0 +1 @@ +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias6/irc.josuah.net b/s6/tinydns/himalaya-solaire.org/conf/alias6/irc.josuah.net @@ -0,0 +1 @@ +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias6/josuah.net b/s6/tinydns/himalaya-solaire.org/conf/alias6/josuah.net @@ -0,0 +1 @@ +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias6/mail.josuah.net b/s6/tinydns/himalaya-solaire.org/conf/alias6/mail.josuah.net @@ -0,0 +1 @@ +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/himalaya-solaire.org/conf/alias6/www.josuah.net b/s6/tinydns/himalaya-solaire.org/conf/alias6/www.josuah.net @@ -0,0 +1 @@ +2001:19f0:5001:7ac:5400:01ff:fe90:7c33 diff --git a/s6/tinydns/himalaya-solaire.org/conf/mx/himalaya-solaire.org b/s6/tinydns/himalaya-solaire.org/conf/mx/himalaya-solaire.org @@ -0,0 +1,2 @@ +10 spool.mail.gandi.net +50 fb.mail.gandi.net. diff --git a/s6/tinydns/himalaya-solaire.org/conf/ns/josuah.net b/s6/tinydns/himalaya-solaire.org/conf/ns/josuah.net @@ -0,0 +1 @@ +199.247.28.162 diff --git a/s6/tinydns/himalaya-solaire.org/conf/txt/himalaya-solaire.org b/s6/tinydns/himalaya-solaire.org/conf/txt/himalaya-solaire.org @@ -0,0 +1 @@ +"v=spf1 include:_mailcust.gandi.net ?all" diff --git a/s6/tinydns/x/setup b/s6/tinydns/x/setup @@ -5,6 +5,7 @@ if { forbacktickx x { ls conf } importas -n type x forbacktickx x { ls conf/${type} } importas -n name x forbacktickx x { cat conf/${type}/${name} } importas -n ip x + if { echo tinydns-edit data/data data/data.new add $type $name $ip } tinydns-edit data/data data/data.new add $type $name $ip }