[2019-10-24 14:34] Lorenzo Puliti <lorenzo.r...@gmail.com> > Package: runit > Version: 2.1.2-35 > Severity: normal > > As discussed in #934231 > > [Dmitry Bogatov] > >> create mode 100644 debian/anacron.runscript/finish > > > There is nothing in this script specific to anacron. I propose > > following: > > [....] > > I'm testing the following > -------------------------------- > $cat /lib/runit/finish-default > #!/bin/sh > > # no need to sv d service here, runsv will stop trying after the first > attempt to start > [ $1 = -1 ] && echo "runsv: ERROR $1 in $NAME: unexpected error or wrong sh > syntax" > > [ $1 = 161 ] && echo "runsv: ERROR $1 in $NAME: disabled by local settings" \ > && sv d $NAME && exit 0 > > [ $1 = 162 ] && echo "runsv: ERROR $1 in $NAME: configtest or early setup > failed" \ > && sv d $NAME && exit 0 > > [ $1 = 170 ] && echo "runsv: ERROR $1 in $NAME: a runtime hard dependecy is > missing" \ > && sv d $NAME && exit 0 > > exit 0
There is no need in last "exit 0", and please use more verbose and easier to understand "if-then style". Style "foo && bar && zz" interacts unexpectedly with "set -e". You can use "! foo || bar", but we are not after code golf here. > [...] > > As you can see, there is still some non-service specific code, but I don't > know > how to export the NAME inside the sourced script, is it feasible in > dash/POSIX? > Also some daemon may need specific code between Maybe we can change intended usage of "finish-default" to source-only, so /etc/runsv/<foo>/finish would contain something like #!/bin/sh . /lib/runit/finish-default "$@" This way /lib/runit/finish-default will have access to $0, and definition of NAME could be moved into internals of /lib/runit/finish-default. Also, you can use 'trap "do_stuff" EXIT' to get messages printed on the end of script. Use of "trap EXIT" must be documented, though, as there can be only one trap. To convey such intention, it is possible to give /lib/runit/finish-default following shebang: #!/bin/echo this script must be sourced, not executed. -- Note, that I send and fetch email in batch, once in a few days. Please, mention in body of your reply when you add or remove recepients.