#
# Copyright 2006 Yann Rouillard <yann@blastwave.org>
# All rights reserved.  Use is subject to license terms.
#
# Redistribution and/or use, with or without modification, is
# permitted.  This code is without warranty of any kind.  The
# author(s) shall not be liable in the event that use of the
# software causes damage.
#
# i.smf - class script which install smf related files
#         This class will simply copy file except for the
#         manifest file which, in addition, will imported 
#         in the svc repository
#
# use this class for the following files:
# /opt/csw/var/svc
# /opt/csw/var/svc/manifest
# /opt/csw/var/svc/manifest/network
# /opt/csw/var/svc/manifest/network/softname.xml=/softname.xml
# /opt/csw/lib/svc
# /opt/csw/lib/svc/method
# /opt/csw/lib/svc/method/svc-softname
#
if [ -z "$PKG_INSTALL_ROOT" ]; then
    PKG_INSTALL_ROOT="/"
fi

while read SRC DEST; do
    EXT="`/usr/bin/echo $DEST | /usr/bin/awk -F. '{ print $(NF) }'`"
        "$BASEDIR/usr/bin/cp" "$SRC" "$DEST" || exit 2

    # the .xml file is the manifest file
    if [ "$EXT" = "xml" ]; then
        /usr/sbin/chroot "$PKG_INSTALL_ROOT" /usr/sbin/svccfg import "$DEST"
    fi
done

exit 0
