2015-04-21 14:07:46 -07:00
|
|
|
#!/bin/sh
|
|
|
|
# postinst script for ifupdown2
|
|
|
|
#
|
|
|
|
# see: dh_installdeb(1)
|
|
|
|
|
2013-11-04 06:06:11 -08:00
|
|
|
set -e
|
|
|
|
|
2015-04-21 14:07:46 -07:00
|
|
|
# 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>
|
|
|
|
# * <postinst> `abort-remove'
|
|
|
|
# * <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
|
|
|
|
|
2013-11-04 06:06:11 -08:00
|
|
|
MYNAME="${0##*/}"
|
|
|
|
|
|
|
|
report() { echo "${MYNAME}: $*" ; }
|
|
|
|
report_warn() { report "Warning: $*" >&2 ; }
|
|
|
|
report_err() { report "Error: $*" >&2 ; }
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
configure)
|
2015-04-21 14:07:46 -07:00
|
|
|
# Create /etc/network/run
|
2013-11-04 06:06:11 -08:00
|
|
|
[ -d /run/network ] || mkdir -p /run/network
|
|
|
|
|
|
|
|
# for backward compatibility
|
2013-11-30 23:52:30 -08:00
|
|
|
if [ ! -f /etc/network/run ]; then
|
|
|
|
ln -sf /run/network /etc/network/run
|
|
|
|
fi
|
2013-11-04 06:06:11 -08:00
|
|
|
|
2015-04-21 14:07:46 -07:00
|
|
|
ln -sf /usr/share/python-ifupdown2/generate_interfaces.py \
|
|
|
|
/usr/share/doc/python-ifupdown2/examples/generate_interfaces.py
|
2014-05-21 12:39:30 -07:00
|
|
|
|
2013-11-04 06:06:11 -08:00
|
|
|
[ -d /etc/network/if-pre-up.d ] || mkdir -p /etc/network/if-pre-up.d
|
|
|
|
[ -d /etc/network/if-up.d ] || mkdir -p /etc/network/if-up.d
|
|
|
|
[ -d /etc/network/if-post-up.d ] || mkdir -p /etc/network/if-post-up.d
|
|
|
|
|
|
|
|
[ -d /etc/network/if-pre-down.d ] || mkdir -p /etc/network/if-pre-down.d
|
|
|
|
[ -d /etc/network/if-down.d ] || mkdir -p /etc/network/if-down.d
|
|
|
|
[ -d /etc/network/if-post-down.d ] || mkdir -p /etc/network/if-post-down.d
|
|
|
|
|
|
|
|
|
|
|
|
# Generic stuff done on all configurations
|
|
|
|
if [ -f /etc/network/interfaces ] ; then
|
|
|
|
# TODO: This should be handled with debconf and the script
|
|
|
|
# could introduce the line there directly
|
|
|
|
if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then
|
|
|
|
report_warn "No 'iface lo' definition found in /etc/network/interfaces"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! grep -q "^[[:space:]]*\(allow-\|\)auto[[:space:]]\+\(.*[[:space:]]\+\|\)lo0\?\([[:space:]]\+\|$\)" /etc/network/interfaces ; then
|
|
|
|
report_warn "No 'auto lo' statement found in /etc/network/interfaces"
|
|
|
|
fi
|
|
|
|
else # ! -f /etc/network/interfaces
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
echo "Creating /etc/network/interfaces."
|
|
|
|
echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces
|
|
|
|
echo "auto lo" >> /etc/network/interfaces
|
|
|
|
echo "iface lo inet loopback" >> /etc/network/interfaces
|
|
|
|
else
|
|
|
|
report_warn "/etc/network/interfaces does not exist"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2014-12-08 22:59:41 -08:00
|
|
|
[ -e /sbin/ifup ] || ln -sf /sbin/ifupdown /sbin/ifup
|
|
|
|
[ -e /sbin/ifdown ] || ln -sf /sbin/ifupdown /sbin/ifdown
|
|
|
|
[ -e /sbin/ifquery ] || ln -sf /sbin/ifupdown /sbin/ifquery
|
|
|
|
[ -e /sbin/ifreload ] || ln -sf /sbin/ifupdown /sbin/ifreload
|
2014-04-11 12:34:47 -07:00
|
|
|
|
|
|
|
(cd /usr/share/man/man8/ && ln -sf /usr/share/man/man8/ifup.8.gz ifdown.8.gz)
|
|
|
|
|
2014-04-25 16:09:14 -07:00
|
|
|
mkdir -p /etc/network/interfaces.d/
|
2015-04-21 14:07:46 -07:00
|
|
|
update-rc.d networking start 40 S . start 35 0 6 . >/dev/null
|
|
|
|
;;
|
|
|
|
|
|
|
|
abort-upgrade|abort-remove|abort-deconfigure)
|
2013-11-04 06:06:11 -08:00
|
|
|
;;
|
|
|
|
|
2015-04-21 14:07:46 -07:00
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`$1'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2013-11-04 06:06:11 -08:00
|
|
|
esac
|
|
|
|
|
2015-04-21 14:07:46 -07:00
|
|
|
# dh_installdeb will replace this with shell code automatically
|
|
|
|
# generated by other debhelper scripts.
|
|
|
|
|
2014-06-06 23:00:24 -07:00
|
|
|
# override default udev bridge and hotplug rules because they interfere with
|
|
|
|
# networking init script
|
|
|
|
udev_user_rulesdir=/etc/udev/rules.d/
|
|
|
|
udev_sys_rulesdir=/lib/udev/rules.d/
|
|
|
|
if [ -e $udev_user_rulesdir ]; then
|
2015-04-21 14:07:46 -07:00
|
|
|
udev_ifupdown2_overrides="80-networking.rules
|
|
|
|
60-bridge-network-interface.rules"
|
|
|
|
for u in ${udev_ifupdown2_overrides}
|
2014-06-06 23:00:24 -07:00
|
|
|
do
|
|
|
|
if [ -e ${udev_sys_rulesdir}/$u -a ! -e ${udev_user_rulesdir}/$u ]; then
|
|
|
|
(cd ${udev_user_rulesdir} && ln -sf /dev/null $u)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-11-04 06:06:11 -08:00
|
|
|
#DEBHELPER#
|
2015-04-20 13:41:05 -07:00
|
|
|
|
|
|
|
exit 0
|