"Fossies" - the Fresh Open Source Software Archive

Member "shorewall-core-5.2.8/uninstall.sh" (24 Sep 2020, 3407 Bytes) of package /linux/misc/shorewall/shorewall-core-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 latest Fossies "Diffs" side-by-side code changes report for "uninstall.sh": 5.2.7_vs_5.2.8.

    1 #!/bin/sh
    2 #
    3 # Script to back uninstall Shoreline Firewall Core Modules
    4 #
    5 #     (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
    6 #
    7 #       Shorewall documentation is available at https://shorewall.org
    8 #
    9 #       This program is part of Shorewall.
   10 #
   11 #   This program is free software; you can redistribute it and/or modify
   12 #   it under the terms of the GNU General Public License as published by the
   13 #       Free Software Foundation, either version 2 of the license or, at your
   14 #       option, any later version.
   15 #
   16 #   This program is distributed in the hope that it will be useful,
   17 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
   18 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
   19 #   GNU General Public License for more details.
   20 #
   21 #   You should have received a copy of the GNU General Public License
   22 #   along with this program; if not, see <http://www.gnu.org/licenses/>.
   23 #
   24 #    Usage:
   25 #
   26 #       You may only use this script to uninstall the version
   27 #       shown below. Simply run this script to remove Shorewall Firewall
   28 
   29 VERSION=5.2.8
   30 PRODUCT=shorewall-core
   31 Product="Shorewall Core"
   32 
   33 usage() # $1 = exit status
   34 {
   35     ME=$(basename $0)
   36     echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
   37     echo "where <option> is one of"
   38     echo "  -h"
   39     echo "  -v"
   40     exit $1
   41 }
   42 
   43 #
   44 # Change to the directory containing this script
   45 #
   46 cd "$(dirname $0)"
   47 
   48 #
   49 # Source common functions
   50 #
   51 . ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
   52 
   53 #
   54 # Parse the run line
   55 #
   56 finished=0
   57 
   58 while [ $finished -eq 0 ]; do
   59     option=$1
   60 
   61     case "$option" in
   62     -*)
   63         option=${option#-}
   64 
   65         while [ -n "$option" ]; do
   66         case $option in
   67             h)
   68             usage 0
   69             ;;
   70             v)
   71             echo "$Product Firewall Uninstaller Version $VERSION"
   72             exit 0
   73             ;;
   74             *)
   75             usage 1
   76             ;;
   77         esac
   78         done
   79 
   80         shift
   81         ;;
   82     *)
   83         finished=1
   84         ;;
   85     esac
   86 done
   87 
   88 #
   89 # Read the RC file
   90 #
   91 if [ $# -eq 0 ]; then
   92     if [ -f ./shorewallrc ]; then
   93         . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
   94     elif [ -f ~/.shorewallrc ]; then
   95         . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
   96     elif [ -f /usr/share/shorewall/shorewallrc ]; then
   97         . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
   98     else
   99     fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
  100     fi
  101 elif [ $# -eq 1 ]; then
  102     file=$1
  103     case $file in
  104     /*|.*)
  105         ;;
  106     *)
  107         file=./$file || exit 1
  108         ;;
  109     esac
  110 
  111     . $file || fatal_error "Can not load the RC file: $file"
  112 else
  113     usage 1
  114 fi
  115 
  116 if [ -f ${SHAREDIR}/shorewall/coreversion ]; then
  117     INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall/coreversion)"
  118     if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
  119     echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
  120     echo "         and this is the $VERSION uninstaller."
  121     VERSION="$INSTALLED_VERSION"
  122     fi
  123 else
  124     echo "WARNING: $Product Version $VERSION is not installed"
  125     VERSION=""
  126 fi
  127 
  128 echo "Uninstalling $Product $VERSION"
  129 
  130 if [ -n "${MANDIR}" ]; then
  131     remove_file_with_wildcard ${MANDIR}/man5/shorewall\*
  132     remove_file_with_wildcard ${MANDIR}/man8/shorewall\*
  133 fi
  134 
  135 remove_directory ${SHAREDIR}/shorewall
  136 remove_file ~/.shorewallrc
  137 remove_file ${SBINDIR}/shorewall
  138 
  139 #
  140 # Report Success
  141 #
  142 echo "$Product $VERSION Uninstalled"