postinst 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 | #! /bin/sh
# postinst script for netenv
#
# see: dh_installdeb(1)
set -e
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
#
# function defining (look for "lets do the work" to find the real beginning)
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/'
}
config_current_onboard () {
cd /etc/
# The script must not give an error when run multiple times.
#
# Since this function is also run when the user chose to overwrite an
# existing configuration, we destroy/restore what we find.
if [ -L resolv.conf ]; then
target=`readlink resolv.conf`
rm resolv.conf
mv $target resolv.conf
fi
rm -f resolv.conf.netenv-old resolv.conf.netenv-default
# now we are in the state before netenv touched the system.
#
# now create the new configuration. Since we just made them ordinary files
# in case they were symlinks, we can safely assume that they are. All other cases
# (devices or the like) will brake anyway.
cp resolv.conf resolv.conf.netenv-default
rm resolv.conf
ln -s resolv.conf.netenv-default resolv.conf
# now we do the same for interfaces:
cd network
if [ -L interfaces ]; then
target=`readlink interfaces`
rm interfaces
mv $target interfaces
fi
rm -f interfaces.netenv-old interfaces.netenv-default
cp interfaces interfaces.netenv-default
rm interfaces
ln -s interfaces.netenv-default interfaces
# now we create the files in /etc/netenv/. First the file describing the configuration
cat > $SETUPFILE << EOF
# created by Debian setup
netenv_id=Installation_default
export NETENV_SCRIPT=/etc/netenv/setup-default
# you can set any variable here. export it!
EOF
# and this is the script to run that will move the symlinks
cat > $NETENV_SCRIPT <<EOF
#!/bin/sh
# created by Debian setup
if [ -r /etc/network/interfaces.netenv-default ]; then
mv /etc/network/interfaces /etc/network/interfaces.netenv-old
ln -s /etc/network/interfaces.netenv-default /etc/network/interfaces
fi
if [ -r /etc/resolv.conf.netenv-default ]; then
mv /etc/resolv.conf /etc/resolv.conf.netenv-old
ln -s /etc/resolv.conf.netenv-default /etc/resolv.conf
fi
# you can do this with any file, e.g. /etc/printcap or XF86Config.
EOF
# just to be sure, fix permissions
chown 0 /etc/netenv/*
chmod 644 /etc/netenv/*
}
config_current_pcmcia () {
# list of variables to get from /etc/pcmcia/network.opts
VARLIST="IF_PORT BOOTP DHCP DHCP_HOSTNAME PPPOE IPADDR NETMASK NETWORK BROADCAST GATEWAY DOMAIN SEARCH DNS1 DNS2 DNS3"
# first, set all of them to empty values
for VARIABLE in $VARLIST; do
eval $VARIABLE="";
done
NETOPTS_TMP=`tempfile -d /tmp 2>/dev/null`
trap 'rm -f $NETOPTS_TMP' 0 HUP INT QUIT PIPE TERM
# write non-comment, non-empty lines with a variable assignment to temporary file
egrep -v '^#|^$' /etc/pcmcia/network.opts | grep "=" > $NETOPTS_TMP
# look for each variable in $VARLIST and assign it to the value found in the tempfile
for VARIABLE in $VARLIST; do
eval $VARIABLE="`grep_var $VARIABLE $NETOPTS_TMP`";
done
rm $NETOPTS_TMP
# now write the netenv setup file
echo "# default configuration file, created by postinst script" > $SETUPFILE
echo "netenv_id=installation_default" >> $SETUPFILE
for VARIABLE in $VARLIST; do
if [ -n "`eval echo "$"$VARIABLE`" ]; then
# the value is not zero, so write it:
echo "export $VARIABLE="`eval echo "$"$VARIABLE` >> $SETUPFILE
fi
done
}
# The sequence number of netenv was changed after version, to have a
# sequence number before networking and ifupdown. It is reinserted by
# debhelper below.
#
# In version 0.94.3-25, this statement was after DEBHELPER tag which
# leaded to #547394 as the tag is replaced by `update-rc.d start'
# (dh_installinit).
if [ "$1" = "configure" ] && dpkg --compare-versions "$2" le "0.94.3-24" ; then
update-rc.d -f netenv remove > /dev/null || exit $?
fi
# lets do the work
# We have to put the debhelper scripts above the hand-crafted
# part. Thus, we can disable netenv on boot time later by using
# update-rc.d.
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
# Automatically added by dh_installinit
if [ -x "/etc/init.d/netenv" ]; then
if [ ! -e "/etc/init/netenv.conf" ]; then
update-rc.d netenv start 38 S . >/dev/null
fi
fi
# End automatically added section
. /usr/share/debconf/confmodule
NODE=`uname -n`
SETUPFILE=/etc/netenv/${NODE}
NETENV_SCRIPT=/etc/netenv/setup-default
case "$1" in
configure|reconfigure)
# clean up for old bug (pre-0.82)
find /etc/netenv \( -name "dialo*" ! -name "*-*" \) -o \( -name "netenv.tmp.*" \) -exec rm -f {} \;
# clean up temporary file of version 0.82
if [ -f /etc/netenv/netenv ]; then
cat > /etc/netenv/netenv <<EOF
This file is no longer used or updated; you can
safely remove it.
Please refer to the tempfile
/var/tmp/netenv*
EOF
fi
# remove stale file from version 0.82
if [ -e /etc/netenv/${NODE}-default ]; then rm /etc/netenv/${NODE}-default; fi
# clean up temporary files (from version 0.94.2-2)
find /var/tmp/ -type f -name "neten*" -atime +1 -exec rm '{}' \;
# restoring after bug #225582 (cleanup has been done in config)
if [ -f /var/tmp/netenv_upgrade_restored-symlinks ]; then
# if there were stale links, this means there should be links. We configure
# with the link method
config_current_onboard
fi
# normal operation. Is netenv configured yet?
db_get netenv/is_configured0
if [ "$RET" = "false" ]; then
# not configured, can we configure automatically?
db_get netenv/auto_configure
case "$RET" in
"Use current settings")
# we can do automatic configuration. But which method?
db_get netenv/auto_method
case "$RET" in
pcmcia)
# do the configuration based on /etc/pcmcia/network.opts
config_current_pcmcia ;;
interfaces)
# do it based on /etc/network/interfaces
config_current_onboard ;;
*)
exit 1 ;;
esac
;;
"Disable for now")
# it's not exactly good to use update-rc.d in postinst, because it will
# nuke any local customization. However, we only do this if there is no
# working configuration, or the admin chose not to run his old one. This
# is kind of an emergency, and he'll have to read the docs and fiddle with
# his configuration manually, anyway.
update-rc.d -f netenv remove > /dev/null || exit $? ;;
*)
exit 1;;
esac
fi
# now clean up old, now unused debconf templates
OLDTEMPLATES_0_94_2="netenv/howto_manual netenv/onboard_current_unreadable netenv/info_schemes netenv/howto_enable0 netenv/dialog_missing0 netenv/info_pcmcia netenv/ask_pcmcia netenv/howto_configure0 netenv/info_configure0 netenv/is_pcmcia netenv/IF_PORT netenv/BOOTP netenv/DHCP netenv/DHCP_HOSTNAME netenv/PPPOE netenv/IPADDR netenv/NETMASK netenv/NETWORK netenv/BROADCAST netenv/GATEWAY netenv/DOMAIN netenv/SEARCH netenv/DNS1 netenv/DNS2 netenv/DNS3"
OLDTEMPLATES_0_04_3_2="netenv/cleaned_225582"
OLDTEMPLATES="$OLDTEMPLATES_0_94_2 $OLDTEMPLATES_0_04_3_2"
for template in $OLDTEMPLATES; do
db_unregister netenv/$template || true
done
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
db_stop
exit 0
|