dot

packages and services management
Log | Files | Refs | README

commit abcdbc70d42d25539417c07ca364af146c47e1e4
parent f3888cc6efbc23d5b921448e3d489508463ac5b7
Author: Josuah Demangeon <mail@josuah.net>
Date:   Mon, 20 Aug 2018 08:55:33 +0200

s6: service needs to be started if in down state

Diffstat:
Minit | 42++++++++++++++++++++++--------------------
As6/s6-svscan-run/SIGHUP | 4++++
As6/s6-svscan-run/SIGINT | 4++++
As6/s6-svscan-run/SIGQUIT | 4++++
As6/s6-svscan-run/SIGTERM | 4++++
As6/s6-svscan-run/SIGUSR1 | 4++++
As6/s6-svscan-run/SIGUSR2 | 4++++
As6/s6-svscan-run/crash | 7+++++++
As6/s6-svscan-run/finish | 20++++++++++++++++++++
9 files changed, 73 insertions(+), 20 deletions(-)

diff --git a/init b/init @@ -1,27 +1,29 @@ #!/usr/bin/env execlineb -# setup -if { s6-rmrf /run/s6 } -if { s6-mkdir -p /var/s6 /run/s6 } -if { s6-hiercopy /etc/s6/s6-svscan-log /var/s6/s6-svscan-log } -if { s6-ln -nsf /var/s6/s6-svscan-log /run/s6/s6-svscan-log } +if { s6-rmrf /run/s6 /var/s6/init } +if { s6-mkdir -p /run/s6 /var/s6/init /log/ } +if { s6-hiercopy /etc/s6/s6-svscan-log /var/s6/init/s6-svscan-log } +if { s6-hiercopy /etc/s6/s6-svscan-run /var/s6/init/.s6-svscan } +if { s6-ln -sf /var/s6/init/s6-svscan-log /var/s6/init/.s6-svscan /run/s6 } -# s6-svscan background { - redirfd -r 0 /dev/null - redirfd -wnb 1 /run/s6/s6-svscan-log/fifo - fdmove -c 2 1 - s6-svscan -t0 /run/s6 -} + # wait until s6-svscan starts + redirfd -w 1 /var/s6/s6-svscan-log/fifo + + s6-setsid -- + fdmove -c 1 2 -# wait until s6-svscan starts -redirfd -w 3 /run/s6/s6-svscan-log/fifo -fdclose 3 + backtick -n t { s6-clock } + importas t t + if { s6-rc-compile /var/s6/compiled${t} /var/s6/source } + if { s6-rc-init -c /var/s6/compiled${t} -l /var/s6/live /run/s6 } + if { s6-ln -nsf /var/s6/compiled${t} /var/s6/compiled } + if { elglob s6-rmrf /run/s6/*/down } +} -backtick -n t { s6-clock } -importas t t -if { s6-mkdir -p /var/s6 /run/s6 /log/ } -if { s6-rc-compile /var/s6/compiled${t} /var/s6/source } -if { s6-rc-init -c /var/s6/compiled${t} -l /var/s6/live /run/s6 } -if { s6-ln -nsf /var/s6/compiled${t} /var/s6/compiled } +cd /var/s6 +redirfd -r 0 /dev/null +redirfd -wnb 1 /var/s6/s6-svscan-log/fifo +fdmove -c 2 1 +s6-svscan -t0 /run/s6 diff --git a/s6/s6-svscan-run/SIGHUP b/s6/s6-svscan-run/SIGHUP @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -h -- "/run"/service diff --git a/s6/s6-svscan-run/SIGINT b/s6/s6-svscan-run/SIGINT @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -6 -- "/run"/service diff --git a/s6/s6-svscan-run/SIGQUIT b/s6/s6-svscan-run/SIGQUIT @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -q -- "/run"/service diff --git a/s6/s6-svscan-run/SIGTERM b/s6/s6-svscan-run/SIGTERM @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -t -- "/run"/service diff --git a/s6/s6-svscan-run/SIGUSR1 b/s6/s6-svscan-run/SIGUSR1 @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -7 -- "/run"/service diff --git a/s6/s6-svscan-run/SIGUSR2 b/s6/s6-svscan-run/SIGUSR2 @@ -0,0 +1,4 @@ +#!/bin/execlineb -P + +foreground { "/etc/rc.shutdown" } +s6-svscanctl -0 -- "/run"/service diff --git a/s6/s6-svscan-run/crash b/s6/s6-svscan-run/crash @@ -0,0 +1,7 @@ +#!/bin/execlineb -P + +redirfd -r 0 /dev/console +redirfd -w 1 /dev/console +fdmove -c 2 1 +foreground { s6-echo -- "s6-svscan crashed. Dropping to an interactive shell." } +/bin/sh -i diff --git a/s6/s6-svscan-run/finish b/s6/s6-svscan-run/finish @@ -0,0 +1,20 @@ +#!/bin/execlineb -S0 + +cd / +redirfd -w 2 /dev/console +fdmove -c 1 2 +foreground { s6-svc -X -- "/run"/service/s6-svscan-log } +unexport ? +wait -r -- { } +foreground { s6-echo "Syncing disks." } +foreground { s6-sync } +foreground { s6-echo "Sending all processes the TERM signal." } +foreground { s6-nuke -th } +s6-sleep -m -- 2000 +foreground { s6-echo "Sending all processes the KILL signal." } +foreground { s6-nuke -k } +wait { } +foreground { s6-echo "Unmounting disks." } +foreground { s6-umount -a } +foreground { s6-mount -ro remount /dev/root / } +s6-${1} -f