aboutsummaryrefslogtreecommitdiffstats
path: root/sdk/bin/instinit
blob: fdd089978c0cc143eafdc7740244ffe4fdca393b (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
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
run=/etc/rc.d
levels=""
base=$1

if [ ! -d $run ] ; then
	exit 0
fi

if [ -d $run/init.d ] ; then
	levels=$run
	init='../init.d/'$1'.init'
	run=$run/init.d
	target=$1'.init'
else
	target='rc.'$1
	levels='false'
fi

source=$1'.init'
shift

if [ ! -f "$run/$target" ] ; then
	echo 'Adding '$target' to '$run
	if [ -f /etc/sudo.conf ] ; then
		sudo  root install -o root -m 0700 $source $run/$target
	else
		su root -c "install -o root -m 0700 $source $run/$target"
	fi
else
	exit 0
fi

if [ -z "$BASH" ] ; then
	exit 0
fi

if [ -z "$levels" ] ; then
	exit 0
fi

initial=$1
shift

for level in $* ; do
	runlvl=$levels'/rc'$level'.d'
	if [ ! -d $runlvl ] ; then
		continue
	fi
	cd $runlvl
	count=$initial
	while [ -f *$count* ] ; do
		count=$[count + 1]
	done
	target='S'$count$base
	echo 'Adding '$target' to '$runlvl
	ln -s $init $target
done