"Fossies" - the Fresh Open Source Software Archive

Member "shorewall6-lite-5.2.8/uninstall.sh" (24 Sep 2020, 4966 Bytes) of package /linux/misc/shorewall/shorewall6-lite-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 Lite
    4 #
    5 #     (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
    6 #
    7 #       Shorewall documentation is available at http://shorewall.sourceforge.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.8
   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-lite.service ]; then
   48     PRODUCT=shorewall-lite
   49     Product="Shorewall Lite"
   50 else
   51     PRODUCT=shorewall6-lite
   52     Product="Shorewall6 Lite"
   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 ]; then
  146     ${SBINDIR}/$PRODUCT clear
  147     elif qt ip6tables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall6 ]; then
  148     ${SBINDIR}/$PRODUCT clear
  149     fi
  150 fi
  151 
  152 remove_file ${SBINDIR}/$PRODUCT
  153 
  154 if [ -h ${SHAREDIR}/$PRODUCT/init ]; then
  155     if [ $HOST = openwrt ]; then
  156     if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
  157         /etc/init.d/$PRODUCT disable
  158     fi
  159     
  160     FIREWALL=$(readlink ${SHAREDIR}/$PRODUCT/init)
  161     else
  162     FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
  163     fi
  164 elif [ -n "$INITFILE" ]; then
  165     FIREWALL=${INITDIR}/${INITFILE}
  166 fi
  167 
  168 if [ -f "$FIREWALL" ]; then
  169     if [ $configure -eq 1 ]; then
  170     if mywhich insserv ; then
  171             insserv -r $FIREWALL
  172     elif mywhich update-rc.d ; then
  173         update-rc.d ${PRODUCT} remove
  174     elif mywhich chkconfig ; then
  175         chkconfig --del $(basename $FIREWALL)
  176     fi
  177     fi
  178 
  179     remove_file $FIREWALL
  180 fi
  181 
  182 [ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
  183 
  184 if [ -n "$SERVICEDIR" ]; then
  185     [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
  186     remove_file $SERVICEDIR/${PRODUCT}.service
  187 fi
  188 
  189 remove_directory ${CONFDIR}/$PRODUCT
  190 remove_directory ${VARDIR}
  191 remove_directory ${SHAREDIR}/$PRODUCT
  192 remove_directory ${LIBEXECDIR}/$PRODUCT
  193 remove_file  ${CONFDIR}/logrotate.d/$PRODUCT
  194 
  195 if [ -n "$SYSCONFDIR" ]; then
  196     [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT}
  197 fi
  198 
  199 if [ -n "${MANDIR}" ]; then
  200     remove_file_with_wildcard ${MANDIR}/man5/${PRODUCT}\*
  201     remove_file_with_wildcard ${MANDIR}/man8/${PRODUCT}\*
  202 fi
  203 
  204 #
  205 # Report Success
  206 #
  207 echo "$Product $VERSION Uninstalled"