#!/bin/sh
# NPCTE fix for bug 4451597, GS, 5 June 2001
#
# postpatch script for OSI patch 111344, fix for /etc/netconfig issues at first reboot after
# pkgrm of SUNWcorpc or SUNWcorpx packages
# Create preremove scripts for these packages.

mk_scr() {
    dir="/var/sadm/pkg/$1/install"
    scr="$dir/preremove"

    # if pkg. not installed, or if installed with preremove script, return
    if [ ! -d $dir ] || [ -f $scr ]; then
        return
    fi

    # test creation, change permissions, and silently exit if that fails
    touch $scr && [ $? -ne 0 ] && chmod -fR o+rwx $dir && exit 0

    cat << "EOF_"  >$scr
#!/bin/sh
# NPCTE fix for bug 4451597, GS, 5 June 2001
#
# preremove script for OSI patch 111344, fix for /etc/netconfig issues at first reboot after
# pkgrm of SUNWcorpc or SUNWcorpx packages
# Remove oclt line from /etc/netconfig and restart inetd
#
output="/dev/null"     # /tmp/`basename $0`.out
same=false
case `/bin/isainfo -b` in
    "32")
        [ "$PKG" = "SUNWcorpc" ] && same=true
        ;;
    "64")
        [ "$PKG" = "SUNWcorpx" ] && same=true
        ;;
    *)
        # unexpected case
        exit 0
        ;;
esac

# If package for current mode (32 or 64 bit) OR it's the last package of the two SUNWcorp[cx]
if $same || [ `pkginfo | grep -c SUNWcorp[cx]` -eq 1 ]; then
    # This cmd removes the oclt line and restarts the inetd daemon
    /etc/init.d/osirpc.last stop > $output 2>&1
fi
exit 0
# end NPCTE fix for bug 4451597, GS, 5 June 2001
EOF_
}

mk_scr SUNWcorpc
mk_scr SUNWcorpx
# end NPCTE fix for bug 4451597, GS, 5 June 2001


