Debian Codegraph @

debian/isc-dhcp-server.postinst

raw
1 #!/bin/sh
2 #
3 # Inspiration stolen from the fetchmail* packages. Thanks Henrique!
4 #
5 #
6
7 set -e
8
9 case "$1" in
10 configure)
11 # continue below
12 ;;
13
14 abort-upgrade|abort-remove|abort-deconfigure)
15 exit 0
16 ;;
17
18 *)
19 echo "postinst called with unknown argument \`$1'" >&2
20 exit 0
21 ;;
22 esac
23
24 # Handle debconf
25 . /usr/share/debconf/confmodule
26
27 INITCONFFILE="/etc/default/isc-dhcp-server"
28
29 # We generate several files during the postinst, and we don't want
30 # them to be readable only by root.
31 umask 022
32
33 # Generate configuration file if it does not exist, using default values.
34 [ -r "${INITCONFFILE}" ] || {
35 echo Generating ${INITCONFFILE}... >&2
36 cat >${INITCONFFILE} <<'EOFMAGICNUMBER1234'
37 # Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)
38
39 # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
40 #DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
41 #DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
42
43 # Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
44 #DHCPDv4_PID=/var/run/dhcpd.pid
45 #DHCPDv6_PID=/var/run/dhcpd6.pid
46
47 # Additional options to start dhcpd with.
48 # Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
49 #OPTIONS=""
50
51 # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
52 # Separate multiple interfaces with spaces, e.g. "eth0 eth1".
53 INTERFACESv4=""
54 INTERFACESv6=""
55 EOFMAGICNUMBER1234
56 }
57
58 # ------------------------- Debconf questions start ---------------------
59
60 db_get isc-dhcp-server/interfaces || true
61 INTERFACESv4="${RET}"
62
63 if [ -n "$INTERFACESv4" ]; then
64 TMPFILE="$(mktemp -q ${INITCONFFILE}.new.XXXXXX)"
65 sed -e "s,^[[:space:]]*INTERFACESv4[[:space:]]*=.*,INTERFACESv4=\"${INTERFACESv4}\"," \
66 <${INITCONFFILE} >${TMPFILE}
67 cp ${TMPFILE} ${INITCONFFILE}
68 rm ${TMPFILE}
69 fi
70
71 # ------------------------- Debconf questions end ---------------------
72 db_stop
73
74 test ! -x /sbin/restorecon || restorecon /var/lib/dhcp/dhcpd.leases
75
76 #DEBHELPER#
77
78 exit 0