dot

packages and services management
Log | Files | Refs | README

commit 4e4283beb82b7790698fef9f39bd1dfa3fb2ea7b
parent 8e23ea91b36456a300892be5d41007d7652b0d25
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sat,  1 Dec 2018 17:15:34 +0100

pack/bin/{mail,service}-*: fix consistency errors

Diffstat:
Abin/mail-com | 15+++++++++++++++
Abin/mail-draft | 23+++++++++++++++++++++++
Abin/mail-filter | 28++++++++++++++++++++++++++++
Abin/mail-send | 27+++++++++++++++++++++++++++
Mbin/mail-write | 12+++---------
Mbin/service-build | 14+++++---------
Mbin/service-disable | 2+-
Mbin/service-enable | 5+++--
Mbin/service-log | 3++-
Mbin/service-status | 10++++++----
10 files changed, 113 insertions(+), 26 deletions(-)

diff --git a/bin/mail-com b/bin/mail-com @@ -0,0 +1,15 @@ +#!/usr/bin/env execlineb +elgetpositionals + +backtick -n USER { whoami } +importas USER USER +backtick -n HOME { homeof $USER } +importas HOME HOME +importas -D ${HOME}/.mblaze MBLAZE MBLAZE + +backtick -n From { mhdr -h local-mailbox ${MBLAZE}/profile } +backtick -n To { pipeline { dollarat -n -d "," } sed "s/, */, /g" } +backtick -n Message-Id { mgenmid } +backtick -n Date { mdate } + +mail-write ${@} diff --git a/bin/mail-draft b/bin/mail-draft @@ -0,0 +1,23 @@ +#!/usr/bin/env execlineb +elgetpositionals -P 1 + +importas -D vi -s EDITOR EDITOR + +backtick -n x { mseq ${1} } +importas -n draft x + +if { printf "Draft: %s\n" ${draft} } + +loopwhilex -o 101 + +if { printf " [e]dit, [s]end, [c]ancel, [d]elete, [gs] sign, [ge] encrypt " } +backtick -n x { sed q } +importas x x + +ifelse { test ${x} = e } { foreground { ${EDITOR} ${draft} } exit 101 } +ifelse { test ${x} = s } { mail-send ${draft} } +ifelse { test ${x} = c } { echo mail not sent, draft kept } +ifelse { test ${x} = d } { rm -i ${draft} } +ifelse { test ${x} = gs } { if { echo not implemented } exit 101 } +ifelse { test ${x} = ge } { if { echo not implemented } exit 101 } +exit 101 diff --git a/bin/mail-filter b/bin/mail-filter @@ -0,0 +1,28 @@ +#!/usr/bin/env execlineb +backtick -n x { whoami } importas USER x +backtick -n x { homeof $USER } importas HOME x +multisubstitute { + importas -D ${HOME}/.mblaze MBLAZE MBLAZE + importas -D INBOX INBOX 1 + importas -D ${HOME}/mail MAILDIR MAILDIR +} + +cd $MAILDIR + +fdmove -c 1 2 + +forbacktickx -n x { ls ${MBLAZE}/sort } importas target x +if { mmkdir -p -m 0700 ${target}/cur ${target}/new ${target}/tmp } +if { fdmove -c 1 2 printf "%-35s " $target } + +backtick -n x { + pipeline { cat ${MBLAZE}/sort/${target} } + tr "\n" " " +} importas rule x + +forbacktickx -n x { + pipeline { mlist $INBOX } + mpick -v -t $rule +} importas file x + +if { test ${file} != ${target}/new } mv $file ${target}/new diff --git a/bin/mail-send b/bin/mail-send @@ -0,0 +1,27 @@ +#!/usr/bin/env execlineb +elgetpositionals -P 1 + +backtick -n USER { whoami } +importas USER USER +backtick -n HOME { homeof $USER } +importas HOME HOME +importas -D ${HOME}/.mblaze MBLAZE MBLAZE + +backtick -n -D ${HOME}/mail/OUTBOX x { mhdr -h outbox ${MBLAZE}/profile } +importas outbox x +backtick -n -D "sendmail" x { mhdr -h sendmail ${MBLAZE}/profile } +importas sm x +backtick -n -D "-t" x { mhdr -h sendmail-args ${MBLAZE}/profile } +importas args x +define -s sendmail "${sm} ${args}" + +backtick -n x { mseq ${1} } +importas -n draft x + +if -t { if { redirfd -r 0 ${draft} mmime -c } + if { redirfd -r 0 ${draft} redirfd -w 1 ${draft}.mime mmime } + mv ${draft}.mime ${draft} +} + +if { redirfd -r 0 ${draft} ${sendmail} } +redirfd -r 0 ${draft} mdeliver -v ${outbox} diff --git a/bin/mail-write b/bin/mail-write @@ -2,22 +2,16 @@ backtick -n USER { whoami } importas USER USER - backtick -n HOME { homeof $USER } importas HOME HOME - importas -D ${HOME}/.mblaze MBLAZE MBLAZE -backtick -n x { mhdr -h outbox ${MBLAZE}/profile } -importas -D ${maildir}/OUTBOX outbox x +backtick -n -D ${HOME}/mail/OUTBOX x { mhdr -h outbox ${MBLAZE}/profile } +importas outbox x -backtick -n x { redirfd -r 0 /dev/null mdeliver -v -c -XD ${outbox} } +backtick -n x { redirfd -r 0 /dev/null mdeliver -v -XD ${outbox} } importas draft x -backtick -n To { pipeline { dollarat -n -d "," } sed "s/, */, /g" } -backtick -n Message-Id { mgenmid } -backtick -n Date { mdate } - multisubstitute { importas -n Bcc Bcc importas -n Cc Cc diff --git a/bin/service-build b/bin/service-build @@ -16,14 +16,11 @@ importas -n type x if { cd /etc/s6/${base} redirfd -w 1 /dev/null ls x ${mod} } -backtick -n x { if -t { test $type = longrun } echo ,x } -importas ext x - -if { rm -rf ${sv} ${sv},x } +if { rm -rf ${sv} ${sv},log } if { forx -o 0 x { x $mod } importas x x - s6-hiercopy /etc/s6/${base}/${x} ${sv}${ext} + s6-hiercopy /etc/s6/${base}/${x} ${sv} } if { if -t { test $type = bundle } @@ -37,11 +34,10 @@ 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 } - if { redirfd -w 1 ${sv},log/consumer-for echo ${sv},x } + if { redirfd -a 1 ${sv}/producer-for echo ${sv},log } + if { redirfd -w 1 ${sv},log/consumer-for echo ${sv} } if { redirfd -w 1 ${sv},log/env/SERVICE echo ${sv} } - if { redirfd -w 1 ${sv},log/pipeline-name echo ${sv} } } -cd ${sv}${ext} +cd ${sv} if -t { test -e setup } ./setup diff --git a/bin/service-disable b/bin/service-disable @@ -2,7 +2,7 @@ cd /var/s6 elgetpositionals -P 1 -if { rm -rf ${@} ${@},x ${@},log } +if { rm -rf ${@} ${@},log } backtick -n t { s6-clock } importas t t diff --git a/bin/service-enable b/bin/service-enable @@ -14,5 +14,6 @@ if { s6-rc-update -l /var/s6/.s6-rc/live /var/s6/.s6-rc/compiled${time} } 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 +if -n { test -d /var/s6/${base} } +elglob -0 x ${base},* +s6-rc-bundle -f -l .s6-rc/live add ${base} ${x} diff --git a/bin/service-log b/bin/service-log @@ -4,7 +4,8 @@ cd /var/log backtick x { pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } - sed -n "s/,log$// p" + pipeline { sed -n "s/,log$// p" } + uniq } importas -ns -d "\n" x x diff --git a/bin/service-status b/bin/service-status @@ -6,15 +6,17 @@ if { printf "\n" } fdmove -c 2 1 forbacktickx x { pipeline { s6-rc -l /var/s6/.s6-rc/live list $@ } - sed -n "s/,x$// p" + pipeline { sed "s/,log$//" } + sort -u } importas -n -d "\n" sv x -if { printf " \033[1m%s\033[m\n " ${sv} } -if { s6-svstat /run/s6/${sv},x } +if { heredoc 0 ${sv} sed -r "s/([^,]*),?(.*)/ \033[1m\\1\033[m (\\2)/" } +if { printf " " } +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 ptree ${x} }