summaryrefslogtreecommitdiff
path: root/bin/init
blob: 436e55a8b44108dbe245dc984de5579322df9bd9 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/execlineb -P
importas -i XDG_RUNTIME_DIR XDG_RUNTIME_DIR
importas -i HOME HOME

foreground { redirfd -w 2 /dev/null
	foreground { find ${XDG_RUNTIME_DIR} -maxdepth 1 ! -path ${XDG_RUNTIME_DIR} -exec rm -rf "{}" + }
	foreground { mkdir -p
		${HOME}/.local/state/s6/uncaught-logs
		${XDG_RUNTIME_DIR}/service/.s6-svscan
		${XDG_RUNTIME_DIR}/service/s6-svscan-log
	}
	ln -sf /bin/false ${XDG_RUNTIME_DIR}/service/.s6-svscan/crash
}
execline-cd ${XDG_RUNTIME_DIR}/service
if {
  redirfd -w 1 .s6-svscan/finish
  heredoc 0 "#!/bin/execlineb -P\ns6-svc -x -- \"${XDG_RUNTIME_DIR}/service/s6-svscan-log\"\n"
  cat
}
if { chmod 0755 .s6-svscan/finish }
foreground { redirfd -w 2 /dev/null mkfifo -m 0600 s6-svscan-log/fifo }
if { redirfd -w 1 s6-svscan-log/notification-fd echo 3 }
if {
  redirfd -w 1 s6-svscan-log/run
  heredoc 0 "#!/bin/execlineb -P
redirfd -rnb 0 fifo
exec -c
s6-log -bpd3 -- t ${HOME}/.local/state/s6/uncaught-logs\n"
  cat
}
if { chmod 0755 s6-svscan-log/run }

redirfd -r 0 /dev/null
redirfd -wnb 1 s6-svscan-log/fifo
fdmove -c 2 1

fdreserve 2
multisubstitute { importas -u fdr FD0 importas -u fdw FD1 }
piperw ${fdr} ${fdw}
background {
	fdclose ${fdw}
	foreground { fdmove 0 ${fdr} redirfd -w 1 /dev/null cat }
	s6-svlisten -U { ./s6-svscan-log }
	if { s6-rc-init -bl ${XDG_RUNTIME_DIR}/s6-rc
		-c ${HOME}/.local/share/s6-rc/compiled
		${XDG_RUNTIME_DIR}/service }
	s6-rc -l ${XDG_RUNTIME_DIR}/s6-rc -bu change default
}
fdclose ${fdr}
emptyenv -c
s6-svscan -d ${fdw} -- ${XDG_RUNTIME_DIR}/service