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