File: dhcp3-server.postinst

package info (click to toggle)
dhcp3 3.0.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,456 kB
  • ctags: 5,176
  • sloc: ansic: 66,419; sh: 1,677; perl: 601; makefile: 137
file content (86 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/sh -e
#
# Inspiration stolen from the fetchmail* packages. Thanks Henrique!
#
# $Id: dhcp3-server.postinst,v 1.4 2003/12/18 21:29:05 mdz Exp $
#

#DEBHELPER#

case "$1" in
	configure)
		# continue below
		;;

	abort-upgrade|abort-remove|abort-deconfigure)
		exit 0
		;;

	*)
		echo "postinst called with unknown argument \`$1'" >&2
		exit 0
		;;
esac

# Handle debconf
. /usr/share/debconf/confmodule

INITCONFFILE=/etc/default/dhcp3-server

# We generate several files during the postinst, and we don't want
#	them to be readable only by root.
umask 022

# Generate configuration file if it does not exist, using default values.
[ -r "${INITCONFFILE}" ] || {
	echo Generating ${INITCONFFILE}... >&2
	cat >${INITCONFFILE} <<'EOFMAGICNUMBER1234'
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#	Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES=""
EOFMAGICNUMBER1234
}

# ------------------------- Debconf questions start ---------------------

db_get dhcp3-server/interfaces || true
INTERFACES="${RET}"

TMPFILE=`mktemp -q ${INITCONFFILE}.new.XXXXXX`
sed -e "s/^[[:space:]]*INTERFACES[[:space:]]*=.*/INTERFACES=\"${INTERFACES}\"/" \
	<${INITCONFFILE} >${TMPFILE}
cp ${TMPFILE} ${INITCONFFILE}
rm ${TMPFILE}

# ------------------------- Debconf questions end ---------------------

if [ ! -e /var/lib/dhcp3/dhcpd.leases ]; then
    if test -e /var/lib/dhcp/dhcpd.leases; then
        cp /var/lib/dhcp/dhcpd.leases /var/lib/dhcp3/dhcpd.leases
    else
	touch /var/lib/dhcp3/dhcpd.leases
    fi
fi

update-rc.d dhcp3-server defaults >/dev/null

# Init script could fail, since dhcp3 is unconfigured on a new install
if [ -x /usr/sbin/invoke-rc.d ]; then
	invoke-rc.d dhcp3-server start || true
else
        if [ -x /etc/init.d/dhcp3-server ]; then
                /etc/init.d/dhcp3-server start || true
        fi
fi

db_stop

exit 0