#!/bin/sh # # Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # # # i.manifest - smf(5) service manifest install class action script # repfile=$PKG_INSTALL_ROOT/etc/svc/repository.db export repfile SVCCFG=/usr/sbin/svccfg SVCADM=/usr/sbin/svcadm AWK=/usr/bin/awk RM=/usr/bin/rm CP=/usr/bin/cp MV=/usr/bin/mv CHMOD=/usr/bin/chmod CHOWN=/usr/bin/chown . /lib/svc/share/smf_include.sh # # Helper function. Handle services deathrow file. # Arguments: $1:manifest file. # svc_deathrow() { TEMP=/tmp/svc_deathrow.$$ DEATHROW_FILE=${PKG_INSTALL_ROOT}/etc/svc/deathrow # # Services deathrow file handling, file format: # < >< > # (field separator is a space character) # if [ -s ${DEATHROW_FILE} ]; then # # Manifest file could be from another Solaris version, bypass # the service bundle and validation (we only need the fmris # list). Calling svccfg inventory with SVCCFG_NOVALIDATE=1 is # safe because there is no access to the alternate repository. # ENTITIES=`SVCCFG_NOVALIDATE=1 $SVCCFG inventory $1` for fmri in $ENTITIES; do # # If fmri matches one in deathrow file, remove the # line from the file. # >${TEMP} $AWK "(\$1==\"$fmri\") \ {next}; {print}" ${DEATHROW_FILE} >>${TEMP} && \ $MV ${TEMP} ${DEATHROW_FILE} $RM -f ${TEMP} done fi } # # If the repository does not yet exist, create it from the appropriate seed. If # for some reason the seeds do not exist, svccfg(1M) will create the repository # automatically. # if [ ! -f $repfile ]; then if [ -n "$SUNW_PKG_INSTALL_ZONENAME" -a \ "$SUNW_PKG_INSTALL_ZONENAME" != "global" ]; then [ -f $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db ] && \ $CP $PKG_INSTALL_ROOT/lib/svc/seed/nonglobal.db $repfile else [ -f $PKG_INSTALL_ROOT/lib/svc/seed/global.db ] && \ $CP $PKG_INSTALL_ROOT/lib/svc/seed/global.db $repfile fi $CHMOD 0600 $repfile $CHOWN root:sys $repfile fi do_manifest_import="no" alternate_root="no" if [ "$PKG_INSTALL_ROOT" != "" -a "$PKG_INSTALL_ROOT" != "/" ]; then alternate_root="yes" fi smf_alive="no" if [ -r ${PKG_INSTALL_ROOT}${SMF_SYSVOL_FS}/repository_door -a \ "${alternate_root}" = "no" ]; then smf_alive="yes" fi while read src dst; do $CP -p $src $dst manifest=${dst#${PKG_INSTALL_ROOT}} standard_location=$(print $manifest | $AWK ' /^\/(var|lib)\/svc\/manifest\// { print "true" } { next; }') if [ "${standard_location}" = "true" ]; then do_manifest_import="yes" elif [ "${smf_alive}" = "yes" ]; then SVCCFG_CHECKHASH=1 $SVCCFG import $dst else svc_deathrow $dst fi done if [ "${do_manifest_import}" = "yes" -a "${smf_alive}" = "yes" ]; then $SVCADM restart svc:/system/manifest-import:default fi exit 0