This file is indexed.

postinst is in ifupdown 0.7~beta2ubuntu8.

This file is a maintainer script. It is executed when installing (*inst) or removing (*rm) the package.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/sh
set -e

MYNAME="${0##*/}"

report() { echo "${MYNAME}: $*" ; }
report_warn() { report "Warning: $*" >&2 ; }
report_err() { report "Error: $*" >&2 ; }

# Create /etc/network/run 
if [ "$1" = configure -a ! -d /etc/network/run ]; then
  if [ -e /etc/network/run -o -L /etc/network/run ]; then
    echo "Removing non-directory /etc/network/run..."
    rm -f /etc/network/run
    [ -L /etc/network/run.dpkg-old ] && echo "Removing old symlink /etc/network/run.dpkg-old..." && rm -f /etc/network/run.dpkg-old
  fi

  # The best choice is to use /run/network
  # That must be supported everywhere

  [ -d /run/network ] || mkdir -p /run/network
  ln -s /run/network /etc/network/run
fi 

# Move /etc/network/ifstate to /etc/network/run/ifstate
if [ "$1" = configure -a "$2" != "" -a -e /etc/network/ifstate ] &&
     dpkg --compare-versions "$2" lt "0.6.5"
then
  if [ ! -e /etc/network/run/ifstate ] || ! diff /etc/network/ifstate /etc/network/run/ifstate >/dev/null
  then
    echo "Moving /etc/network/ifstate to /etc/network/run/ifstate"
    if [ ! -L /etc/network/ifstate ]; then
      mv /etc/network/ifstate /etc/network/run/ifstate
    else
      cat /etc/network/ifstate >/etc/network/run/ifstate
      mv /etc/network/ifstate /etc/network/ifstate.dpkg-old
    fi
  fi
fi

l=$(readlink /etc/network/run || echo /etc/network/run)

# Migrate /etc/network/run to /run/network
if [ "$1" = configure -a "$2" != "" -a -e /etc/network/run -a "$l" != "/run/network" ]
then
  echo "Migrating network state directory from $l to /run/network..."
  [ -d /run/network ] || mkdir /run/network
  if [ -e /etc/network/run/ifstate ]
  then
    echo "Moving /etc/network/run/ifstate to /run/network/ifstate"
    if [ ! -L /etc/network/run/ifstate ]; then
      mv -f /etc/network/run/ifstate /run/network/ifstate
    else
      # we do this thing with .dpkg-new just so we don't truncate the
      # state file in the case of crazy symlinked or mount-bound setup
      cat /etc/network/run/ifstate >/run/network/ifstate.dpkg-new
      mv -f /etc/network/run/ifstate /run/network/ifstate.dpkg-old
      mv -f /run/network/ifstate.dpkg-new /run/network/ifstate
    fi
  fi
  mv -f /etc/network/run /etc/network/run.dpkg-old
  ln -s /run/network /etc/network/run
  rmdir /etc/network/run.dpkg-old 2>/dev/null || report_warn "Not removing the old contents of /etc/network/run: directory not empty; renamed into /etc/network/run.dpkg-old."
fi


if [ "$1" = "configure" -a "$2" != "" ] &&
     dpkg --compare-versions "$2" le "0.6.4-4.1" &&
     [ -f /etc/network/run/ifstate -a -x /sbin/dhclient ]
then
  # for every active ifupdown-controlled dhclient interface, copy
  # /var/run/dhclient.pid, so that the new ifdown is able to kill
  # dhclient.
  #
  # the old version had a bug with more than one DHCP iface anyway,
  # so we don't know which one the PID file actually belongs to.

  sed -e 's/^.*=//' /etc/network/run/ifstate |
    while read iface; do
      # handle \<newline>-continued lines
      if sed -e '/^[[:space:]]*#/b;:g /\\$/{N;s/\\\n//;bg;}' /etc/network/interfaces | grep -qe "^[[:space:]]*iface[[:space:]]*\\b${iface}\\b[[:space:]]*.*\\bdhcp\\b.*" &&
          [ -f "/var/run/dhclient.pid" ] &&
          [ ! -f "/var/run/dhclient.${iface}.pid" ]
      then
        # copy original file.  If dhclient was started
        # manually, one can still use dhclient.pid, if started
        # by ifupdown, the new ifupdown can take it down with 
        # dhclient.${iface}.pid.  Obsolete files are removed during
        # next boot (bootmisc.sh).
        cp /var/run/dhclient.pid "/var/run/dhclient.${iface}.pid"
      fi
    done
fi

# Remove the ifupdown and ifupdown-clean init script symlinks
if [ "$1" = "configure" -a "$2" != "" ] &&
     dpkg --compare-versions "$2" lt "0.6.7ubuntu4"
then
    rm -f /etc/init.d/ifupdown /etc/init.d/ifupdown-clean
    rm -f /etc/default/ifupdown

    update-rc.d -f ifupdown remove
    update-rc.d -f ifupdown-clean remove
fi

# Generic stuff done on all configurations
if [ "$1" = "configure" ] ; then
  if [ -f /etc/network/interfaces ] ; then
    # TODO: This should be handled with debconf and the script
    # could introduce the line there directly
    if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then
      report_warn "No 'iface lo' definition found in /etc/network/interfaces"
      report_warn " adding it for you"
      if ! grep -q "^[[:space:]]*auto[[:space:]].*\<lo\>" /etc/network/interfaces ; then
        # both are missing? add the whole block
        report_warn "No 'auto lo' statement found in /etc/network/interfaces"
        report_warn " adding it for you"
cat >> /etc/network/interfaces <<EOF

# The loopback network interface
auto lo
iface lo inet loopback
EOF
      else
        sed -i -e'/^[[:space:]]*auto[[:space:]].*\<lo\>/a\
iface lo inet loopback' /etc/network/interfaces
      fi
    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"
      report_warn " adding it for you"
      sed -i -e'/^[[:space:]]*iface[[:space:]]\+lo[[:space:]]\+inet[[:space:]]\+loopback\>/i\
auto lo' /etc/network/interfaces
    fi
  else  # ! -f /etc/network/interfaces
    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
  fi
fi

if [ -x "/etc/init.d/ifupdown" ]; then
    update-rc.d -f ifupdown remove >/dev/null || exit $?
fi

if [ -x "/etc/init.d/ifupdown-clean" ]; then
    update-rc.d -f ifupdown-clean remove >/dev/null || exit $?
    rm -f /etc/init.d/ifupdown-clean
fi