From: Paul Sopka <psopka@sopka.ch>
To: "supervision@list.skarnet.org" <supervision@list.skarnet.org>
Subject: Scripting Stage 3 and 4
Date: Thu, 9 Jan 2025 21:25:45 +0100 [thread overview]
Message-ID: <1dcb4b00-db5d-49bd-8598-fd6b2e5febdd@sopka.ch> (raw)
[-- Attachment #1.1.1: Type: text/plain, Size: 2451 bytes --]
Hey everybody,
I scripted shutdown stage 3 and 4 based on s6-linux-init-shutdownd and
it works quite well,
even though being VERY rough around the edges currently:
(Linux-powertool is a minimal program that just makes the syscall to
halt, poweroff or reboot)
| #!/bin/execlineb -P
|
| multisubstitute {
| importas -SD /etc/s6-rc G6CONFIGDIR
| importas -SD /run G6LIVEDIR
| }
|
| fdmove -c 2 1
| redirfd -w 1 /dev/console
| redirfd -r 0 /dev/null
|
| tryexec { ./stage3b }
|
| foreground { rm -f fifo }
| foreground { mkfifo -m 0700 fifo }
| foreground { fdmove 1 3 echo "" }
| redirfd -r 0 fifo
| withstdinas -E DIRECTIVE
|
| if { eltest \\\\${DIRECTIVE} =~ ^-[hpr]$ }
|
| foreground { s6-rc -l ${G6LIVEDIR}/s6-rc -v2 -bDa -t 10000 change }
| foreground {
| pipeline { ls -1 ${G6LIVEDIR}/service/ }
| pipeline { sed /g6-shutdown/d }
| forstdin -pE SERVICE
| mv -f ${G6LIVEDIR}/service/${SERVICE}
${G6LIVEDIR}/service/.${SERVICE}
| }
| foreground { s6-svscanctl -h ${G6LIVEDIR}/service }
|
| foreground {
| redirfd -w 1 stage3b
| echo "#!/bin/execlineb
| tryexec { ./stage4 }
| foreground { mv stage4p stage4 }
| foreground { kill -SIGCONT -- -1 }
| foreground { sleep 1 }
| foreground { echo sending all processes the KILL signal... }
| foreground { kill -SIGKILL -- -1 }"
| }
| foreground { chmod o+x stage3b }
|
| foreground {
| redirfd -w 1 stage4p
| echo "#!/bin/execlineb
| foreground { mount -o remount,ro / }
| foreground { umount -a }
| linux-powertool ${DIRECTIVE}"
| }
| foreground { chmod o+x stage4p }
|
| foreground { echo "sending all processes the TERM signal..." }
| foreground { kill -SIGTERM -- -1 }
Now I was wondering why you, Laurent recommend against using the finish
script of s6-svscan
for the shutdown procedure (here:
https://skarnet.org/software/s6/s6-svscan-1.html#stage3).
Using that would make good portion of my implementation more elegant and
simple,
especially all the dance around creating scripts to be ran by "tryexec"
after being restarted upon being signaled to stop...
I figured that other people might also have some interest in this,
so I am posting the question here.
Regards,
Paul
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3195 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
next reply other threads:[~2025-01-09 20:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-09 20:25 Paul Sopka [this message]
2025-01-09 23:19 ` Laurent Bercot
2025-01-11 8:30 ` Paul Sopka
2025-01-11 12:21 ` Re[2]: " Laurent Bercot
2025-01-11 15:15 ` Paul Sopka
2025-01-11 13:22 ` Guillermo
2025-01-11 15:29 ` Paul Sopka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1dcb4b00-db5d-49bd-8598-fd6b2e5febdd@sopka.ch \
--to=psopka@sopka.ch \
--cc=supervision@list.skarnet.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).