"Fossies" - the Fresh Open Source Software Archive

Member "shorewall-init-5.2.3.3/ifupdown.debian.sh" (12 Apr 2019, 2858 Bytes) of package /linux/misc/shorewall/shorewall-init-5.2.3.3.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 #
    3 # Debian ifupdown script for Shorewall-based products
    4 #
    5 #     This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
    6 #
    7 #     (c) 2010,2013 - Tom Eastep (teastep@shorewall.net)
    8 #
    9 #       Shorewall documentation is available at http://shorewall.net
   10 #
   11 #       This program is free software; you can redistribute it and/or modify
   12 #       it under the terms of Version 2 of the GNU General Public License
   13 #       as published by the Free Software Foundation.
   14 #
   15 #       This program is distributed in the hope that it will be useful,
   16 #       but WITHOUT ANY WARRANTY; without even the implied warranty of
   17 #       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   18 #       GNU General Public License for more details.
   19 #
   20 #       You should have received a copy of the GNU General Public License
   21 #       along with this program; if not, write to the Free Software
   22 #       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   23 #
   24 
   25 setstatedir() {
   26     local statedir
   27     if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then
   28     statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
   29     fi
   30 
   31     [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
   32 
   33     if [ ! -x $STATEDIR/firewall ]; then
   34     if [ $PRODUCT = shorewall ]; then
   35         ${SBINDIR}/shorewall compile
   36     elif [ $PRODUCT = shorewall6 ]; then
   37         ${SBINDIR}/shorewall -6 compile
   38     fi
   39     fi
   40 }
   41 
   42 Debian_ppp() {
   43     NEWPRODUCTS=
   44     INTERFACE="$1"
   45 
   46     case $0 in
   47     /etc/ppp/ip-*)
   48         #
   49         # IPv4
   50         #
   51         for product in $PRODUCTS; do
   52         case $product in
   53             shorewall|shorewall-lite)
   54             NEWPRODUCTS="$NEWPRODUCTS $product";
   55             ;;
   56         esac
   57         done
   58         ;;
   59     /etc/ppp/ipv6-*)
   60         #
   61         # IPv6
   62         #
   63         for product in $PRODUCTS; do
   64         case $product in
   65             shorewall6|shorewall6-lite)
   66             NEWPRODUCTS="$NEWPRODUCTS $product";
   67             ;;
   68         esac
   69         done
   70         ;;
   71     *)
   72         exit 0
   73         ;;
   74     esac
   75 
   76     PRODUCTS="$NEWPRODUCTS"
   77 
   78     case $0 in
   79     *up/*)
   80         COMMAND=up
   81         ;;
   82     *)
   83         COMMAND=down
   84         ;;
   85     esac
   86 }
   87 
   88 IFUPDOWN=0
   89 PRODUCTS=
   90 
   91 #
   92 # The installer may alter this
   93 #
   94 . /usr/share/shorewall/shorewallrc
   95 
   96 if [ -f /etc/default/shorewall-init ]; then
   97     . /etc/default/shorewall-init
   98 elif [ -f /etc/sysconfig/shorewall-init ]; then
   99     . /etc/sysconfig/shorewall-init
  100 fi
  101 
  102 [ "$IFUPDOWN" = 1 -a -n "$PRODUCTS" ] || exit 0
  103 
  104 case $0 in
  105     /etc/ppp*)
  106     #
  107     # Debian ppp
  108     #
  109     Debian_ppp
  110     ;;
  111     *)
  112         #
  113         # Debian ifupdown system
  114         #
  115     INTERFACE="$IFACE"
  116 
  117     if [ "$MODE" = start ]; then
  118         COMMAND=up
  119     elif [ "$MODE" = stop ]; then
  120         COMMAND=down
  121     else
  122         exit 0
  123     fi
  124     ;;
  125 esac
  126 
  127 [ -n "$LOGFILE" ] || LOGFILE=/dev/null
  128 
  129 for PRODUCT in $PRODUCTS; do
  130     setstatedir
  131 
  132     if [ -x $VARLIB/$PRODUCT/firewall ]; then
  133     ( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
  134     fi
  135 done
  136 
  137 exit 0