"Fossies" - the Fresh Open Source Software Archive

Member "shorewall6-5.2.3.4/uninstall.sh" (27 Aug 2019, 5612 Bytes) of package /linux/misc/shorewall/shorewall6-5.2.3.4.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. See also the latest Fossies "Diffs" side-by-side code changes report for "uninstall.sh": 5.2.3.3_vs_5.2.3.4.

    1 #!/bin/sh
    2 #
    3 # Script to back uninstall Shoreline Firewall
    4 #
    5 #     (c) 2000-2017 - Tom Eastep (teastep@shorewall.net)
    6 #
    7 #       Shorewall documentation is available at http://www.shorewall.net
    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.3.4
   30 
   31 usage() # $1 = exit status
   32 {
   33     ME=$(basename $0)
   34     echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
   35     echo "where <option> is one of"
   36     echo "  -h"
   37     echo "  -v"
   38     echo "  -n"
   39     exit $1
   40 }
   41 
   42 #
   43 # Change to the directory containing this script
   44 #
   45 cd "$(dirname $0)"
   46 
   47 if [ -f shorewall.service ]; then
   48     PRODUCT=shorewall
   49     Product=Shorewall
   50 else
   51     PRODUCT=shorewall6
   52     Product=Shorewall6
   53 fi
   54 
   55 #
   56 # Source common functions
   57 #
   58 . ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
   59 
   60 #
   61 # Parse the run line
   62 #
   63 finished=0
   64 configure=1
   65 
   66 while [ $finished -eq 0 ]; do
   67     option=$1
   68 
   69     case "$option" in
   70     -*)
   71         option=${option#-}
   72 
   73         while [ -n "$option" ]; do
   74         case $option in
   75             h)
   76             usage 0
   77             ;;
   78             v)
   79             echo "$Product Firewall Uninstaller Version $VERSION"
   80             exit 0
   81             ;;
   82             n*)
   83             configure=0
   84             option=${option#n}
   85             ;;
   86             *)
   87             usage 1
   88             ;;
   89         esac
   90         done
   91 
   92         shift
   93         ;;
   94     *)
   95         finished=1
   96         ;;
   97     esac
   98 done
   99 
  100 #
  101 # Read the RC file
  102 #
  103 if [ $# -eq 0 ]; then
  104     if [ -f ./shorewallrc ]; then
  105         . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
  106     elif [ -f ~/.shorewallrc ]; then
  107         . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
  108     elif [ -f /usr/share/shorewall/shorewallrc ]; then
  109         . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
  110     else
  111     fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
  112     fi
  113 elif [ $# -eq 1 ]; then
  114     file=$1
  115     case $file in
  116     /*|.*)
  117         ;;
  118     *)
  119         file=./$file || exit 1
  120         ;;
  121     esac
  122 
  123     . $file || fatal_error "Can not load the RC file: $file"
  124 else
  125     usage 1
  126 fi
  127 
  128 if [ -f ${SHAREDIR}/$PRODUCT/version ]; then
  129     INSTALLED_VERSION="$(cat ${SHAREDIR}/$PRODUCT/version)"
  130     if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
  131     echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
  132     echo "         and this is the $VERSION uninstaller."
  133     VERSION="$INSTALLED_VERSION"
  134     fi
  135 else
  136     echo "WARNING: $Product Version $VERSION is not installed"
  137     VERSION=""
  138 fi
  139 
  140 echo "Uninstalling $Product $VERSION"
  141 
  142 [ -n "$SANDBOX" ] && configure=0
  143 
  144 if [ $configure -eq 1 ]; then
  145     if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall-lite ]; then
  146     ${SBINDIR}/$PRODUCT clear
  147     elif qt ip6tables -L shorewall6 -n && [ ! -f ${SBINDIR}/shorewall6-lite ]; then
  148     ${SBINDIR}/$PRODUCT clear
  149     fi
  150 fi
  151 
  152 remove_file ${SBINDIR}/$PRODUCT
  153 
  154 if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
  155     FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
  156 elif [ -n "$INITFILE" ]; then
  157     FIREWALL=${INITDIR}/${INITFILE}
  158 fi
  159 
  160 if [ -f "$FIREWALL" ]; then
  161     if [ $configure -eq 1 ]; then
  162     if mywhich insserv ; then
  163             insserv -r $FIREWALL
  164     elif mywhich update-rc.d ; then
  165         update-rc.d ${PRODUCT} remove
  166     elif mywhich chkconfig ; then
  167         chkconfig --del $(basename $FIREWALL)
  168     fi
  169     fi
  170 
  171     remove_file $FIREWALL
  172 fi
  173 
  174 [ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
  175 
  176 if [ -n "$SERVICEDIR" ]; then
  177     [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
  178     remove_file $SERVICEDIR/${PRODUCT}.service
  179 fi
  180 
  181 remove_file ${SHAREDIR}/$PRODUCT/version
  182 remove_directory ${CONFDIR}/$PRODUCT
  183 
  184 if [ -n "$SYSCONFDIR" ]; then
  185     [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT}
  186 fi
  187 
  188 remove_directory ${VARDIR}
  189 [ ${LIBEXECDIR} = ${SHAREDIR} ] || remove_directory ${LIBEXECDIR}/$PRODUCT
  190 remove_directory ${SHAREDIR}/$PRODUCT/configfiles
  191 remove_file_with_wildcard  ${SHAREDIR}/$PRODUCT/module\*
  192 remove_file  ${SHAREDIR}/$PRODUCT/helpers
  193 remove_file_with_wildcard  ${SHAREDIR}/$PRODUCT/action\*
  194 remove_file_with_wildcard  ${SHAREDIR}/$PRODUCT/macro.\*
  195 
  196 if [ $PRODUCT = shorewall ]; then
  197     remove_file_with_wildcard ${PERLLIBDIR}/$Product/\*
  198     remove_directory ${SHAREDIR}/$PRODUCT/Samples
  199     remove_directory ${SHAREDIR}/$PRODUCT/$Product
  200     remove_file  ${SHAREDIR}/$PRODUCT/lib.cli-std
  201     remove_file  ${SHAREDIR}/$PRODUCT/lib.runtime
  202     remove_file  ${SHAREDIR}/$PRODUCT/compiler.pl
  203     remove_file_with_wildcard  ${SHAREDIR}/$PRODUCT/prog.\*
  204     remove_file  ${SHAREDIR}/$PRODUCT/init
  205 else
  206     remove_directory ${SHAREDIR}/$PRODUCT
  207 fi
  208 
  209 for f in ${MANDIR}/man5/${PRODUCT}* ${MANDIR}/man8/${PRODUCT}*; do
  210     case $f in
  211     shorewall[6]-lite*)
  212         ;;
  213     *)
  214         remove_file $f
  215         ;;
  216     esac
  217 done
  218 
  219 remove_file  ${CONFDIR}/logrotate.d/$PRODUCT
  220 
  221 [ -n "$SYSTEMD" ] && remove_file ${SYSTEMD}/${PRODUCT}.service
  222 
  223 #
  224 # Report Success
  225 #
  226 echo "$Product $VERSION Uninstalled"