2011-04-16 17:31:46 +02:00
|
|
|
\#!/bin/sh
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
# Script to back uninstall Shoreline Firewall
|
|
|
|
#
|
|
|
|
# This program is under GPL [http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt]
|
|
|
|
#
|
2011-05-23 19:06:56 +02:00
|
|
|
# (c) 2000-2011 - Tom Eastep (teastep@shorewall.net)
|
2010-05-17 00:35:22 +02:00
|
|
|
#
|
|
|
|
# Shorewall documentation is available at http://shorewall.sourceforge.net
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of Version 2 of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# You may only use this script to uninstall the version
|
|
|
|
# shown below. Simply run this script to remove Shorewall Firewall
|
|
|
|
|
2011-07-13 16:10:07 +02:00
|
|
|
VERSION=xxx #The Build script inserts the actual version
|
2010-05-17 00:35:22 +02:00
|
|
|
|
|
|
|
usage() # $1 = exit status
|
|
|
|
{
|
|
|
|
ME=$(basename $0)
|
2012-03-30 21:02:25 +02:00
|
|
|
echo "usage: $ME [ <shorewallrc file> ]"
|
2010-05-17 00:35:22 +02:00
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
qt()
|
|
|
|
{
|
|
|
|
"$@" >/dev/null 2>&1
|
|
|
|
}
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
split() {
|
|
|
|
local ifs
|
|
|
|
ifs=$IFS
|
|
|
|
IFS=:
|
|
|
|
set -- $1
|
|
|
|
echo $*
|
|
|
|
IFS=$ifs
|
|
|
|
}
|
|
|
|
|
|
|
|
mywhich() {
|
|
|
|
local dir
|
|
|
|
|
|
|
|
for dir in $(split $PATH); do
|
|
|
|
if [ -x $dir/$1 ]; then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
return 2
|
|
|
|
}
|
|
|
|
|
2010-05-17 00:35:22 +02:00
|
|
|
remove_file() # $1 = file to restore
|
|
|
|
{
|
|
|
|
if [ -f $1 -o -L $1 ] ; then
|
|
|
|
rm -f $1
|
|
|
|
echo "$1 Removed"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-04-02 15:48:23 +02:00
|
|
|
#
|
|
|
|
# Read the RC file
|
|
|
|
#
|
2012-03-30 21:02:25 +02:00
|
|
|
if [ $# -eq 0 ]; then
|
2012-04-02 15:48:23 +02:00
|
|
|
if [ -f ./shorewallrc ]; then
|
|
|
|
. ./shorewallrc
|
|
|
|
elif [ -f ~/.shorewallrc ]; then
|
|
|
|
. ~/.shorewallrc || exit 1
|
|
|
|
file=./.shorewallrc
|
|
|
|
elif [ -f /usr/share/shorewall/shorewallrc ]; then
|
|
|
|
. /usr/share/shorewall/shorewallrc
|
|
|
|
else
|
|
|
|
fatal_error "No configuration file specified and /usr/share/shorewall/shorewallrc not found"
|
|
|
|
fi
|
2012-03-30 21:02:25 +02:00
|
|
|
elif [ $# -eq 1 ]; then
|
|
|
|
file=$1
|
2012-04-02 15:48:23 +02:00
|
|
|
case $file in
|
|
|
|
/*|.*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
file=./$file
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
. $file || exit 1
|
2012-03-24 21:05:39 +01:00
|
|
|
else
|
2012-03-30 21:02:25 +02:00
|
|
|
usage 1
|
|
|
|
fi
|
2012-03-24 21:05:39 +01:00
|
|
|
|
|
|
|
if [ -f ${SHAREDIR}/shorewall-init/version ]; then
|
|
|
|
INSTALLED_VERSION="$(cat ${SHAREDIR}/shorewall-init/version)"
|
2010-05-17 00:35:22 +02:00
|
|
|
if [ "$INSTALLED_VERSION" != "$VERSION" ]; then
|
2010-05-19 00:42:26 +02:00
|
|
|
echo "WARNING: Shorewall Init Version $INSTALLED_VERSION is installed"
|
2010-05-17 00:35:22 +02:00
|
|
|
echo " and this is the $VERSION uninstaller."
|
|
|
|
VERSION="$INSTALLED_VERSION"
|
|
|
|
fi
|
|
|
|
else
|
2010-05-19 00:42:26 +02:00
|
|
|
echo "WARNING: Shorewall Init Version $VERSION is not installed"
|
2010-05-17 00:35:22 +02:00
|
|
|
VERSION=""
|
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ -n "${LIBEXEC:=${SHAREDIR}}" ]
|
2011-04-03 18:56:30 +02:00
|
|
|
|
2010-05-19 00:42:26 +02:00
|
|
|
echo "Uninstalling Shorewall Init $VERSION"
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
INITSCRIPT=${CONFDIR}/init.d/shorewall-init
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -f "$INITSCRIPT" ]; then
|
|
|
|
if mywhich updaterc.d ; then
|
2011-01-16 22:09:02 +01:00
|
|
|
updaterc.d shorewall-init remove
|
2012-03-24 21:05:39 +01:00
|
|
|
elif mywhich insserv ; then
|
2010-05-19 00:42:26 +02:00
|
|
|
insserv -r $INITSCRIPT
|
2012-03-24 21:05:39 +01:00
|
|
|
elif mywhich chkconfig ; then
|
2010-05-19 00:42:26 +02:00
|
|
|
chkconfig --del $(basename $INITSCRIPT)
|
2012-03-24 21:05:39 +01:00
|
|
|
elif mywhich systemctl ; then
|
2011-08-23 23:07:44 +02:00
|
|
|
systemctl disable shorewall-init
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-19 00:42:26 +02:00
|
|
|
remove_file $INITSCRIPT
|
2010-05-17 00:35:22 +02:00
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ "$(readlink -m -q ${SBINDIR}/ifup-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifup-local
|
|
|
|
[ "$(readlink -m -q ${SBINDIR}/ifdown-local)" = ${SHAREDIR}/shorewall-init ] && remove_file ${SBINDIR}/ifdown-local
|
|
|
|
|
|
|
|
remove_file ${CONFDIR}/default/shorewall-init
|
|
|
|
remove_file ${CONFDIR}/sysconfig/shorewall-init
|
2010-05-19 00:42:26 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
remove_file ${CONFDIR}/NetworkManager/dispatcher.d/01-shorewall
|
2010-05-19 00:42:26 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
remove_file ${CONFDIR}/network/if-up.d/shorewall
|
|
|
|
remove_file ${CONFDIR}/network/if-down.d/shorewall
|
2010-05-19 00:42:26 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
remove_file ${CONFDIR}/sysconfig/network/if-up.d/shorewall
|
|
|
|
remove_file ${CONFDIR}/sysconfig/network/if-down.d/shorewall
|
2010-05-19 00:42:26 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
[ -n "$SYSTEMD" ] && remove_file ${SYSTEMD}/shorewall.service
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
if [ -d ${CONFDIR}/ppp ]; then
|
2010-12-04 21:06:05 +01:00
|
|
|
for directory in ip-up.d ip-down.d ipv6-up.d ipv6-down.d; do
|
2012-03-24 21:05:39 +01:00
|
|
|
remove_file ${CONFDIR}/ppp/$directory/shorewall
|
2010-12-04 21:06:05 +01:00
|
|
|
done
|
2010-12-05 18:11:08 +01:00
|
|
|
|
|
|
|
for file in if-up.local if-down.local; do
|
2012-03-24 21:05:39 +01:00
|
|
|
if fgrep -q Shorewall-based ${CONFDIR}/ppp/$FILE; then
|
|
|
|
remove_file ${CONFDIR}/ppp/$FILE
|
2010-12-05 18:11:08 +01:00
|
|
|
fi
|
|
|
|
done
|
2010-12-04 21:06:05 +01:00
|
|
|
fi
|
|
|
|
|
2012-03-24 21:05:39 +01:00
|
|
|
rm -rf ${SHAREDIR}/shorewall-init
|
2011-04-17 20:20:26 +02:00
|
|
|
rm -rf ${LIBEXEC}/shorewall-init
|
2010-05-17 00:35:22 +02:00
|
|
|
|
2010-05-19 00:42:26 +02:00
|
|
|
echo "Shorewall Init Uninstalled"
|
2010-05-17 00:35:22 +02:00
|
|
|
|
|
|
|
|