1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00
CumulusNetworks-ifupdown2/debian/ifupdown2.postinst
Julien Fortin d486dd0df0 ifupdown2 2.0.0 release
This is a major update coming all at once from master-next branch
master-next branch was started with --orphan option which is basically a new
branch without history.

The major changes are:
    - repackaging
    - cleanup the directory tree
    - rewritte setup.py to allow install from deb file or pypi (pip install)
    - add a Makefile to make things (like building a deb) easier
    - review all debian files

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
2018-12-13 11:43:32 -08:00

87 lines
2.6 KiB
Bash

#!/bin/sh
set -e
MYNAME="${0##*/}"
report() { echo "${MYNAME}: $*" ; }
report_warn() { report "Warning: $*" >&2 ; }
report_err() { report "Error: $*" >&2 ; }
fix_dhclient_file_with_space()
{
# because of a typo an older ifupdown2 version was creating lease file
# with trailing space. In case we still have users with such files we
# need to strip that trailing whitespace.
for filename in `find /var/lib/dhcp/ -name "dhclient.*.leases "`
do
if [ -f "$filename " ];
then
interface_name=`echo $filename | cut -d'.' -f2,3,4,5`
mv "$filename " /var/lib/dhcp/dhclient6.$interface_name
fi
done
}
process_etc_network_interfaces()
{
# Generic stuff done on all configurations
if [ -f /etc/network/interfaces ] ; then
if ! grep -q -E "^[[:space:]]*iface[[:space:]]+l[o0]([[:space:]]+inet([[:space:]]+loopback)?)?[[:space:]]*$" /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
}
process_udev()
{
# 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
udev_ifupdown2_overrides="80-networking.rules
60-bridge-network-interface.rules"
for u in ${udev_ifupdown2_overrides}
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
}
case "$1" in
configure)
fix_dhclient_file_with_space
process_etc_network_interfaces
process_udev
chmod +x /usr/share/ifupdown2/__main__.py
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0