File: postinst

package info (click to toggle)
dhcpcd 0.70-3
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 276 kB
  • ctags: 270
  • sloc: ansic: 2,300; sh: 391; makefile: 93
file content (79 lines) | stat: -rw-r--r-- 2,394 bytes parent folder | download | duplicates (2)
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
#!/bin/sh -e

if [ ! -f /etc/dhcpc/resolv.conf.original ]; then
	# Make the resolver information settable by DHCPC
	cp /etc/resolv.conf /etc/dhcpc/resolv.conf
	mv /etc/resolv.conf /etc/dhcpc/resolv.conf.original
	ln -s /etc/dhcpc/resolv.conf /etc
fi

if [ ! -f /etc/dhcpc/ntp.conf.original ]; then
	# Make the NTP configuration settable by DHCPC
	if [ -e /etc/ntp.conf ]; then
		cp /etc/ntp.conf /etc/dhcpc
		mv /etc/ntp.conf /etc/dhcpc/ntp.conf.original
		ln -s /etc/dhcpc/ntp.conf /etc
	fi
fi

# Has the daemon already been configured in a previous install?
if [ "$1" == 'configure' -a ! -f "/etc/dhcpc/config" ] ; then
	# Prompt the user to decide which interface dhcpcd will use.
	IFACE_LIST=`ifconfig |cut -f 1 -d " " | grep eth`

	# Decide on a default device. We prefer eth0, but if it's not available,
	# we will take the first one in the list as the default.
	if echo $IFACE_LIST |grep -q eth0 ; then
		DEFAULT=eth0
	else
		DEFAULT=`echo $IFACE_LIST |cut -f -1 -d " "`
	fi

	echo "Dhcpcd configuration"
	echo "--------------------"
	echo "Dhcpcd needs to be told which network interface to use. Once dhcpcd is"
	echo "installed, the IP address of this interface will be determined by"
	echo "querying a DHCP server."
	echo ""
	echo "** Warning: If a DHCP server is not available on the network, or is not"
	echo "** properly configured, dhcpcd will mess up the current network config"
	echo "** on the network interface you select."
	echo ""
	echo "Please choose the interface you wish to be configured by dhcpcd, and"
	echo "enter it below. If you do not want dhcpcd to be automatically enabled,"
	echo "enter \"none\"."
	echo "The following interfaces are avaliable on this system:"
	echo ""
	echo "$IFACE_LIST"
	
	echo ""
	echo -n "Select interface [$DEFAULT]":
	read IFACE
	echo ""
	
	if [ "$IFACE" = "" ]; then
		IFACE=$DEFAULT;
	fi
	
	if [ "$IFACE" != "none" ] ; then
		echo "Dhcpcd is configured to use: $IFACE"
	fi

	cat <<EOF >/etc/dhcpc/config
# List here the interface that the dhcpcd daemon should use.
# The default is to assign an IP address to eth0.
# If you want to disable the daemon, enter "none" here.
IFACE=$IFACE
EOF

	echo "You can change the interface dhcpcd uses at any time by editing"
	echo "/etc/dhcpc/config and restarting the daemon."
fi

update-rc.d dhcpc defaults 13 >/dev/null

if [ -x /etc/init.d/dhcpc ]; then
	/etc/init.d/dhcpc start
fi

#DEBHELPER#