"Fossies" - the Fresh Open Source Software Archive

Member "shorewall-init-5.2.8/ifupdown.suse.sh" (24 Sep 2020, 2988 Bytes) of package /linux/misc/shorewall/shorewall-init-5.2.8.tar.bz2:


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 and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "ifupdown.suse.sh": 5.2.3.6_vs_5.2.6.

    1 #!/bin/sh
    2 #
    3 # SuSE 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 https://shorewall.org
   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 SuSE_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 PHASE=''
  105 
  106 case $0 in
  107     /etc/ppp*)
  108         #
  109     # SUSE ppp
  110     #
  111     SuSE_ppp
  112     ;;
  113     
  114     *)
  115         #
  116         # SuSE ifupdown system
  117         #
  118     INTERFACE="$2"
  119 
  120     case $0 in
  121         *dispatcher.d*)
  122         INTERFACE="$1"
  123         case "$2" in
  124             up|down)
  125             COMMAND="$2"
  126             ;;
  127             *)
  128             exit 0
  129             ;;
  130         esac
  131         ;;
  132         *if-up.d*)
  133         COMMAND=up
  134         ;;
  135         *if-down.d*)
  136         COMMAND=down
  137         ;;
  138         *)
  139         exit 0
  140         ;;
  141     esac
  142     ;;
  143 esac
  144 
  145 [ -n "$LOGFILE" ] || LOGFILE=/dev/null
  146 
  147 for PRODUCT in $PRODUCTS; do
  148     setstatedir
  149 
  150     if [ -x $VARLIB/$PRODUCT/firewall ]; then
  151       ( ${VARLIB}/$PRODUCT/firewall -V0 $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
  152     fi
  153 done
  154 
  155 exit 0