~ubuntu-branches/ubuntu/oneiric/netbase/oneiric

« back to all changes in this revision

Viewing changes to debian/netbase.postinst

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2006-01-25 17:16:36 UTC
  • Revision ID: james.westby@ubuntu.com-20060125171636-f3kg5a9smhkumguw
Tags: 4.24ubuntu1
* Resynchronise with Debian.
  - Manually fix up init script again.
* Migrate /etc/network/options to /etc/sysctl.conf settings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
  . /usr/share/debconf/confmodule
5
5
fi
6
6
 
7
 
remove_options_file() {
8
 
  [ -z "$2" -o ! -e /etc/network/options ] || return 0
9
 
  if dpkg --compare-versions "$2" ge "4.22-1"; then
10
 
    return 0
11
 
  fi
12
 
 
13
 
  # on which conditions should /etc/network/options be silently removed?
 
7
# Set an entry in sysctl.conf
 
8
set_sysctl() {
 
9
        if [ -n "$2" ]; then
 
10
                return
 
11
        elif [ "$2" = "no" ]; then
 
12
                value=0
 
13
        else
 
14
                value=1
 
15
        fi
 
16
 
 
17
        if [ -e /etc/sysctl.conf ]; then
 
18
                if grep "^$1=" /etc/sysctl.conf >/dev/null 2>&1; then
 
19
                        echo >> /etc/sysctl.conf
 
20
                        echo "# From /etc/network/options; commented out due to your setting above" >> /etc/sysctl.conf
 
21
                        echo "#$1=$value" >> /etc/sysctl.conf
 
22
                elif grep "^# *$1=" /etc/sysctl.conf >/dev/null 2>&1; then
 
23
                        sed -i -e "s,^# *$1=.*,$1=$value," /etc/sysctl.conf
 
24
                else
 
25
                        echo >> /etc/sysctl.conf
 
26
                        echo "# From /etc/network/options" >> /etc/sysctl.conf
 
27
                        echo "#$1=$value" >> /etc/sysctl.conf
 
28
                fi
 
29
        else
 
30
                echo >> /etc/sysctl.conf
 
31
                echo "# From /etc/network/options" >> /etc/sysctl.conf
 
32
                echo "#$1=$value" >> /etc/sysctl.conf
 
33
        fi
 
34
}
 
35
 
 
36
# Convert the options file into sysctl.conf
 
37
migrate_options_file() {
 
38
        [ -n "$2" -a -e /etc/network/options ] || return 0
 
39
        dpkg --compare-versions "$2" lt "4.24ubuntu1" || return 0
 
40
 
 
41
        . /etc/network/options
 
42
 
 
43
        set_sysctl "net/ipv4/conf/all/rp_filter" "$spoofprotect"
 
44
        set_sysctl "net/ipv4/ip_forward"         "$ip_forward"
 
45
        set_sysctl "net/ipv4/tcp_syncookies"     "$syncookies"
 
46
        
 
47
        rm -f /etc/network/options
14
48
}
15
49
 
16
50
remove_old_files() {
106
140
 
107
141
case "$1" in
108
142
    configure)
 
143
    migrate_options_file "$@"
109
144
    #remove_options_file "$@"
110
145
    remove_old_files
111
146
    kill_portmapper "$@"