"Fossies" - the Fresh Open Source Software Archive

Member "aif-2.1.1/share/arno-iptables-firewall/aif-job-execute" (16 Sep 2020, 3743 Bytes) of package /linux/privat/aif-2.1.1.tar.gz:


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 latest Fossies "Diffs" side-by-side code changes report for "aif-job-execute": 2.1.0_vs_2.1.1.

    1 #!/bin/sh
    2 
    3 # ------------------------------------------------------------------------------
    4 #                         -= Arno's Iptables Firewall(AIF) =-
    5 #              Single- & multi-homed firewall script with DSL/ADSL support
    6 #
    7 #                           ~ In memory of my dear father ~
    8 #
    9 # (C) Copyright 2001-2020 by Arno van Amersfoort & Lonnie Abelbeck
   10 # Homepage              : https://rocky.eld.leidenuniv.nl/
   11 # Email                 : a r n o v a AT r o c k y DOT e l d DOT l e i d e n u n i v DOT n l
   12 #                         (note: you must remove all spaces and substitute the @ and the .
   13 #                         at the proper locations!)
   14 # ------------------------------------------------------------------------------
   15 # This program is free software; you can redistribute it and/or
   16 # modify it under the terms of the GNU General Public License
   17 # version 2 as published by the Free Software Foundation.
   18 
   19 # This program is distributed in the hope that it will be useful,
   20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   22 # GNU General Public License for more details.
   23 
   24 # You should have received a copy of the GNU General Public License
   25 # along with this program; if not, write to the Free Software
   26 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
   27 # ------------------------------------------------------------------------------
   28 
   29 # Location of the main configuration file for the firewall
   30 ##########################################################
   31 CONF_FILE=/etc/arno-iptables-firewall/firewall.conf
   32 
   33 # Define some global variables
   34 OPT_INDENT=""
   35 JOB_HELPER_PATH=""
   36 
   37 # Check sanity of environment
   38 sanity_check()
   39 {
   40   if [ -z "$JOB_HELPER_PATH" ]; then
   41     echo "** ERROR: Missing job-helper argument!" >&2
   42     return 1
   43   fi
   44 
   45   return 0
   46 }
   47 
   48 
   49 show_help()
   50 {
   51   echo "Usage: $(basename $0) [options] {plugin_helper_path}" >&2
   52   echo "" >&2
   53   echo "Options:" >&2
   54   echo "--help|-h                   - Print this help" >&2
   55   echo "--indent=\'{indent}\'       - Use {indent} for line indention" >&2
   56   echo ""
   57 }
   58 
   59 
   60 process_commandline()
   61 {
   62   # Check arguments
   63   while [ -n "$1" ]; do
   64     ARG="$1"
   65     ARGNAME=`echo "$ARG" |cut -d= -f1`
   66     ARGVAL=`echo "$ARG" |cut -d= -f2 -s`
   67 
   68     case "$ARGNAME" in
   69               --help|-h) show_help;
   70                          exit 0
   71                          ;;
   72             --indent|-i) OPT_INDENT="$ARGVAL"
   73                          ;;
   74                      -*) echo "ERROR: Bad argument \"$ARG\"" >&2
   75                          show_help
   76                          exit 1
   77                          ;;
   78                       *) JOB_HELPER_PATH="$ARG"
   79                          ;;
   80     esac
   81 
   82     shift # Next argument
   83   done
   84 }
   85 
   86 
   87 ############
   88 # Mainline #
   89 ############
   90 
   91 process_commandline "$@"
   92 
   93 if [ ! -f "$CONF_FILE" ]; then
   94   echo "ERROR: Could not read configuration file ($CONF_FILE)!" >&2
   95   echo "" >&2
   96   exit 2
   97 fi
   98 
   99 # Source config file
  100 . "$CONF_FILE"
  101 
  102 # Check if the environment file exists and if so, load it
  103 #########################################################
  104 ENV_FILE="${0%/*}/environment"
  105 
  106 if [ ! -f "$ENV_FILE" ]; then
  107   echo "** ERROR: Unable to locate environment file \"$ENV_FILE\"!" >&2
  108   exit 2
  109 fi
  110 
  111 # Source environment file
  112 . "$ENV_FILE"
  113 
  114 # Only proceed if environment ok
  115 if ! sanity_check; then
  116   exit 2
  117 fi
  118 
  119 # Reset to 0, just in case
  120 PLUGIN_RET_VAL=0
  121 
  122 LOCK_NAME="$(basename "$JOB_HELPER_PATH")"
  123 
  124 # Enter critical section (single lock)
  125 if ! lock_enter_single $LOCK_NAME; then
  126   exit 2
  127 fi
  128 
  129 # Set indent
  130 INDENT="$OPT_INDENT"
  131 
  132 # Source helper
  133 . "$JOB_HELPER_PATH"
  134 
  135 # Leave critical section
  136 if ! lock_leave $LOCK_NAME; then
  137   exit 2
  138 fi
  139 
  140 # Return helper's return code
  141 exit $PLUGIN_RET_VAL