11
11
# conffile transition between netbase and ifupdown and changing from an
12
12
# upstart-job symlink to a real conffile, so we have to hack around it in
13
13
# the preinst and postinst.
14
# NOTE: This can be dropped after 14.04 LTS
14
15
if dpkg --compare-versions "$2" lt-nl 0.7.5ubuntu4; then
15
16
CONFFILE=/etc/init.d/networking
16
17
if ([ ! -e "$CONFFILE" ] && [ -e "$CONFFILE".dpkg-dist ]) \
116
116
# Generic stuff done on all configurations
117
117
if [ "$1" = "configure" ] ; then
118
if [ -f /etc/network/interfaces ] ; then
119
# TODO: This should be handled with debconf and the script
120
# could introduce the line there directly
121
if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then
122
report_warn "No 'iface lo' definition found in /etc/network/interfaces"
123
report_warn " adding it for you"
124
if ! grep -q "^[[:space:]]*auto[[:space:]].*\<lo\>" /etc/network/interfaces ; then
125
# both are missing? add the whole block
126
report_warn "No 'auto lo' statement found in /etc/network/interfaces"
127
report_warn " adding it for you"
128
cat >> /etc/network/interfaces <<EOF
130
# The loopback network interface
132
iface lo inet loopback
135
sed -i -e'/^[[:space:]]*auto[[:space:]].*\<lo\>/a\
136
iface lo inet loopback' /etc/network/interfaces
139
if ! grep -q "^[[:space:]]*\(allow-\|\)auto[[:space:]]\+\(.*[[:space:]]\+\|\)lo0\?\([[:space:]]\+\|$\)" /etc/network/interfaces ; then
140
report_warn "No 'auto lo' statement found in /etc/network/interfaces"
141
report_warn " adding it for you"
142
sed -i -e'/^[[:space:]]*iface[[:space:]]\+lo[[:space:]]\+inet[[:space:]]\+loopback\>/i\
143
auto lo' /etc/network/interfaces
145
else # ! -f /etc/network/interfaces
146
echo "Creating /etc/network/interfaces."
147
echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces
148
echo "auto lo" >> /etc/network/interfaces
149
echo "iface lo inet loopback" >> /etc/network/interfaces
118
# We don't need loopback interface definition anymore as
119
# ifupdown handles loopback interface on its own from now
120
if [ ! -f /etc/network/interfaces ] ; then
122
echo "Creating /etc/network/interfaces."
123
echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces
124
echo "# Include files from /etc/network/interfaces.d:" >> /etc/network/interfaces
125
echo "source-directory /etc/network/interfaces.d" >> /etc/network/interfaces
127
report_warn "/etc/network/interfaces does not exist"