#!/sbin/sh
# @(#) postremove.sd - B.08.40
# SD postremove script
# (C) Copyright Marxmeier Software AG, 2002-2024. All rights reserved.
#
# Unconfigure scripts are executed during the un-configuration phase
# of a swremove process. They can also be executed by the swconfig
# command.
#

#################################################
#             Startup                           #
#################################################

# source standard SD control script utilities

UTILS=/usr/lbin/sw/control_utils
if [ ! -f $UTILS ]
then
   echo "ERROR:    Cannot find $UTILS"
   exit 1
fi
. $UTILS

# set retval and exitval

exitval=$SUCCESS
set_status()
{
   retval=${1:-$?}
   [[ $retval -eq  $FAILURE ]] && exitval=$retval
}

# remove patch descriptions

rm -f /opt/eloquence/8.4/share/doc/PE84-*

# remove examples

#for f in /opt/eloquence/8.4/share/example/*
#do
#    b=`basename "$f"`
#    if [ -e "$f" -a "$b" != "README" ]; then
#        rm -rf "$f"
#    fi
#done

# Remove webdlg2 status directory

if [ -d /var/opt/eloquence/8.4/eloqwebd2.tmp ]; then
   find /var/opt/eloquence/8.4/eloqwebd2.tmp -type f -exec rm -f -- '{}' \; 2>/dev/null
   rmdir -f /var/opt/eloquence/8.4/eloqwebd2.tmp 2>/dev/null
fi

# Remove empty directories that this fileset owns exclusively.

if [ -d /opt/eloquence/8.4 ]; then
   find /opt/eloquence/8.4 -type d -depth|xargs rmdir -f 2>/dev/null
fi

if [ -d /var/opt/eloquence/8.4 ]; then
   find /var/opt/eloquence/8.4 -type d -depth|xargs rmdir -f 2>/dev/null
fi

if [ -d /etc/opt/eloquence/8.4 ]; then
   find /etc/opt/eloquence/8.4 -type d -depth|xargs rmdir -f 2>/dev/null
fi

# remove socket directory if only directory
if [ -d /var/opt/eloquence/socket ]; then
   nf=$(ls /var/opt/eloquence | fgrep -v socket | wc -l)
   [[ $nf -eq 0 ]] &&  rmdir /var/opt/eloquence
fi

exit $exitval
