title: deb package fails while postinst bash script executing
body: <p>Im making a bash script for nagios custom plugins &amp; configuration
  i use equivs for its simplicity</p>
  
  <p>here'is my control file.</p>
  
  <p>in Files: section , i tell files to copy themselves to their right path.</p>
  
  <pre><code>Files: check_cpu_loadx /usr/lib/nagios/plugins
   check_ipmi_sensors /usr/lib/nagios/plugins
   check_libreoffice_count /usr/lib/nagios/plugins
   check_ram_per_user /usr/lib/nagios/plugins
   check_ram_usage2 /usr/lib/nagios/plugins
   check_ram_usage_percentage /usr/lib/nagios/plugins
   check_tcptraffic /usr/lib/nagios/plugins
   nrpe_custom.cfg /etc/nagios
  </code></pre>
  
  <p>in the postinst section , it's a bash script that is used for post-install</p>
  
  <pre><code> File: postinst
       #!/bin/bash -e
       set -x
       echo 'configuring nrpe.conf file.'
       mv /etc/nagios/nrpe.cfg /etc/nagios/nrpe.original.backup
       mv /etc/nagios/nrpe_custom.cfg /etc/nagios/nrpe.cfg
       chmod -R +x /usr/lib/nagios/plugins
       echo 'Installing tcp-ip addon..'
       FLAG=0
       Interfaces=`ifconfig -a | grep -o -e "[a-z][a-z]*[0-9]*[ ]*Link" | perl -pe "s|^([a-z]*[0-9]*)[ ]*Link|\1|"`
       for Interface in $Interfaces; do
          INET=`ifconfig $Interface | grep -o -e "inet addr:[^ ]*" | grep -o -e "[^:]*$"`
          MASK=`ifconfig $Interface | grep -o -e "Mask:[^ ]*"      | grep -o -e "[^:]*$"`
          STATUS="up"
          #loopback
          if [ "$Interface" == "lo" ]; then
              continue
          fi
          #if eth is down
          if [ -z "$INET" ]; then
              continue
          fi
           #if eth ip not starts with 10. or 192.
          if [[ "$INET" == 10.* ]]
          then
              ActiveEth=$Interface;
              break
          elif [[ "$INET" == 192.* ]]
          then
          ActiveEth=$Interface;
              break
          else
              echo "Ethernet Selection Failed!Configure nrpe.cfg manually.Change tcp_traffic plugin paramethers according to your current ethernet.";
              FLAG=1
              break
          fi    
       done
       if [[ "$FLAG" == 0 ]]
       then
           echo 'Selected Ethernet :'$ActiveEth
           sed -i -e "s/eth0/$ActiveEth/g" /etc/nagios/nrpe.cfg
       fi
       echo 'nrpe.conf changed.'
       echo 'Nagios-nrpe-server restarting.'
       service nagios-nrpe-server restart
       echo 'IPMI modules are loading.'
       modprobe ipmi_devintf
       modprobe ipmi_msghandler
       echo "IPMI modules are added to startup."
       #echo "ipmi_si" &gt;&gt; /etc/modules
       echo "ipmi_devintf" &gt;&gt; /etc/modules
       echo "ipmi_msghandler" &gt;&gt; /etc/modules
  </code></pre>
  
  <p>the problem here , when i compile it to deb package i got <strong>"subprocess installed post-installation script return error exit status 1"</strong></p>
  
  <p>then i added set -x for debugging.the problem is for configuring tcp-ip addon , there are some machines that have more then one ethernet card.So i need to choose with the one that has a ip that starts with 10.* or 192.*</p>
  
  <p>in the second section , there is a line 
  <strong>INET=<code>ifconfig $Interface | grep -o -e "inet addr:[^ ]*" | grep -o -e "[^:]*$"</code></strong>
  when a ethernet device has no ip , grep returns null and INET variable becomes null , that why the process exit status is 1.
  after that line , when i enter "$?" , it says 1</p>
  
  <p>so the problem here is , when i run dpkg -i to install that package , bash script quits after it sees that INET becomes null .. </p>
  
  <p>any help would be appreciated. Im new to this bash thing.</p>