Unify the uninstallers

- Clean up code
 - Use the .service suffix

Signed-off-by: Matt Darfeuille <matdarf@gmail.com>
Signed-off-by: Tom Eastep <teastep@shorewall.net>
This commit is contained in:
Matt Darfeuille 2017-02-20 18:52:00 +01:00 committed by Tom Eastep
parent f48b2e715f
commit c58efe7698
No known key found for this signature in database
GPG Key ID: 96E6B3F2423A4D10
6 changed files with 157 additions and 77 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Script to back uninstall Shoreline Firewall
# Script to back uninstall Shoreline Firewall Core Modules
#
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
#
@ -26,14 +26,17 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
PRODUCT="shorewall-core"
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall-core
Product="Shorewall Core"
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]"
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
exit $1
}
@ -47,6 +50,41 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
while [ $finished -eq 0 ]; do
option=$1
case "$option" in
-*)
option=${option#-}
while [ -n "$option" ]; do
case $option in
h)
usage 0
;;
v)
echo "$Product Firewall Uninstaller Version $VERSION"
exit 0
;;
*)
usage 1
;;
esac
done
shift
;;
*)
finished=1
;;
esac
done
#
# Read the RC file
#
@ -92,6 +130,7 @@ echo "Uninstalling $Product $VERSION"
rm -rf ${SHAREDIR}/shorewall
rm -f ~/.shorewallrc
echo "$Product Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Script to back uninstall Shoreline Firewall
# Script to back uninstall Shoreline Firewall Init
#
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
#
@ -26,14 +26,18 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall-init
Product="Shorewall Init"
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]"
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
echo " -n"
exit $1
}
@ -47,6 +51,9 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
configure=1
@ -124,35 +131,35 @@ else
VERSION=""
fi
[ -n "${LIBEXEC:=${SHAREDIR}}" ]
echo "Uninstalling $Product $VERSION"
[ -n "$SANDBOX" ] && configure=0
INITSCRIPT=${CONFDIR}/init.d/$PRODUCT
[ -n "${LIBEXEC:=${SHAREDIR}}" ]
if [ -f "$INITSCRIPT" ]; then
rm -f ${SBINDIR}/$PRODUCT
FIREWALL=${CONFDIR}/init.d/$PRODUCT
if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then
if [ $HOST = openwrt ]; then
if /etc/init.d/$PRODUCT enabled; then
/etc/init.d/$PRODUCT disable
fi
elif mywhich updaterc.d ; then
updaterc.d $PRODUCT remove
updaterc.d ${PRODUCT} remove
elif mywhich insserv ; then
insserv -r $INITSCRIPT
insserv -r $FIREWALL
elif mywhich chkconfig ; then
chkconfig --del $(basename $INITSCRIPT)
chkconfig --del $(basename $FIREWALL)
fi
fi
remove_file $INITSCRIPT
remove_file $FIREWALL
fi
if [ -z "${SERVICEDIR}" ]; then
SERVICEDIR="$SYSTEMD"
fi
[ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
@ -193,10 +200,11 @@ if [ -d ${CONFDIR}/ppp ]; then
done
fi
rm -f ${SBINDIR}/$PRODUCT
rm -rf ${SHAREDIR}/$PRODUCT
rm -rf ${LIBEXECDIR}/$PRODUCT
rm -f ${CONFDIR}/logrotate.d/$PRODUCT
echo "$Product Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#
# Script to back uninstall Shoreline Firewall
# Script to back uninstall Shoreline Firewall Lite
#
# (c) 2000-2016 - Tom Eastep (teastep@shorewall.net)
#
@ -26,7 +26,7 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall-lite
Product="Shorewall Lite"
@ -51,6 +51,9 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
configure=1
@ -67,7 +70,7 @@ while [ $finished -eq 0 ]; do
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
echo "$Product Firewall Uninstaller Version $VERSION"
exit 0
;;
n*)
@ -134,10 +137,12 @@ echo "Uninstalling $Product $VERSION"
if [ $configure -eq 1 ]; then
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall ]; then
$PRODUCT clear
${SBINDIR}/$PRODUCT clear
fi
fi
rm -f ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
if [ $HOST = openwrt ]; then
if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
@ -155,7 +160,7 @@ fi
if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then
if mywhich updaterc.d ; then
updaterc.d $PRODUCT remove
updaterc.d ${PRODUCT} remove
elif mywhich insserv ; then
insserv -r $FIREWALL
elif mywhich chkconfig ; then
@ -166,26 +171,29 @@ if [ -f "$FIREWALL" ]; then
remove_file $FIREWALL
fi
[ -z "$SERVICEDIR" ] && SERVICEDIR="$SYSTEMD"
[ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/${PRODUCT}.service
fi
rm -f ${SBINDIR}/$PRODUCT
rm -rf ${CONFDIR}/$PRODUCT
rm -rf ${VARDIR}
rm -rf ${SHAREDIR}/$PRODUCT
rm -rf ${LIBEXECDIR}/$PRODUCT
rm -f ${CONFDIR}/logrotate.d/$PRODUCT
rm -f ${SYSCONFDIR}/$PRODUCT
if [ -n "$SYSCONFDIR" ]; then
[ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT}
fi
if [ -n "${MANDIR}" ]; then
rm -f ${MANDIR}/man5/${PRODUCT}*
rm -f ${MANDIR}/man8/${PRODUCT}*
fi
echo "$Product Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@ -26,7 +26,7 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall
Product=Shorewall
@ -51,6 +51,9 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
configure=1
@ -67,7 +70,7 @@ while [ $finished -eq 0 ]; do
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
echo "$Product Firewall Uninstaller Version $VERSION"
exit 0
;;
n*)
@ -128,14 +131,13 @@ else
VERSION=""
fi
echo "Uninstalling $Product $VERSION"
[ -n "$SANDBOX" ] && configure=0
if [ $configure -eq 1 ]; then
if qt iptables -L shorewall -n && [ ! -f ${SBINDIR}/shorewall-lite ]; then
$PRODUCT clear
${SBINDIR}/$PRODUCT clear
fi
fi
@ -161,11 +163,10 @@ if [ -f "$FIREWALL" ]; then
remove_file $FIREWALL
fi
if [ -z "${SERVICEDIR}" ]; then
SERVICEDIR="$SYSTEMD"
fi
[ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/${PRODUCT}.service
fi
@ -176,12 +177,12 @@ if [ -n "$SYSCONFDIR" ]; then
[ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT}
fi
rm -rf ${VARDIR}/$PRODUCT
rm -rf ${VARDIR}
rm -rf ${PERLLIBDIR}/$Product/*
[ ${LIBEXECDIR} = ${SHAREDIR} ] || rm -rf ${LIBEXECDIR}/$PRODUCT
rm -rf ${SHAREDIR}/$PRODUCT/configfiles/
rm -rf ${SHAREDIR}/$PRODUCT/Samples/
rm -rf ${SHAREDIR}/$PRODUCT/$Product/
rm -rf ${SHAREDIR}/$PRODUCT/configfiles
rm -rf ${SHAREDIR}/$PRODUCT/Samples
rm -rf ${SHAREDIR}/$PRODUCT/$Product
rm -f ${SHAREDIR}/$PRODUCT/lib.cli-std
rm -f ${SHAREDIR}/$PRODUCT/lib.runtime
rm -f ${SHAREDIR}/$PRODUCT/compiler.pl
@ -204,8 +205,9 @@ done
rm -f ${CONFDIR}/logrotate.d/$PRODUCT
[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service
echo "$Product Uninstalled"
[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@ -26,14 +26,18 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall6-lite
Product="Shorewall6 Lite"
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]"
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
echo " -n"
exit $1
}
@ -47,6 +51,9 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
configure=1
@ -63,7 +70,7 @@ while [ $finished -eq 0 ]; do
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
echo "$Product Firewall Uninstaller Version $VERSION"
exit 0
;;
n*)
@ -134,7 +141,9 @@ if [ $configure -eq 1 ]; then
fi
fi
if [ -f ${SHAREDIR}/$PRODUCT/init ]; then
rm -f ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
if [ $HOST = openwrt ]; then
if [ $configure -eq 1 ] && /etc/init.d/$PRODUCT enabled; then
/etc/init.d/$PRODUCT disable
@ -151,37 +160,40 @@ fi
if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then
if mywhich updaterc.d ; then
updaterc.d $PRODUCT remove
updaterc.d ${PRODUCT} remove
elif mywhich insserv ; then
insserv -r $FIREWALL
elif mywhich chkconfig ; then
chkconfig --del $(basename $FIREWALL)
elif mywhich systemctl ; then
systemctl disable $PRODUCT
fi
fi
remove_file $FIREWALL
fi
[ -z "$SERVICEDIR" ] && SERVICEDIR="$SYSTEMD"
[ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/${PRODUCT}.service
fi
rm -f ${SBINDIR}/$PRODUCT
rm -rf ${CONFDIR}/$PRODUCT
rm -rf ${VARDIR}
rm -rf ${SHAREDIR}/$PRODUCT
rm -rf ${LIBEXECDIR}/$PRODUCT
rm -f ${CONFDIR}/logrotate.d/$PRODUCT
rm -f ${SYSCONFDIR}/$PRODUCT
if [ -n "$SYSCONFDIR" ]; then
[ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT}
fi
if [ -n "${MANDIR}" ]; then
rm -f ${MANDIR}/man5/${PRODUCT}*
rm -f ${MANDIR}/man8/${PRODUCT}*
fi
echo "$Product Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"

View File

@ -26,14 +26,18 @@
# You may only use this script to uninstall the version
# shown below. Simply run this script to remove Shorewall Firewall
VERSION=xxx #The Build script inserts the actual version
VERSION=xxx # The Build script inserts the actual version
PRODUCT=shorewall6
Product=Shorewall6
usage() # $1 = exit status
{
ME=$(basename $0)
echo "usage: $ME [ <shorewallrc file> ]"
echo "usage: $ME [ <option> ] [ <shorewallrc file> ]"
echo "where <option> is one of"
echo " -h"
echo " -v"
echo " -n"
exit $1
}
@ -47,6 +51,9 @@ cd "$(dirname $0)"
#
. ./lib.uninstaller || { echo "ERROR: Can not load common functions." >&2; exit 1; }
#
# Parse the run line
#
finished=0
configure=1
@ -63,7 +70,7 @@ while [ $finished -eq 0 ]; do
usage 0
;;
v)
echo "$Product Firewall Installer Version $VERSION"
echo "$Product Firewall Uninstaller Version $VERSION"
exit 0
;;
n*)
@ -134,6 +141,8 @@ if [ $configure -eq 1 ]; then
fi
fi
rm -f ${SBINDIR}/$PRODUCT
if [ -L ${SHAREDIR}/$PRODUCT/init ]; then
FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init)
elif [ -n "$INITFILE" ]; then
@ -143,7 +152,7 @@ fi
if [ -f "$FIREWALL" ]; then
if [ $configure -eq 1 ]; then
if mywhich updaterc.d ; then
updaterc.d $PRODUCT remove
updaterc.d ${PRODUCT} remove
elif mywhich insserv ; then
insserv -r $FIREWALL
elif mywhich chkconfig ; then
@ -154,10 +163,10 @@ if [ -f "$FIREWALL" ]; then
remove_file $FIREWALL
fi
[ -n "$SERVICEDIR" ] || SERVICEDIR=${SYSTEMD}
[ -z "${SERVICEDIR}" ] && SERVICEDIR="$SYSTEMD"
if [ -n "$SERVICEDIR" ]; then
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}
[ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service
rm -f $SERVICEDIR/${PRODUCT}.service
fi
@ -168,24 +177,26 @@ if [ -n "$SYSCONFDIR" ]; then
[ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT}
fi
rm -f ${SBINDIR}/$PRODUCT
rm -rf ${CONFDIR}/$PRODUCT
rm -rf ${VARDIR}
rm -rf ${LIBEXECDIR}/$PRODUCT
rm -rf ${SHAREDIR}/$PRODUCT
for f in ${MANDIR}/man5/${PRODUCT}* ${SHAREDIR}/man/man8/${PRODUCT}*; do
for f in ${MANDIR}/man5/${PRODUCT}* ${MANDIR}/man8/${PRODUCT}*; do
case $f in
shorewall6-lite*)
;;
*)
rm -f $f
;;
esac
done
rm -f ${CONFDIR}/logrotate.d/$PRODUCT
[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service
echo "$Product Uninstalled"
#
# Report Success
#
echo "$Product $VERSION Uninstalled"