"Fossies" - the Fresh Open Source Software Archive

Member "shorewall-init-5.2.8/ifupdown.fedora.sh" (24 Sep 2020, 2613 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.fedora.sh": 5.2.3.6_vs_5.2.6.

    1 #!/bin/sh
    2 #
    3 # Redhat/Fedora/Centos/Foobar 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 # Get startup options (override default)
   26 OPTIONS=
   27 
   28 setstatedir() {
   29     local statedir
   30     if [ -f ${CONFDIR}/${PRODUCT}/vardir ]; then
   31     statedir=$( . /${CONFDIR}/${PRODUCT}/vardir && echo $VARDIR )
   32     fi
   33 
   34     [ -n "$statedir" ] && STATEDIR=${statedir} || STATEDIR=${VARLIB}/${PRODUCT}
   35 
   36     if [ ! -x $STATEDIR/firewall ]; then
   37     if [ $PRODUCT = shorewall ]; then
   38         ${SBINDIR}/shorewall compile
   39     elif [ $PRODUCT = shorewall6 ]; then
   40         ${SBINDIR}/shorewall -6 compile
   41     fi
   42     fi
   43 }
   44 
   45 IFUPDOWN=0
   46 PRODUCTS=
   47 
   48 #
   49 # The installer may alter this
   50 #
   51 . /usr/share/shorewall/shorewallrc
   52 
   53 if [ -f /etc/default/shorewall-init ]; then
   54     . /etc/default/shorewall-init
   55 elif [ -f /etc/sysconfig/shorewall-init ]; then
   56     . /etc/sysconfig/shorewall-init
   57 fi
   58 
   59 [ "$IFUPDOWN" = 1 -a -n "$PRODUCTS" ] || exit 0
   60 
   61 PHASE=''
   62 
   63 case $0 in
   64     /etc/ppp*)
   65     INTERFACE="$1"
   66 
   67     case $0 in
   68         *ip-up.local)
   69         COMMAND=up
   70         ;;
   71         *ip-down.local)
   72         COMMAND=down
   73         ;;
   74         *)
   75         exit 0
   76         ;;
   77     esac
   78     ;;
   79     *)
   80     #
   81     # RedHat ifup/down system
   82     #
   83     INTERFACE="$1"
   84     
   85     case $0 in 
   86         *ifup*)
   87         COMMAND=up
   88         ;;
   89         *ifdown*)
   90         COMMAND=down
   91         ;;
   92         *dispatcher.d*)
   93         case "$2" in
   94             up|down)
   95             COMMAND="$2"
   96             ;;
   97             *)
   98             exit 0
   99             ;;
  100         esac
  101         ;;
  102         *)
  103         exit 0
  104         ;;
  105     esac
  106     ;;
  107 esac
  108 
  109 [ -n "$LOGFILE" ] || LOGFILE=/dev/null
  110 
  111 for PRODUCT in $PRODUCTS; do
  112     setstatedir
  113 
  114     if [ -x "$STATEDIR/firewall" ]; then
  115       echo "`date --rfc-3339=seconds` $0: Executing $STATEDIR/firewall $OPTIONS $COMMAND $INTERFACE" >> $LOGFILE 2>&1
  116       ( $STATEDIR/firewall $OPTIONS $COMMAND $INTERFACE >> $LOGFILE 2>&1 ) || true
  117     fi
  118 done
  119 
  120 exit 0