~ubuntu-branches/ubuntu/saucy/netbase/saucy

« back to all changes in this revision

Viewing changes to debian/netbase.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Lorenzo De Liso
  • Date: 2010-11-08 12:25:31 UTC
  • mfrom: (1.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20101108122531-rmi2wpcqab27f2nq
Tags: 4.43ubuntu1
* Merge from debian unstable (LP: #671193), remaining changes:
  - debian/netbase.init:
    + silence ifup/ifdown if VERBOSE == no
    + silence debuging output if VERBOSE == no
    + Temporarily increase usplash timeout to 120 seconds
      to cope with slop DHCP server responses. LP: #21617
    + Replace the "start" command with a call to upstart-job
  - debian/control: Depend on upstart-job
  - debian/netbase.postinst:
    + Remove old start symlinks on upgrade
    + Only install symlinks for runlevel 0 and 6
* Dropped changes:
  - Don't deconfigure network interfaces if /etc/iscsi/iscsi.initramfs
    exists, since that probably indicates root on iSCSI (LP: #447377): fixed
    in debian

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh -e
2
2
 
3
 
remove_options_file() {
4
 
  [ -z "$2" -o ! -e /etc/network/options ] || return 0
5
 
  if dpkg --compare-versions "$2" ge "4.22-1"; then
6
 
    return 0
7
 
  fi
8
 
 
9
 
  # on which conditions should /etc/network/options be silently removed?
 
3
create_hosts_file() {
 
4
  if [ -e /etc/hosts ]; then return 0; fi
 
5
 
 
6
  cat > /etc/hosts <<-EOF
 
7
        127.0.0.1       localhost
 
8
        ::1             localhost ip6-localhost ip6-loopback
 
9
        fe00::0         ip6-localnet
 
10
        ff00::0         ip6-mcastprefix
 
11
        ff02::1         ip6-allnodes
 
12
        ff02::2         ip6-allrouters
 
13
 
 
14
EOF
10
15
}
11
16
 
12
 
update_hosts_file() {
13
 
  if [ -f /etc/hosts ] && ! grep -qE "^::1[[:space:]]" /etc/hosts; then
14
 
    cat >>/etc/hosts <<-EOF
15
 
 
16
 
        ::1     localhost ip6-localhost ip6-loopback
17
 
        fe00::0 ip6-localnet
18
 
        ff00::0 ip6-mcastprefix
19
 
        ff02::1 ip6-allnodes
20
 
        ff02::2 ip6-allrouters
 
17
create_networks_file() {
 
18
  if [ -e /etc/networks ]; then return 0; fi
 
19
 
 
20
  cat > /etc/networks <<-EOF
 
21
        default         0.0.0.0
 
22
        loopback        127.0.0.0
 
23
        link-local      169.254.0.0
 
24
 
21
25
EOF
22
 
  fi
23
26
}
24
27
 
25
28
update_rc() {
29
32
  update-rc.d networking start 35 0 6 . > /dev/null
30
33
}
31
34
 
32
 
create_networks() {
33
 
  if [ -e /etc/networks ]; then return 0; fi
34
 
 
35
 
  cat >> /etc/networks <<-EOF
36
 
        default         0.0.0.0
37
 
        loopback        127.0.0.0
38
 
        link-local      169.254.0.0
39
 
        
 
35
# create bindv6only.conf on new installs and upgrades from << 4.38
 
36
create_bindv6only_conf() {
 
37
  if [ -e /etc/sysctl.d/bindv6only.conf ]; then
 
38
    return 0
 
39
  fi
 
40
  [ "$(uname -s)" = "Linux" ] || return 0
 
41
  [ -d /etc/sysctl.d/ ] || mkdir /etc/sysctl.d/
 
42
  if [ "$2" ] && dpkg --compare-versions "$2" ge "4.38"; then
 
43
    return 0
 
44
  fi
 
45
 
 
46
  cat >> /etc/sysctl.d/bindv6only.conf <<-EOF
 
47
# This sysctl sets the default value of the IPV6_V6ONLY socket option.
 
48
#
 
49
# When disabled, IPv6 sockets will also be able to send and receive IPv4
 
50
# traffic with addresses in the form ::ffff:192.0.2.1 and daemons listening
 
51
# on IPv6 sockets will also accept IPv4 connections.
 
52
#
 
53
# When IPV6_V6ONLY is enabled, daemons interested in both IPv4 and IPv6
 
54
# connections must open two listening sockets.
 
55
# This is the default behaviour of almost all modern operating systems.
 
56
 
 
57
net.ipv6.bindv6only = 1
40
58
EOF
41
59
}
42
60
 
43
61
case "$1" in
44
62
    configure)
45
 
    #remove_options_file "$@"
46
 
    update_hosts_file
 
63
    if [ -z "$2" ]; then
 
64
        create_hosts_file
 
65
        create_networks_file
 
66
    fi
47
67
    update_rc
48
 
    create_networks
 
68
    #create_bindv6only_conf "$@"
49
69
    ;;
50
70
 
51
71
    abort-upgrade|abort-remove|abort-deconfigure)