"Fossies" - the Fresh Open Source Software Archive

Member "shorewall-init-5.2.3.3/uninstall.sh" (12 Apr 2019, 5383 Bytes) of package /linux/misc/shorewall/shorewall-init-5.2.3.3.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.2_vs_5.2.3.3.

    1 #!/bin/sh
    2 #
    3 # Script to back uninstall Shoreline Firewall Init
    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.3.3
   30 PRODUCT=shorewall-init
   31 Product="Shorewall Init"
   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     echo "  -n"
   41     exit $1
   42 }
   43 
   44 #
   45 # Change to the directory containing this script
   46 #
   47 cd "$(dirname $0)"
   48 
   49 #
   50 # Source common functions
   51 #
   52 . ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
   53 
   54 #
   55 # Parse the run line
   56 #
   57 finished=0
   58 configure=1
   59 
   60 while [ $finished -eq 0 ]; do
   61     option=$1
   62 
   63     case "$option" in
   64     -*)
   65         option=${option#-}
   66 
   67         while [ -n "$option" ]; do
   68         case $option in
   69             h)
   70             usage 0
   71             ;;
   72             v)
   73             echo "$Product Firewall Installer Version $VERSION"
   74             exit 0
   75             ;;
   76             n*)
   77             configure=0
   78             option=${option#n}
   79             ;;
   80             *)
   81             usage 1
   82             ;;
   83         esac
   84         done
   85 
   86         shift
   87         ;;
   88     *)
   89         finished=1
   90         ;;
   91     esac
   92 done
   93 
   94 #
   95 # Read the RC file
   96 #
   97 if [ $# -eq 0 ]; then
   98     if [ -f ./shorewallrc ]; then
   99         . ./shorewallrc || fatal_error "Can not load the RC file: ./shorewallrc"
  100     elif [ -f ~/.shorewallrc ]; then
  101         . ~/.shorewallrc || fatal_error "Can not load the RC file: ~/.shorewallrc"
  102     elif [ -f /usr/share/shorewall/shorewallrc ]; then
  103         . /usr/share/shorewall/shorewallrc || fatal_error "Can not load the RC file: /usr/share/shorewall/shorewallrc"
  104     else
  105     fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
  106     fi
  107 elif [ $# -eq 1 ]; then
  108     file=$1
  109     case $file in
  110     /*|.*)
  111         ;;
  112     *)
  113         file=./$file || exit 1
  114         ;;
  115     esac
  116 
  117     . $file || fatal_error "Can not load the RC file: $file"
  118 else
  119     usage 1
  120 fi
  121 
  122 if [ -f ${SHAREDIR}/$PRODUCT/version ]; then
  123     INSTALLED_VERSION="$(cat ${SHAREDIR}/$PRODUCT/version)"
  124     if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
  125     echo "WARNING: $Product Version $INSTALLED_VERSION is installed"
  126     echo "         and this is the $VERSION uninstaller."
  127     VERSION="$INSTALLED_VERSION"
  128     fi
  129 else
  130     echo "WARNING: $Product Version $VERSION is not installed"
  131     VERSION=""
  132 fi
  133 
  134 echo "Uninstalling $Product $VERSION"
  135 
  136 [ -n "$SANDBOX" ] && configure=0
  137 
  138 [ -n "${LIBEXEC:=${SHAREDIR}}" ]
  139 
  140 remove_file  ${SBINDIR}/$PRODUCT
  141 
  142 FIREWALL=${CONFDIR}/init.d/$PRODUCT
  143 
  144 if [ -f "$FIREWALL" ]; then
  145     if [ $configure -eq 1 ]; then
  146     if [ $HOST = openwrt ] ; then
  147         if /etc/init.d/$PRODUCT enabled; then
  148         /etc/init.d/$PRODUCT disable
  149         fi
  150     elif mywhich insserv ; then
  151             insserv -r $FIREWALL
  152     elif mywhich update-rc.d ; then
  153         update-rc.d ${PRODUCT} remove
  154     elif mywhich chkconfig ; then
  155         chkconfig --del $(basename $FIREWALL)
  156     fi
  157     fi
  158 
  159     remove_file $FIREWALL
  160 fi
  161 
  162 [ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
  163 
  164 if [ -n "$SERVICEDIR" ]; then
  165     [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
  166     remove_file $SERVICEDIR/${PRODUCT}.service
  167 fi
  168 
  169 if [ $HOST = openwrt ]; then
  170     [ "$(readlink -q ${SBINDIR}/ifup-local)"   = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifup-local
  171     [ "$(readlink -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifdown-local
  172 else
  173     [ "$(readlink -m -q ${SBINDIR}/ifup-local)"   = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifup-local
  174     [ "$(readlink -m -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/$PRODUCT ] && remove_file ${SBINDIR}/ifdown-local
  175 fi
  176 
  177 remove_file ${CONFDIR}/default/$PRODUCT
  178 remove_file ${CONFDIR}/sysconfig/$PRODUCT
  179 
  180 remove_file ${CONFDIR}/NetworkManager/dispatcher.d/01-shorewall
  181 
  182 remove_file ${CONFDIR}/network/if-up.d/shorewall
  183 remove_file ${CONFDIR}/network/if-down.d/shorewall
  184 remove_file ${CONFDIR}/network/if-post-down.d/shorewall
  185 
  186 remove_file ${CONFDIR}/sysconfig/network/if-up.d/shorewall
  187 remove_file ${CONFDIR}/sysconfig/network/if-down.d/shorewall
  188 
  189 if [ -d ${CONFDIR}/ppp ]; then
  190     for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
  191     remove_file ${CONFDIR}/ppp/$directory/shorewall
  192     done
  193 
  194     for file in if-up.local if-down.local; do
  195     if [ -f ${CONFDIR}/ppp/$file ]; then
  196         if grep -qF Shorewall-based ${CONFDIR}/ppp/$FILE; then
  197         remove_file ${CONFDIR}/ppp/$FILE
  198         fi
  199     fi
  200     done
  201 fi
  202 
  203 remove_directory ${SHAREDIR}/$PRODUCT
  204 remove_directory ${LIBEXECDIR}/$PRODUCT
  205 remove_file  ${CONFDIR}/logrotate.d/$PRODUCT
  206 
  207 #
  208 # Report Success
  209 #
  210 echo "$Product $VERSION Uninstalled"