]>
Commit | Line | Data |
---|---|---|
522bf8e6 | 1 | #!/bin/bash |
a6f80f0e | 2 | set -e |
3 | ||
4 | MYNAME="${0##*/}" | |
5 | ||
6 | report() { echo "${MYNAME}: $*" ; } | |
7 | report_warn() { report "Warning: $*" >&2 ; } | |
8 | report_err() { report "Error: $*" >&2 ; } | |
9 | ||
10 | case "$1" in | |
11 | configure) | |
12 | # Create /etc/network/run | |
13 | [ -d /run/network ] || mkdir -p /run/network | |
14 | ||
15 | # for backward compatibility | |
551a3627 | 16 | if [ ! -f /etc/network/run ]; then |
17 | ln -sf /run/network /etc/network/run | |
18 | fi | |
a6f80f0e | 19 | |
93e8319a | 20 | ln -sf /usr/share/python-ifupdown2/generate_interfaces.py /usr/share/doc/python-ifupdown2/examples/generate_interfaces.py |
21 | ||
a6f80f0e | 22 | [ -d /etc/network/if-pre-up.d ] || mkdir -p /etc/network/if-pre-up.d |
23 | [ -d /etc/network/if-up.d ] || mkdir -p /etc/network/if-up.d | |
24 | [ -d /etc/network/if-post-up.d ] || mkdir -p /etc/network/if-post-up.d | |
25 | ||
26 | [ -d /etc/network/if-pre-down.d ] || mkdir -p /etc/network/if-pre-down.d | |
27 | [ -d /etc/network/if-down.d ] || mkdir -p /etc/network/if-down.d | |
28 | [ -d /etc/network/if-post-down.d ] || mkdir -p /etc/network/if-post-down.d | |
29 | ||
30 | ||
31 | # Generic stuff done on all configurations | |
32 | if [ -f /etc/network/interfaces ] ; then | |
33 | # TODO: This should be handled with debconf and the script | |
34 | # could introduce the line there directly | |
35 | if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then | |
36 | report_warn "No 'iface lo' definition found in /etc/network/interfaces" | |
37 | fi | |
38 | ||
39 | if ! grep -q "^[[:space:]]*\(allow-\|\)auto[[:space:]]\+\(.*[[:space:]]\+\|\)lo0\?\([[:space:]]\+\|$\)" /etc/network/interfaces ; then | |
40 | report_warn "No 'auto lo' statement found in /etc/network/interfaces" | |
41 | fi | |
42 | else # ! -f /etc/network/interfaces | |
43 | if [ -z "$2" ]; then | |
44 | echo "Creating /etc/network/interfaces." | |
45 | echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces | |
46 | echo "auto lo" >> /etc/network/interfaces | |
47 | echo "iface lo inet loopback" >> /etc/network/interfaces | |
48 | else | |
49 | report_warn "/etc/network/interfaces does not exist" | |
50 | fi | |
51 | fi | |
52 | ||
c9bba753 RP |
53 | [ -e /sbin/ifup ] || ln -sf /sbin/ifupdown /sbin/ifup |
54 | [ -e /sbin/ifdown ] || ln -sf /sbin/ifupdown /sbin/ifdown | |
55 | [ -e /sbin/ifquery ] || ln -sf /sbin/ifupdown /sbin/ifquery | |
56 | [ -e /sbin/ifreload ] || ln -sf /sbin/ifupdown /sbin/ifreload | |
4c3af470 | 57 | |
58 | (cd /usr/share/man/man8/ && ln -sf /usr/share/man/man8/ifup.8.gz ifdown.8.gz) | |
59 | ||
d40e96ee | 60 | mkdir -p /etc/network/interfaces.d/ |
a6f80f0e | 61 | ;; |
62 | ||
63 | purge) | |
64 | # Note: We don't remove /etc/network/interfaces | |
65 | rm -f /run/network/ifstate | |
66 | rm -f /sbin/ifquery | |
67 | rm -f /sbin/ifup | |
68 | rm -f /sbin/ifdown | |
93e8319a | 69 | rm -f /usr/share/doc/python-ifupdown2/generate_interfaces.py |
a6f80f0e | 70 | ;; |
71 | esac | |
72 | ||
522bf8e6 RP |
73 | # override default udev bridge and hotplug rules because they interfere with |
74 | # networking init script | |
75 | udev_user_rulesdir=/etc/udev/rules.d/ | |
76 | udev_sys_rulesdir=/lib/udev/rules.d/ | |
77 | if [ -e $udev_user_rulesdir ]; then | |
78 | udev_ifupdown2_overrides=("80-networking.rules" "60-bridge-network-interface.rules") | |
79 | for u in ${udev_ifupdown2_overrides[*]} | |
80 | do | |
81 | if [ -e ${udev_sys_rulesdir}/$u -a ! -e ${udev_user_rulesdir}/$u ]; then | |
82 | (cd ${udev_user_rulesdir} && ln -sf /dev/null $u) | |
83 | fi | |
84 | done | |
85 | fi | |
86 | ||
a6f80f0e | 87 | if [ -x "/etc/init.d/networking" ]; then |
88 | update-rc.d networking start 40 S . start 35 0 6 . >/dev/null || exit $? | |
89 | fi | |
90 | ||
91 | #DEBHELPER# | |
ef7b7c04 JT |
92 | |
93 | exit 0 |