aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/prepare-svscan
blob: 9fe7f8d7cb269101d5ac485401a7386e5549070f (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
32
33
34
35
36
37
#!@shebangdir@/execlineb -Ws4

# ISC license.

multisubstitute {
	 define WORKINGDIR ${1}
	 define RUNDIR ${2}
	 define BUNDLE ${3}
	 define PROG ${4}
}

redirfd -r 0 /dev/null
execline-umask 0022

if { mkdir -p -m750 -- ${RUNDIR} }
foreground { cp -RfpL -- ${WORKINGDIR}/run-image/. ${RUNDIR}/ }

if { mkfifo -m700 ${RUNDIR}/service/s6-svscan-log/fifo }
redirfd -wnb 1 ${RUNDIR}/service/s6-svscan-log/fifo

background {
	redirfd -w 2 ${RUNDIR}/service/s6-svscan-log/fifo
	if -x0 -n { eltest -d ${RUNDIR}/s6-rc }
		foreground { echo "\ninit!\n" }
		if {
			s6-rc-init
				-c ${WORKINGDIR}/compiled
			   	-l ${RUNDIR}/s6-rc
			   	${RUNDIR}/service
		}
		foreground { echo "\nStarting bundle ${BUNDLE}...\n" }
		s6-rc -l ${RUNDIR}/s6-rc -v2 -b -t@timeout@ -up change ${BUNDLE}
}
fdmove -c 2 1

s6-envdir -I ${WORKINGDIR}/env
${PROG} ${@}