diff --git a/Shorewall-core/lib.uninstaller b/Shorewall-core/lib.uninstaller index 160811e10..531a40914 100644 --- a/Shorewall-core/lib.uninstaller +++ b/Shorewall-core/lib.uninstaller @@ -61,9 +61,36 @@ mywhich() { remove_file() # $1 = file to remove { - if [ -f $1 -o -L $1 ] ; then - rm -f $1 - echo "$1 Removed" + if [ -n "$1" ] ; then + if [ -f $1 -o -L $1 ] ; then + rm -f $1 + echo "$1 Removed" + fi + fi +} + +remove_directory() # $1 = directory to remove +{ + if [ -n "$1" ] ; then + if [ -d $1 ] ; then + rm -rf $1 + echo "$1 Removed" + fi + fi +} + +remove_file_with_wildcard() # $1 = file with wildcard to remove +{ + if [ -n "$1" ] ; then + for f in $1; do + if [ -d $f ] ; then + rm -rf $f + echo "$f Removed" + elif [ -f $f -o -L $f ] ; then + rm -f $f + echo "$f Removed" + fi + done fi } diff --git a/Shorewall-core/uninstall.sh b/Shorewall-core/uninstall.sh index bef7ce1ad..1b124a5e2 100755 --- a/Shorewall-core/uninstall.sh +++ b/Shorewall-core/uninstall.sh @@ -127,8 +127,8 @@ fi echo "Uninstalling $Product $VERSION" -rm -rf ${SHAREDIR}/shorewall -rm -f ~/.shorewallrc +remove_directory ${SHAREDIR}/shorewall +remove_file ~/.shorewallrc # # Report Success diff --git a/Shorewall-init/uninstall.sh b/Shorewall-init/uninstall.sh index 6539fa0a6..00dacf917 100755 --- a/Shorewall-init/uninstall.sh +++ b/Shorewall-init/uninstall.sh @@ -137,7 +137,7 @@ echo "Uninstalling $Product $VERSION" [ -n "${LIBEXEC:=${SHAREDIR}}" ] -rm -f ${SBINDIR}/$PRODUCT +remove_file ${SBINDIR}/$PRODUCT FIREWALL=${CONFDIR}/init.d/$PRODUCT @@ -163,7 +163,7 @@ fi if [ -n "$SERVICEDIR" ]; then [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service - rm -f $SERVICEDIR/${PRODUCT}.service + remove_file $SERVICEDIR/${PRODUCT}.service fi if [ $HOST = openwrt ]; then @@ -200,9 +200,9 @@ if [ -d ${CONFDIR}/ppp ]; then done fi -rm -rf ${SHAREDIR}/$PRODUCT -rm -rf ${LIBEXECDIR}/$PRODUCT -rm -f ${CONFDIR}/logrotate.d/$PRODUCT +remove_directory ${SHAREDIR}/$PRODUCT +remove_directory ${LIBEXECDIR}/$PRODUCT +remove_file ${CONFDIR}/logrotate.d/$PRODUCT # # Report Success diff --git a/Shorewall-lite/uninstall.sh b/Shorewall-lite/uninstall.sh index 6504512aa..c60a89b76 100755 --- a/Shorewall-lite/uninstall.sh +++ b/Shorewall-lite/uninstall.sh @@ -141,7 +141,7 @@ if [ $configure -eq 1 ]; then fi fi -rm -f ${SBINDIR}/$PRODUCT +remove_file ${SBINDIR}/$PRODUCT if [ -L ${SHAREDIR}/$PRODUCT/init ]; then if [ $HOST = openwrt ]; then @@ -175,22 +175,22 @@ fi if [ -n "$SERVICEDIR" ]; then [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service - rm -f $SERVICEDIR/${PRODUCT}.service + remove_file $SERVICEDIR/${PRODUCT}.service fi -rm -rf ${CONFDIR}/$PRODUCT -rm -rf ${VARDIR} -rm -rf ${SHAREDIR}/$PRODUCT -rm -rf ${LIBEXECDIR}/$PRODUCT -rm -f ${CONFDIR}/logrotate.d/$PRODUCT +remove_directory ${CONFDIR}/$PRODUCT +remove_directory ${VARDIR} +remove_directory ${SHAREDIR}/$PRODUCT +remove_directory ${LIBEXECDIR}/$PRODUCT +remove_file ${CONFDIR}/logrotate.d/$PRODUCT if [ -n "$SYSCONFDIR" ]; then - [ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT} + [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT} fi if [ -n "${MANDIR}" ]; then - rm -f ${MANDIR}/man5/${PRODUCT}* - rm -f ${MANDIR}/man8/${PRODUCT}* + remove_file_with_wildcard ${MANDIR}/man5/${PRODUCT}\* + remove_file_with_wildcard ${MANDIR}/man8/${PRODUCT}\* fi # diff --git a/Shorewall/uninstall.sh b/Shorewall/uninstall.sh index 44e7dff9c..ccde70eb4 100755 --- a/Shorewall/uninstall.sh +++ b/Shorewall/uninstall.sh @@ -141,7 +141,7 @@ if [ $configure -eq 1 ]; then fi fi -rm -f ${SBINDIR}/$PRODUCT +remove_file ${SBINDIR}/$PRODUCT if [ -L ${SHAREDIR}/$PRODUCT/init ]; then FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init) @@ -167,45 +167,45 @@ fi if [ -n "$SERVICEDIR" ]; then [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service - rm -f $SERVICEDIR/${PRODUCT}.service + remove_file $SERVICEDIR/${PRODUCT}.service fi -rm -rf ${SHAREDIR}/$PRODUCT/version -rm -rf ${CONFDIR}/$PRODUCT +remove_file ${SHAREDIR}/$PRODUCT/version +remove_directory ${CONFDIR}/$PRODUCT if [ -n "$SYSCONFDIR" ]; then - [ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT} + [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT} fi -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 -f ${SHAREDIR}/$PRODUCT/lib.cli-std -rm -f ${SHAREDIR}/$PRODUCT/lib.runtime -rm -f ${SHAREDIR}/$PRODUCT/compiler.pl -rm -f ${SHAREDIR}/$PRODUCT/prog.* -rm -f ${SHAREDIR}/$PRODUCT/module* -rm -f ${SHAREDIR}/$PRODUCT/helpers -rm -f ${SHAREDIR}/$PRODUCT/action* -rm -f ${SHAREDIR}/$PRODUCT/macro.* -rm -f ${SHAREDIR}/$PRODUCT/init +remove_directory ${VARDIR} +remove_file_with_wildcard ${PERLLIBDIR}/$Product/\* +[ ${LIBEXECDIR} = ${SHAREDIR} ] || remove_directory ${LIBEXECDIR}/$PRODUCT +remove_directory ${SHAREDIR}/$PRODUCT/configfiles +remove_directory ${SHAREDIR}/$PRODUCT/Samples +remove_directory ${SHAREDIR}/$PRODUCT/$Product +remove_file ${SHAREDIR}/$PRODUCT/lib.cli-std +remove_file ${SHAREDIR}/$PRODUCT/lib.runtime +remove_file ${SHAREDIR}/$PRODUCT/compiler.pl +remove_file_with_wildcard ${SHAREDIR}/$PRODUCT/prog.\* +remove_file_with_wildcard ${SHAREDIR}/$PRODUCT/module\* +remove_file ${SHAREDIR}/$PRODUCT/helpers +remove_file_with_wildcard ${SHAREDIR}/$PRODUCT/action\* +remove_file_with_wildcard ${SHAREDIR}/$PRODUCT/macro.\* +remove_file ${SHAREDIR}/$PRODUCT/init for f in ${MANDIR}/man5/${PRODUCT}* ${MANDIR}/man8/${PRODUCT}*; do case $f in shorewall6*|shorewall-lite*) ;; *) - rm -f $f + remove_file $f ;; esac done -rm -f ${CONFDIR}/logrotate.d/$PRODUCT +remove_file ${CONFDIR}/logrotate.d/$PRODUCT -[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service +[ -n "$SYSTEMD" ] && remove_file ${SYSTEMD}/${PRODUCT}.service # # Report Success diff --git a/Shorewall6-lite/uninstall.sh b/Shorewall6-lite/uninstall.sh index a5bfa8ef4..a0a8a55c7 100755 --- a/Shorewall6-lite/uninstall.sh +++ b/Shorewall6-lite/uninstall.sh @@ -141,7 +141,7 @@ if [ $configure -eq 1 ]; then fi fi -rm -f ${SBINDIR}/$PRODUCT +remove_file ${SBINDIR}/$PRODUCT if [ -L ${SHAREDIR}/$PRODUCT/init ]; then if [ $HOST = openwrt ]; then @@ -175,22 +175,22 @@ fi if [ -n "$SERVICEDIR" ]; then [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service - rm -f $SERVICEDIR/${PRODUCT}.service + remove_file $SERVICEDIR/${PRODUCT}.service fi -rm -rf ${CONFDIR}/$PRODUCT -rm -rf ${VARDIR} -rm -rf ${SHAREDIR}/$PRODUCT -rm -rf ${LIBEXECDIR}/$PRODUCT -rm -f ${CONFDIR}/logrotate.d/$PRODUCT +remove_directory ${CONFDIR}/$PRODUCT +remove_directory ${VARDIR} +remove_directory ${SHAREDIR}/$PRODUCT +remove_directory ${LIBEXECDIR}/$PRODUCT +remove_file ${CONFDIR}/logrotate.d/$PRODUCT if [ -n "$SYSCONFDIR" ]; then - [ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT} + [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT} fi if [ -n "${MANDIR}" ]; then - rm -f ${MANDIR}/man5/${PRODUCT}* - rm -f ${MANDIR}/man8/${PRODUCT}* + remove_file_with_wildcard ${MANDIR}/man5/${PRODUCT}\* + remove_file_with_wildcard ${MANDIR}/man8/${PRODUCT}\* fi # diff --git a/Shorewall6/uninstall.sh b/Shorewall6/uninstall.sh index cd900d467..7e9783b74 100755 --- a/Shorewall6/uninstall.sh +++ b/Shorewall6/uninstall.sh @@ -141,7 +141,7 @@ if [ $configure -eq 1 ]; then fi fi -rm -f ${SBINDIR}/$PRODUCT +remove_file ${SBINDIR}/$PRODUCT if [ -L ${SHAREDIR}/$PRODUCT/init ]; then FIREWALL=$(readlink -m -q ${SHAREDIR}/$PRODUCT/init) @@ -167,34 +167,34 @@ fi if [ -n "$SERVICEDIR" ]; then [ $configure -eq 1 ] && systemctl disable ${PRODUCT}.service - rm -f $SERVICEDIR/${PRODUCT}.service + remove_file $SERVICEDIR/${PRODUCT}.service fi -rm -rf ${SHAREDIR}/$PRODUCT/version -rm -rf ${CONFDIR}/$PRODUCT +remove_file ${SHAREDIR}/$PRODUCT/version +remove_directory ${CONFDIR}/$PRODUCT if [ -n "$SYSCONFDIR" ]; then - [ -n "$SYSCONFFILE" ] && rm -f ${SYSCONFDIR}/${PRODUCT} + [ -n "$SYSCONFFILE" ] && remove_file ${SYSCONFDIR}/${PRODUCT} fi -rm -rf ${CONFDIR}/$PRODUCT -rm -rf ${VARDIR} -rm -rf ${LIBEXECDIR}/$PRODUCT -rm -rf ${SHAREDIR}/$PRODUCT +remove_directory ${CONFDIR}/$PRODUCT +remove_directory ${VARDIR} +remove_directory ${LIBEXECDIR}/$PRODUCT +remove_directory ${SHAREDIR}/$PRODUCT for f in ${MANDIR}/man5/${PRODUCT}* ${MANDIR}/man8/${PRODUCT}*; do case $f in shorewall6-lite*) ;; *) - rm -f $f + remove_file $f ;; esac done -rm -f ${CONFDIR}/logrotate.d/$PRODUCT +remove_file ${CONFDIR}/logrotate.d/$PRODUCT -[ -n "$SYSTEMD" ] && rm -f ${SYSTEMD}/${PRODUCT}.service +[ -n "$SYSTEMD" ] && remove_file ${SYSTEMD}/${PRODUCT}.service # # Report Success