summaryrefslogtreecommitdiffstats
path: root/src/bin/system-shutdown-daemon
blob: 9e6850e085873e4b6597cecf722da29f3b4331ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!@shebangdir@/execlineb -P

# ISC license.

tryexec { ./stage3b }

if -n {
	foreground { echo "\nshutdown\n" }
	foreground { s6-rc -l @tmpfsdir@/@sysrundir@/s6-rc -v2 -b -Da -t@timeout@ change }
	foreground {
		pipeline { ls -1 @tmpfsdir@/@sysrundir@/service/ }
		pipeline {
			sed
				-e /s6-svscan-log/d
				-e /.s6-svscan/d
				-e /goetia-shutdown/d
				-e /goetia-rescue/d
		}
		forstdin -pE SERVICE
			s6-svc -T @timeout@ -D @tmpfsdir@/@sysrundir@/service/${SERVICE}
	}

	foreground { rm -Rf -- @syslogdir@/uncaught-logs }
	foreground { cp -Rpf -- @tmpfsdir@/@sysrundir@/log/uncaught-logs @syslogdir@/ }

	foreground { chmod u+x ./stage3b }
	foreground { echo "sending all processes the TERM signal..." }
	foreground { kill -SIGTERM -- -1 }
}
foreground { touch ./down }
chmod a-x ./stage3b