File: update-rc.d

package info (click to toggle)
multistrap 2.1.7
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 676 kB
  • ctags: 55
  • sloc: perl: 1,027; sh: 189; makefile: 128; ansic: 5
file content (69 lines) | stat: -rwxr-xr-x 1,330 bytes parent folder | download | duplicates (5)
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
62
63
64
65
66
67
68
69
#!/bin/sh
#
# Copyright 2008 Hands.com Ltd <phil@hands.com>
# Copyright 2008 Neil Williams <codehelp@debian.org>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 3 of the License, or
#  (at your option) any later version.

initd="/etc/init.d"
etcd="/etc/rc.d"
bn=$1;shift
if [ "$bn" = '-f' ]; then
	bn=$1
	shift
fi

defaults () {
	makelinks "S${1:-20}"
	makelinks "K${2:-${1:-20}}"
}

makelinks () {
	echo " Adding symlink for $initd/$bn ...";
	echo "${etcd}/${1}${bn} -> ../init.d/$bn"
	ln -s "../init.d/$bn" "${etcd}/${1}${bn}"
}

if [ -z "$bn" -o -z "$1" ]; then
	echo "Insufficient arguments"
	exit 1
fi
if [ ! -f "$initd/$bn" ]; then
	echo "update-rc.d: $initd/$bn: file does not exist"
	echo
	exit 1
fi
if [ "$1" = 'remove' ]; then
	shift
	echo "rm -f /etc/rc.d/*${bn}"
	rm -f "/etc/rc.d/*${bn}"
	exit;
elif [ "$1" = 'defaults' ]; then
	makelinks "S${2:-20}"
	makelinks "K${3:-${2:-20}}"
	exit 0;
else
	if [ "$1" = 'start' ]
	then
		shift
		num=$1
		# use two digit prefixes
		if [ $num -lt 10 ]; then
			num="0${num}"
		fi
		makelinks "S${num}"
		while [ "$1" != "." ]
		do
			shift
		done
		shift
		if [ "$1" = 'stop' ]; then
			shift
			makelinks "K${1}"
		fi
	fi
	exit 0;
fi