Home | History | Annotate | Download | only in livemedia
      1 #!/sbin/sh
      2 #
      3 # CDDL HEADER START
      4 #
      5 # The contents of this file are subject to the terms of the
      6 # Common Development and Distribution License, Version 1.0 only
      7 # (the "License").  You may not use this file except in compliance
      8 # with the License.
      9 #
     10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     11 # or http://www.opensolaris.org/os/licensing.
     12 # See the License for the specific language governing permissions
     13 # and limitations under the License.
     14 #
     15 # When distributing Covered Code, include this CDDL HEADER in each
     16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     17 # If applicable, add the following below this CDDL HEADER, with the
     18 # fields enclosed by brackets "[]" replaced with your own identifying
     19 # information: Portions Copyright [yyyy] [name of copyright owner]
     20 #
     21 # CDDL HEADER END
     22 #
     23 #
     24 # Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
     25 # Use is subject to license terms.
     26 #
     27 
     28 # 0.  Initialization.
     29 
     30 [ $# != 1 ] && echo "Usage: mkrepo <rootdir>" && exit 1
     31 
     32 ROOTDIR=$1
     33 SVCCFG_DTD=${ROOTDIR}/usr/share/lib/xml/dtd/service_bundle.dtd.1
     34 SVCCFG_REPOSITORY=${ROOTDIR}/etc/svc/repository.db
     35 
     36 export SVCCFG_DTD SVCCFG_REPOSITORY
     37 
     38 
     39 X=
     40 [ -f /lib/svc/share/smf_include.sh ] || exit 1
     41 
     42 svccfg_apply () {
     43 	$X /usr/sbin/svccfg apply $1
     44 	if [ $? -ne 0 ]; then
     45 		echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
     46 	fi
     47 }
     48 
     49 svccfg_import () {
     50 	$X /usr/sbin/svccfg import $1 2>>/tmp/manifest_import.$$
     51 	if [ $? -ne 0 ]; then
     52 		echo > /dev/msglog
     53 		echo "WARNING: svccfg import $1 failed" | tee /dev/msglog
     54 	fi
     55 }
     56 
     57 #SVCCFG_CHECKHASH=1 export SVCCFG_CHECKHASH
     58 
     59 #
     60 # 2.  Manifest import.  Application directories first, then
     61 # site-specific manifests.
     62 #
     63 nonsite_dirs=`/usr/bin/find ${ROOTDIR}/var/svc/manifest/* -name site -prune -o -type d \
     64 	-print -prune`
     65 
     66 nonsite_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan $nonsite_dirs`
     67 site_manifests=`${ROOTDIR}/lib/svc/bin/mfstscan ${ROOTDIR}/var/svc/manifest/site`
     68 
     69 manifests="$nonsite_manifests $site_manifests"
     70 
     71 [ -n "$_MFST_DEBUG" ] && {
     72 	echo "Changed manifests to import:"
     73 	for m in $manifests; do echo "  $m"; done
     74 }
     75 
     76 #
     77 # 2b.  Import the manifests while giving a running display of imports on
     78 # console, and a final count in the logfile.
     79 #
     80 if [ -n "$nonsite_manifests" -o -n "$site_manifests" ]; then
     81 	rm -f /tmp/manifest_import.$$
     82 
     83 	set -- $manifests
     84 	backup=`echo "$#/$#" | sed 's/.//g'`
     85 	fwidth=`echo "$#\c" | wc -c`
     86 
     87 	echo "Loading smf(5) service descriptions: \c"
     88 
     89 	i=1; n=$#
     90 	while [ $# -gt 0 ]; do
     91 		printf "%${fwidth}s/%${fwidth}s" $i $n
     92 		svccfg_import $1
     93 		i=`expr $i + 1`
     94 		shift
     95 		echo "$backup\c"
     96 	done
     97 
     98 	echo
     99 	echo "Loaded $n smf(5) service descriptions"
    100 	activity=true
    101 
    102 	if [ -s /tmp/manifest_import.$$ ]; then
    103 		echo "svccfg warnings:"
    104 		cat /tmp/manifest_import.$$
    105 
    106 		msg="svccfg import warnings.  See"
    107 		msg="$msg ${ROOTDIR}/var/svc/log/system-manifest-import:default.log ."
    108 		echo $msg
    109 	fi
    110 	rm -f /tmp/manifest_import.$$
    111 fi
    112 
    113 #
    114 # 3.  Profile application.  We must create the platform profile upon
    115 # first boot, as we may be a diskless client of a platform or
    116 # architecture distinct from our NFS server.
    117 #
    118 svccfg_apply ${ROOTDIR}/var/svc/profile/generic.xml
    119 
    120 if [ ! -f ${ROOTDIR}/var/svc/profile/platform.xml ]; then
    121 	this_karch=`uname -m`
    122 	this_plat=`uname -i`
    123 
    124 	if [ -f ${ROOTDIR}/var/svc/profile/platform_$this_plat.xml ]; then
    125 		platform_profile=platform_$this_plat.xml
    126 	elif [ -f ${ROOTDIR}/var/svc/profile/platform_$this_karch.xml ]; then
    127 		platform_profile=platform_$this_karch.xml
    128 	else
    129 		platform_profile=platform_none.xml
    130 	fi
    131 
    132 	(cd ${ROOTDIR}/var/svc/profile; ln -s $platform_profile platform.xml)
    133 fi
    134 
    135 svccfg_apply ${ROOTDIR}/var/svc/profile/platform.xml
    136 
    137 # Apply Live environment modifications
    138 svccfg_apply $LIVEKIT/generic_live.xml
    139 
    140 # Apply name service profile
    141 svccfg_apply ${ROOTDIR}/var/svc/profile/ns_files.xml
    142 
    143 # Dummy out start methods for services we need to run, but as no-ops
    144 svccfg -s system/boot-archive setprop start/exec=:true
    145 svccfg -s system/manifest-import setprop start/exec=:true
    146 svccfg -s system/rmtmpfiles setprop start/exec=:true
    147 svccfg -s system/sysidtool:net setprop start/exec=:true
    148 svccfg -s system/sysidtool:system setprop start/exec=:true
    149 svccfg -s system/scheduler setprop start/exec=:true
    150 svccfg -s system/zones setprop start/exec=:true
    151 svccfg -s application/font/fc-cache setprop start/exec=:true
    152 
    153 #
    154 # Increase timeout to avoid error messages. Default
    155 # of 30 seconds is not enough for some services when
    156 # starting from a slow device like a DVD drive.
    157 #
    158 svccfg -s system/dbus setprop start/timeout_seconds=90
    159 svccfg -s application/opengl/ogl-select setprop start/timeout_seconds=90
    160 
    161 exit 0
    162