File: postinst

package info (click to toggle)
netenv 0.82-8
  • links: PTS
  • area: main
  • in suites: slink
  • size: 156 kB
  • ctags: 40
  • sloc: sh: 336; ansic: 136; makefile: 52
file content (101 lines) | stat: -rw-r--r-- 2,335 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
if [ "$1" != "configure" ]
then
    exit 0
fi

update-rc.d netenv start 40 S . > /dev/null

NODE=`uname -n`
CONFS=`ls -1 /etc/netenv/${NODE}-*|wc|awk '{print $1}'`
NETENV=/etc/init.d/netenv

config_actual()
{
IP=`ifconfig eth0 2>/dev/null|awk '/inet addr:/{print substr($2,6)}'`

if [ ! -z $IP ]; then
#
#	setting up actual environment
#
	BCAST=`ifconfig eth0 2>/dev/null|awk '/Bcast:/{print substr($3,7)}'`
	MASK=`ifconfig eth0 2>/dev/null|awk '/Mask:/{print substr($4,6)}'`
	NETWORK=`echo $BCAST|sed -e 's/255/0/'`
	GATEWAY=`route 2>/dev/null|awk '/0.0.0.0/{print $2}'`
	if [ ! -z $GATEWAY ]; then
		GW="export GATEWAY="
	else
		GW=
	fi
	cat > /etc/netenv/`uname -n`-default << EOF
netenv_id=Installation_default
export IPADDR=$IP
export NETWORK=$NETWORK
export NETMASK=$MASK
export BROADCAST=$BCAST
$GW$GATEWAY
export PROFILE=default
EOF

chmod 755 $NETENV
fi

}

if [ $CONFS -gt 0 ]; then
	cat << EOF
It appears that you already have configured netenv for machine ${NODE}.
EOF
	exit 0
fi

cat << EOF
You do not have netenv configured yet. An unconfigured netenv package will
ask to do type in a network configuration at boot time. Once you have
configured a network connection you can bypass the netenv prompt by adding a
parameter add the boot prompt. Unless you do that though the machine will
wait for input even if netenv is configured. So take care if you want to
reboot the machine remotely. Please refer to the documentation for details.

You can:

1) Let me try to configure your actual network connection as the default
   connection for netenv.
2) Configure one network connection now. Make sure you really save the
   configuration. Otherwise you have to enter the configuration again during
   the next boot.
3) Disable netenv usage at boot time.
EOF

while true
do
	echo "What would you like to do? (1/2/3) [1] "
	read input
	if [ $input = "1" ]
	then
		config_actual
		break
	elif [ $input = "2" ]
	then
		chmod 755 $NETENV
		export NETENV=new
		/sbin/netenv
		break
	elif [ $input = "3" ]
	then
		cat << EOF
Okay, disabling it. You can enable netenv by either running this postinst
again or by simply using:

chmod 755 /etc/init.d/netenv
EOF
		chmod 644 $NETENV
		break
	elif [ ! $input ]
	then
		config_actual
                break
	else
	    echo "Please answer \`1', \`2' or \`3'."
	fi 2>/dev/null
done