- Clean up code
 - Use the .service suffix

Signed-off-by: Matt Darfeuille <[email protected]>
---
 Shorewall-core/uninstall.sh  | 55 +++++++++++++++++++++++++++++++++++++-------
 Shorewall-init/uninstall.sh  | 44 ++++++++++++++++++++---------------
 Shorewall-lite/uninstall.sh  | 32 ++++++++++++++++----------
 Shorewall/uninstall.sh       | 34 ++++++++++++++-------------
 Shorewall6-lite/uninstall.sh | 36 +++++++++++++++++++----------
 Shorewall6/uninstall.sh      | 33 +++++++++++++++++---------
 6 files changed, 157 insertions(+), 77 deletions(-)

diff --git a/Shorewall-core/uninstall.sh b/Shorewall-core/uninstall.sh
index ef0f3dd..bef7ce1 100755
--- a/Shorewall-core/uninstall.sh
+++ b/Shorewall-core/uninstall.sh
@@ -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 ([email protected])
 #
@@ -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
 }
 
@@ -48,6 +51,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
 #
 if [ $# -eq 0 ]; then
@@ -92,6 +130,7 @@ echo "Uninstalling $Product $VERSION"
 rm -rf ${SHAREDIR}/shorewall
 rm -f ~/.shorewallrc
 
-echo "$Product Uninstalled"
-
-
+#
+# Report Success
+#
+echo "$Product $VERSION Uninstalled"
diff --git a/Shorewall-init/uninstall.sh b/Shorewall-init/uninstall.sh
index e2f64da..6539fa0 100755
--- a/Shorewall-init/uninstall.sh
+++ b/Shorewall-init/uninstall.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Script to back uninstall Shoreline Firewall
+# Script to back uninstall Shoreline Firewall Init
 #
 #     (c) 2000-2016 - Tom Eastep ([email protected])
 #
@@ -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}}" ]
+
+rm -f  ${SBINDIR}/$PRODUCT
+
+FIREWALL=${CONFDIR}/init.d/$PRODUCT
 
-if [ -f "$INITSCRIPT" ]; then
+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"
diff --git a/Shorewall-lite/uninstall.sh b/Shorewall-lite/uninstall.sh
index e4f8a22..6504512 100755
--- a/Shorewall-lite/uninstall.sh
+++ b/Shorewall-lite/uninstall.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Script to back uninstall Shoreline Firewall
+# Script to back uninstall Shoreline Firewall Lite
 #
 #     (c) 2000-2016 - Tom Eastep ([email protected])
 #
@@ -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"
diff --git a/Shorewall/uninstall.sh b/Shorewall/uninstall.sh
index 05e7d73..44e7dff 100755
--- a/Shorewall/uninstall.sh
+++ b/Shorewall/uninstall.sh
@@ -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"
diff --git a/Shorewall6-lite/uninstall.sh b/Shorewall6-lite/uninstall.sh
index 6a302f6..a5bfa8e 100755
--- a/Shorewall6-lite/uninstall.sh
+++ b/Shorewall6-lite/uninstall.sh
@@ -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"
diff --git a/Shorewall6/uninstall.sh b/Shorewall6/uninstall.sh
index b0368a6..cd900d4 100755
--- a/Shorewall6/uninstall.sh
+++ b/Shorewall6/uninstall.sh
@@ -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"
 
+[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service
 
+#
+# Report Success
+#
+echo "$Product $VERSION Uninstalled"
-- 
2.8.3


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Shorewall-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/shorewall-devel

Reply via email to