summaryrefslogtreecommitdiff
path: root/extra/openrc/openrc.post-install
blob: 1c273502c1d1a257f4c135649461e9dfb3cc84e9 (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
#!/bin/sh

rc_update() {
	local svc="$1"
	local level="$2"
	mkdir -p /etc/runlevels/$level
	ln -sf /etc/init.d/$svc /etc/runlevels/$level
}

if [ ! -d etc/rcS.d ] && [ ! -d etc/rcL.d ]; then
	exit 0
fi

for i in etc/rc[SL].d/*; do
	[ -L "$i" ] || continue
	oldsvc=${i##*/S[0-9][0-9]}
	# some services are renamed
	case "$oldsvc" in
		modutils)	svc=modules;;
		procps)		svc=sysctl;;
		bootmisc.sh) 	svc=bootmisc;;
		keymap)		svc=keymaps;;
		rc.local)	svc=local;;
		*)		svc=$oldsvc;;
	esac
	
	# add the service to correct "runlevel"
	case "$svc" in
		syslog|klogd)
			rc_update $svc sysinit;;
		hwclock|modules|sysctl|hostname|keymaps|bootmisc)
			rc_update $svc boot;;
		*)	rc_update $svc default;;
	esac

	rm $i
done