#!/bin/sh -e

##  s6-linux-init-shutdownd never tells s6-svscan to exit, so if
##  you're running s6-linux-init, it's normal that your
##  .s6-svscan/finish script is not executed.

##  The place where you want to hack things is /etc/rc.shutdown.final,
##  which is run by the stage 4 script right before the hard reboot.
##  So you can do dirty stuff [...] which should clean up the
##  s6-supervise and the foreground, and give control to
##  .s6-svscan/finish.

## -- Laurent Bercot on skaware mailing list,
##    https://skarnet.org/lists/skaware/1913.html

exec >/dev/console 2>&1

# down, exit supervisor, wait, stay down
s6-svc -dxwD /run/service/s6-linux-init-shutdownd
# HUP, exit supervisor, wait, down
s6-svc -hxwd /run/service/s6-svscan-log
s6-svscanctl -b /run/service # abort