#!/bin/sh
#
# ident : "@(#) "
# version : 1.0 Dienstag, 14. April 2009 13:03 Uhr MEST
# dev : heiko.stein@sun.com


# var
PATH=/:/bin:/usr/bin:/sbin:/usr/sbin:/usr/ccs/bin
LANG=C
export LANG

SAV_DIR="./smf_sav"
README="${SAV_DIR}/readme.txt"
SVC_STATE="${SAV_DIR}/svc_state.txt"
SVC_EXPORT="${SAV_DIR}/svc_export.xml"
SVC_PROFIL="${SAV_DIR}/svc_profil.xml"
FMRI_LIST=""
FMRI=""

# func
_help()
{
echo "\n\n"
echo "Aufruf: $0"
echo "\n\n"
}

_error()
{
echo "\n\n"
echo "\tError:"
echo "\t${ERRORMESS}"
echo "\n\n"
ERRORMESS=""
}


_test_root()
{
echo "test root ..."
if [ "#`id | cut -d\( -f2 | cut -d\) -f1 | grep root`" = "#" ]; then
ERRORMESS="Script muss unter root-Kennung ausgeführt werden."
_error
exit 1
fi

if [ `uname -X | grep -i '^release' | awk '{print $3}' | cut -d. -f2` -lt 10 ]; then
ERRORMESS="Script muss unter Solaris 5.10 oder hoeher ausgefuehrt werden."
_error
exit 1
fi
}

_make_dir()
{
echo "logdir ${SAV_DIR} ..."
if [ -d ${SAV_DIR} ]; then
if [ -d ${SAV_DIR}.old ]; then
rm -rf ${SAV_DIR}.old
fi
mv -f ${SAV_DIR} ${SAV_DIR}.old
fi
mkdir ${SAV_DIR} >> /dev/null 2>&1
if [ $? != 0 ]; then
ERRORMESS="Fehler bei mkdir ${SAV_DIR}."
_error
exit 1
fi
}

_sav_smf()
{
echo "svcs -aH > ${SVC_STATE} ..."
svcs -aH > ${SVC_STATE} 2> /dev/null
if [ $? != 0 ]; then
ERRORMESS="Fehler bei svcs -aH."
_error
else
echo "svcs -aH > ${SVC_STATE}\n" >> ${README}
fi

if [ "x`svcs -xv`" != "x" ]; then
echo "svcs -xv >> ${SVC_STATE} ..."
svcs -xv >> ${SVC_STATE} 2> /dev/null
echo "svcs -xv >> ${SVC_STATE}\n" >> ${README}
fi

echo "svccfg archive > ${SVC_EXPORT} ..."
svccfg archive > ${SVC_EXPORT} 2> /dev/null
if [ $? != 0 ]; then
ERRORMESS="Fehler bei svccfg archive."
_error
else
echo "svccfg archive > ${SVC_EXPORT}\n" >> ${README}
fi

echo "svccfg extract > ${SVC_PROFIL} ..."
svccfg extract > ${SVC_PROFIL} 2> /dev/null
if [ $? != 0 ]; then
ERRORMESS="Fehler bei svccfg extract."
_error
else
echo "svccfg extract > ${SVC_PROFIL}\n" >> ${README}
fi

echo "svccfg export ... "
FRMI_LIST=`svcs -aH | grep -vi '^legacy' | awk '{print $3}' ` 2>/dev/null
for FRMI in ${FRMI_LIST}
do
svccfg export `echo ${FRMI}| cut -d: -f2` > ${SAV_DIR}/`echo ${FRMI} |sed -e 's/\///' -e 's/\//_/g'`.xml
echo "${FRMI} -> `echo ${FRMI} |sed -e 's/\///' -e 's/\//_/g'`.xml" >> ${README}
done
}

trap "_help;exit 1" 2

# main
_test_root
_make_dir
_sav_smf
echo "siehe ${README} ..."

exit 0


More...