config is in netenv 0.94.3-30.
This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.
The actual contents of the file can be viewed below.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | #!/bin/sh
# (setq skeleton-pair t)
set -e
# first, source /usr/share/debconf/confmodule
. /usr/share/debconf/confmodule
# db_purge
# definition of internal functions:
# (to find the end of function defining, look for end)
grep_var () {
# grep vor a variable assignment to variable $1 in file $2.
# return the value that is assigned inside double quotes.
egrep ^[[:blank:]]*$1= $2 | sed -e 's/.*"\([^#]*\)".*/\1/' || true
# we are set -e, hence the || true
}
restore_false_links(){
FALSE_LINKS=false
# is resolv.conf a link to netenv_default, with an underscore instead of dash?
if [ X`readlink /etc/resolv.conf` = X/etc/resolv.conf.netenv_default ]; then
# is the target non-existent, that is: Is it stale as expected?
if [ ! -r `readlink /etc/resolv.conf` ]; then
# o.k., there is one stale link, let's look whether we can fix that:
FALSE_LINKS=true
# is the old file still there?
if [ -f /etc/resolv.conf.netenv-default ]; then
# yes, it is there, we remove the link
rm /etc/resolv.conf
# put the original file back in its place
mv /etc/resolv.conf.netenv-default /etc/resolv.conf
echo "Netenv: Restored old resolv.conf (Bug #225582)."
else
# the original file could not be found, we cannot resolve the situation.
echo "Problems cleaning up wrong links for resolv.conf (Bug #225582)."
echo "Correct installation, removal or purge of netenv might"
echo "require manual action."
fi
fi
fi
# now the same for interfaces - is it a link to a file with underscore?
if [ X`readlink /etc/network/interfaces` = X/etc/network/interfaces.netenv_default ]; then
# and is the link stale (target nonexistent)?
if [ ! -r `readlink /etc/network/interfaces` ]; then
# o.k., another one.
FALSE_LINKS=true
# can we fix it - is the old file still there?
if [ -f /etc/network/interfaces.netenv-default ]; then
# yes, it's there, we remove the stale link
rm /etc/network/interfaces
# and put the original file back
mv /etc/network/interfaces.netenv-default /etc/network/interfaces
echo "Netenv: Restored old interfaces (Bug #225582)."
else
# the original file could not be found, we cannot resolve the situation.
echo "Problems cleaning up wrong links for interfaces (Bug #225582)."
echo "Correct removal or purge of netenv might require manual action"
fi
fi
fi
# the cause of all that mess was a typo in the setup-default script.
BAD_SCRIPT=/etc/netenv/setup-default
# is it still called? Only look in non-commented lines
if [ -f $BAD_SCRIPT ]; then
if grep -v ^# $BAD_SCRIPT | grep netenv_default >/dev/null 2>&1; then
tempfile=`tempfile`
trap 'rm -f $tempfile' 0 HUP INT QUIT PIPE TERM
# replace in non-commented lines
sed -e 's/^\([[:space:]]*[^#]*\)netenv_default/\1netenv-default/g' < $BAD_SCRIPT >$tempfile
rm $BAD_SCRIPT
mv $tempfile $BAD_SCRIPT
echo "Netenv: Corrected buggy setup-default file (Bug #225582)."
fi
fi
# if we found false links, we know that the setup using links was
# chosen (but never worked). To enable it again in postinst, we now
# write a temporary file; postinst will look for it.
if [ $FALSE_LINKS = true ]; then
touch /var/tmp/netenv_upgrade_restored-symlinks
fi
}
check_interfaces () {
INTERFACES=/etc/network/interfaces
TMP_INTERFACES=`tempfile 2> /dev/null`
trap 'rm -f $TMP_INTERFACES' 0 HUP INT QUIT PIPE TERM
TMP2_INTERFACES=`tempfile 2> /dev/null`
trap 'rm -f $TMP2_INTERFACES' 0 HUP INT QUIT PIPE TERM
# filter out commented and blank lines, get the 5 lines
# following the eth0 entry. (the || true is necessary because we are set -e)
egrep -v '^[[:blank:]]*$|^#' $INTERFACES 2>/dev/null | grep -A 5 "iface eth0" > $TMP_INTERFACES || true
# how many lines are there really (maximum is 6)?
LINES=`wc -l $TMP_INTERFACES | cut -d " " -f 5`
# there can be up to 5 options. But the next iface stanza might also
# start earlier. So, do we have an other iface entry in here? If
# yes, kick out the last lines, one by one, until there's no "iface"
# left.
while grep -v "iface eth0" $TMP_INTERFACES | grep iface > /dev/null; do
LINES=$(($LINES - 1))
head -n $LINES $TMP_INTERFACES > $TMP2_INTERFACES
cat $TMP2_INTERFACES > $TMP_INTERFACES
done
rm $TMP2_INTERFACES
# Now, how eth0 defined? The sed expression should yield static, dhcp, or bootp.
# It is kind of complicated, because there may be different amount of different
# kind of whitespace between the keywords, and a comment after it.
ETH0_METHOD=`grep "iface eth0" $TMP_INTERFACES | \
sed -e \
's/[[:space:]]*iface[[:space:]][[:space:]]*eth0[[:space:]][[:space:]]*inet[[:space:]][[:space:]]*\(.*\)[[:space:]]*.*/\1/'`
case $ETH0_METHOD in
static)
# yes, it's static. So we need an address field. Is it there?
if grep address $TMP_INTERFACES >/dev/null 2>&1; then
# o.k., it seems eth0 is configured in /etc/network/interfaces.
# is there also a readable resolv.conf?
if [ -r /etc/resolv.conf ]; then
# yes, so we can use this information
IP_IN_INTERFACES=true;
fi
fi
;;
dhcp|bootp)
# there's no "must" keywords here. We assume it is configured correctly
IP_IN_INTERFACES=true;
;;
esac
rm $TMP_INTERFACES
}
is_true () {
# this is what the pcmcia packages recognize as true
[ "$1" = "y" -o "$1" = "Y" -o "$1" = "yes" -o "$1" = "YES" ]
}
check_network_opts () {
NETOPTS=/etc/pcmcia/network.opts
if [ -r $NETOPTS ]; then
# are the necessary variables set in this file
# (either ip address, or bootp/dhcp)
PCMCIA_IPADDR=`grep_var IPADDR $NETOPTS`
PCMCIA_BOOTP=`grep_var BOOTP $NETOPTS`
PCMCIA_DHCP=`grep_var DHCP $NETOPTS`
if [ -n "$PCMCIA_IPADDR" ]; then
IP_IN_PCMCIA=true;
elif is_true $PCMCIA_BOOTP; then
IP_IN_PCMCIA=true;
elif is_true $PCMCIA_DHCP; then
IP_IN_PCMCIA=true;
fi
fi
}
# end of function defining
# variables used:
NODE=`uname -n`
# there was a bug in 0.94.3-1 which might have messed up the
# configuration. We check for that and restore the old files,
# if possible.
restore_false_links
# figure out whether there is an existing configuration
CONFS=`ls -1 /etc/netenv/${NODE}* 2>/dev/null|wc|awk '{print $1}'` || true
# here we go...
if [ $CONFS -gt 0 ]; then
# it seems there is an old configuration yet.
# Should we keep it?
# (this question has to be set to unseen first, unless explicitly specified)
db_get netenv/showagain
if [ X$RET = Xfalse ]; then
:
else
db_fset netenv/is_configured0 seen false || true
db_fset netenv/showagain seen false || true
fi
db_subst netenv/is_configured0 NODE ${NODE} || true
# so, should we keep it?
db_input medium netenv/is_configured0 || true
db_go
else
# no configuration files found. Ask how to create them, or to disable netenv
db_set netenv/is_configured0 false || true
fi
# now look whether we in fact should change the configuration
# (either because there is none, or because we have been asked to)
db_get netenv/is_configured0 || true
if [ "$RET" = "false" ]; then
# first find out wether network information is stored in /etc/network/interfaces
# or in /etc/pcmcia/network.opts, or both or none
IP_IN_INTERFACES=false
IP_IN_PCMCIA=false
check_interfaces
check_network_opts
# compare what we've found:
AUTO_OK=false
DISABLE_REASON=
AUTO_METHOD=
if [ "$IP_IN_INTERFACES" = "true" ]; then
# we found can use /etc/network/interfaces.
if [ "$IP_IN_PCMCIA" = "true" ]; then
# we also found that we can use network.opts. There is no way to
# find out which is correct, so we do not automatically configure
AUTO_OK=false
DISABLE_REASON=twoconfs
else
# only interfaces, automatic is o.k.
AUTO_OK=true
AUTO_METHOD=interfaces
fi
else
# no configuration found in network/interfaces
if [ "$IP_IN_PCMCIA" = "true" ]; then
# but it's there in network.opts, automatic is o.k.
AUTO_OK=true
AUTO_METHOD=pcmcia
else
# no conf at all.
AUTO_OK=false
DISABLE_REASON=noconf
fi
fi
# can the configuration we found be used?
if [ "$AUTO_OK" = "true" ]; then
# yes, it can. Still we first ask wether this is desired.
db_input medium netenv/auto_configure || true
db_go
db_get netenv/auto_configure
if [ "$RET" = "Use current settings" ]; then
# the user asked us to use the settings we found for automatic configuration
case "$AUTO_METHOD" in
# now we store the method to use (interfaces vs. network.opts) in debconf,
# for use by postinst.
interfaces)
db_set netenv/auto_method interfaces
# also we inform the user about the method chosen, and how to
# generate more configurations
db_subst netenv/info_interfaces NODE ${NODE}
db_input high netenv/info_interfaces || true
;;
pcmcia)
db_set netenv/auto_method pcmcia
# here we inform the user what he still has to do to make it work.
db_input critical netenv/info_pcmcia || true
;;
*) exit 1
esac
db_go
fi
else
# if we can't use the current configuration, we simply
# disable netenv on boot:
db_set netenv/auto_configure "Disable for now" || true
# and tell the user why.
case "$DISABLE_REASON" in
noconf)
db_input high netenv/noconf || true ;;
twoconfs)
db_input high netenv/twoconfs || true ;;
*) exit 1
esac
db_go
fi
else
# if there was an existing configuration, we ask the user whether he doesn't
# want to be bothered again.
db_input medium netenv/showagain || true
db_go
fi
|