oneshot initscripts (was Re: Help wanted to finalise wtmpdb init integration)

Andrew Bower andrew at bower.uk
Sun Jun 22 18:57:25 BST 2025


Hi Mark,

On Wed, Mar 05, 2025 at 05:36:14PM +0100, Lorenzo wrote:
> On Wed, 5 Mar 2025 12:36:22 +0000
> Mark Hindley <mark at hindley.org.uk> wrote:
> 
> > Something along these lines works for me:
> > 
> > do_start_prepare() {
> >   [ -f /run/$NAME.oneshot ] && exit
> > }
> > 
> > do_start_cleanup() {
> >   touch /run/$NAME.oneshot
> > }
> > 
> > do_stop_prepare() {
> >   [ -f /run/$NAME.oneshot ] || exit
> > }
> >
> > do_stop_cleanup() {
> >   rm -fv /run/$NAME.oneshot
> > }
[...]
> > If the approach is OK, I think the contents of the *_prepare() and
> > *_cleanup() functions could ultimately be added to init-d-script(5)
> > and triggered by a TYPE=oneshot or ONESHOT=yes flag or similar.
> 
> I think standardize this in init-d-script would be a good idea, using
> flag files or something else (if someone has a better idea).

Although I didn't go with this approach in the end because the
long-standing method for single-shot services at startup and shutdown of
detecting runlevel transitions was a perfect match, I have just been
working on the 'acct' initscript, which I would like to convert into
init-d-script form, and I can see that there is a more general set of
use cases for the one-shot flag file that would apply to services in the
multi-user runlevels. In this case, init-d-script integration would be
great for keeping such initscripts slim, so I add myself to Lorenzo's
vote of support!

Andrew



More information about the Debian-init-diversity mailing list