about summary refs log tree commit diff
path: root/xmksv
blob: 8c0a5d6ee8e270c4bb4d3fdb5a6af793019e86b1 (plain) (blame)
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
#!/bin/sh -e
# xmksv [-l] [NEWSVDIR...] - create new runit service templates

if [ "$1" = "-l" ]; then
	MKLOG=1
	shift
fi

cd ${SVDIR:-/etc/sv}

for SRV; do
	mkdir "$SRV"
	touch "$SRV/down"
	echo "#!/bin/sh" | install -m755 /dev/stdin "$SRV/run"
	if [ -w /run/runit ]; then
		ln -s /run/runit/supervise."$(printf %s "$SRV" | tr / -)" \
			"$SRV/supervise"
	fi
	if [ -n "$MKLOG" ]; then
		mkdir "$SRV/log"
		cat <<EOF | install -m755 /dev/stdin "$SRV/log/run"
#!/bin/sh
exec vlogger -t $SRV -f daemon
EOF
		if [ -w /run/runit ]; then
			ln -s /run/runit/supervise."$(printf %s "$SRV/log" | tr / -)" \
				"$SRV/log/supervise"
		fi
	fi
done