manifest-import revision 7c478bd95313f5f23a4c958a745db2134aa03244
6aa2272cc4af77e605ba2c4a4781f8567408b7e3pquerna# CDDL HEADER START
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm# The contents of this file are subject to the terms of the
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm# Common Development and Distribution License, Version 1.0 only
0b4b04d8621478ba59f0a6ba2950ddc02ab92b58colm# (the "License"). You may not use this file except in compliance
2f1bb5376c5c4022383bb729679ca751dd75a2eabrianp# with the License.
ad862ab5716726a2d72a292ba1dfb29566c86153brianp# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
ad862ab5716726a2d72a292ba1dfb29566c86153brianp# See the License for the specific language governing permissions
347c9301068524042be654db3b2b055a9ec20633rpluem# and limitations under the License.
347c9301068524042be654db3b2b055a9ec20633rpluem# When distributing Covered Code, include this CDDL HEADER in each
1266e0c1535091b37a0c6ea86183094e575cb8dagregames# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1266e0c1535091b37a0c6ea86183094e575cb8dagregames# If applicable, add the following below this CDDL HEADER, with the
29d3b95754d5730dde08bbda9dc76785894f10f8rpluem# fields enclosed by brackets "[]" replaced with your own identifying
dfd7e0be46ab5ef5b84339b4645d60fdc44cb4a5rpluem# information: Portions Copyright [yyyy] [name of copyright owner]
dfd7e0be46ab5ef5b84339b4645d60fdc44cb4a5rpluem# CDDL HEADER END
7461431ba407b0e1eac3d6a81440a4184e652e9fniq# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
17d53ea32c4968e47733f1c2c063ae07d280efd6jerenkrantz# Use is subject to license terms.
17d53ea32c4968e47733f1c2c063ae07d280efd6jerenkrantz#ident "%Z%%M% %I% %E% SMI"
b38565306421ff53e9f7499bc728d6df5cec294dpquerna# 0. Initialization.
79d1d5666b3ceb59c959b09600aa2bce32324677rpluemwhile getopts n opt; do
a6ea86151dd968120a12b48867d45947ef2bb9darpluem n) X=echo;;
a6ea86151dd968120a12b48867d45947ef2bb9darpluem ?) echo "Usage: /lib/svc/method/manifest-import [-n]\n"
fa735cac4e86858f11c0de4f7cea50fa63eab87ecolm if [ $? -ne 0 ]; then
fa735cac4e86858f11c0de4f7cea50fa63eab87ecolm echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog
3d76cdd5855071bbfb95a27de7d77a8855d1e893niq $X /usr/sbin/svccfg import $1 2>>/tmp/manifest_import.$$
3d76cdd5855071bbfb95a27de7d77a8855d1e893niq if [ $? -ne 0 ]; then
3d76cdd5855071bbfb95a27de7d77a8855d1e893niq echo "WARNING: svccfg import $1 failed" | tee /dev/msglog
bf0dec31a67271a4a67a6d3a3a9b3cdb41278390rpluem # A property has changed in the manifest that we wish to propagate into
bf0dec31a67271a4a67a6d3a3a9b3cdb41278390rpluem # the repository during manifest import. We don't want to pollute
7612604db51e61f6ec4a6593c188e6d0640646abwrowe # manifests with overrides, so handle explicitly here.
0a2c6381b34b977101327f412a4b1ddc8a361ae7rpluem /lib/svc/bin/prophist upgrade -e $fmri -g $pgrp -p $prop -n "$nval" \
0830215c2542165c027f092c18924f2885c98b49trawick # A property has changed in the manifest that we wish to propagate
3aeb30211790fef38a8297f990b7ad3b2c46ece9colm /lib/svc/bin/prophist overwrite -e $fmri -g $pgrp -p $prop -n "$nval"
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton # Certain property groups have migrated from the service level to the
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton # instance level. We don't care if they are at both, as the instance
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton # level will trump. But having neither could be bad. So check and if
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton # the given pg exists at both levels, delete the service-level one only.
6a9a6a63bae82591ea75fc602d5260109b8fa02ccolm /usr/bin/svcprop -q -c -p $property_group $service:$instance
70706a4d1ead0d72a443eac1cc446a0f1a4de069colm /lib/svc/bin/prophist delete -e $service -g $property_group
be2abc811ae62b872703a7b43235598d641f8d8dmjc # Some services have stale dependencies that need to be removed.
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton # This is done by removing the dependency property group.
2e02c854b4531480fe3f7ab353154c99c5bd97e8jorton if [ $? -eq 0 ]; then
a09378e32e823d5619f766394fcdde1cfa16c5dajim /lib/svc/bin/prophist delete -e $fmri -g $property_group
ce8e09ffeb8c696f7fc6c5dfa8814c52caaac59bcolm # Delete obsolete property groups from old manifests. Instances
f8ae06c7d0615d8b9441099794fe80a3f2915469colm # If a property doesn't exist, create it. Instances should be
6eb3a057b5e4f046faba79104d7941552de755dacolm if [ $# -lt 6 ]; then
6aa2272cc4af77e605ba2c4a4781f8567408b7e3pquerna echo "prophist_addprop(): Insufficient arguments ($*)."
454d060a0d7b13606978c536f632be71e311959djerenkrantz /usr/sbin/svccfg -s $fmri setprop $pg/$prop = $*
1392b9997000dceb6aca39da0a1e6405ccb6f0a6jerenkrantz # If a method doesn't exist, create it. Instances should be refreshed
4b0a0ae3fd77f8fc8fd2a693be33ffe4d99cb94ajerenkrantz if [ $# -ne 4 ]; then
4b0a0ae3fd77f8fc8fd2a693be33ffe4d99cb94ajerenkrantz echo "prophist_addmeth(): Insufficient arguments ($*)"
a42c13195a5c68d55f6b2bbf5b5e1e66ab45d5d4pquerna addpg $name method
a42c13195a5c68d55f6b2bbf5b5e1e66ab45d5d4pquerna setprop $name/type = astring: method
2a90918318af50d5712ae7159e5625476332c184pquerna setprop $name/exec = astring: "$exec"
2a90918318af50d5712ae7159e5625476332c184pquerna setprop $name/timeout_seconds = count: $to
82d2a5debc5a6ed2118ac5916d9ba36ad0b5d78btrawick # If a dependency doesn't exist, create it. Instances should be
42167da203d969a1402cf7ce09c14586c04af1dfjim if [ $# -lt 6 ]; then
424c1a743525e9c5008e29b39a99363723409a1dtrawick addpg $name dependency
424c1a743525e9c5008e29b39a99363723409a1dtrawick setprop $name/type = astring: $type
424c1a743525e9c5008e29b39a99363723409a1dtrawick setprop $name/grouping = astring: $group
4375cabac8fc22b3717687ffdbce9bbdf095f255trawick setprop $name/restart_on = astring: $ro
4375cabac8fc22b3717687ffdbce9bbdf095f255trawick setprop $name/entities = fmri: $*
89211a3153be8b03353c3bfbca45fed67cb80f0bpquerna # If a dependent doesn't exist, create it. Instances should be
89211a3153be8b03353c3bfbca45fed67cb80f0bpquerna if [ $# -ne 5 ]; then
89211a3153be8b03353c3bfbca45fed67cb80f0bpquerna echo "prophist_adddpt(): Incorrect arguments ($*).\n"
a2e37e48efb113e8e4f9d9ca9c8286aaac6c936cpquerna /usr/bin/svcprop -Cqp dependents/$name $fmri && return
44ca834b970b454b844efb96f219bdf49fee71e5trawick prophist_addprop $fmri dependents framework $name fmri: $target
44ca834b970b454b844efb96f219bdf49fee71e5trawick prophist_adddep $target $name service $group $ro $fmri
fde88bb682426885c679198ee130d2d5a29e8c0fbnicholes sort -u /etc/svc/volatile/refreshes | xargs -l svcadm refresh
d66ac514cc15e99228d72c56c6c3daf25da8d360niq [ "`/usr/bin/svcprop -p restarter/state $1`" = "maintenance" ] && \
8c46f9f81ae6357dc97560d6d85154f19cf251aejim for inst in `/usr/bin/sort -u /etc/svc/volatile/clears`; do
e5882a36d7756850cc829f5f2286120b877458b1pquerna # Preserve the five hashes for the profiles: generic (two
e5882a36d7756850cc829f5f2286120b877458b1pquerna # cases), platform (uname -i, uname -m outputs), and site.
8b7594c66e764f5cd3506b6f2459497ab65a8b03pquerna gh=`/usr/bin/svcprop -p ${gn}/md5sum smf/manifest 2>/dev/null`
20f1b1a67eef5ab0f3295608c89964a7dca4fdd1pquerna glh=`/usr/bin/svcprop -p ${gln}/md5sum smf/manifest 2>/dev/null`
599c5abcc7fec60611956f56b732eca033c287d2pquerna plh=`/usr/bin/svcprop -p ${pln}/md5sum smf/manifest 2>/dev/null`
e76fdcdfb8994ad70776526f50fa013b3e9a6033bnicholes LC_ALL=C plm=`/usr/bin/uname -m | /usr/bin/tr , _`
eb9b491d7b262dad572ec2f1f75eea592283f81apquerna if [ $plm != $pl ]; then
1ef90d1763e489969ec7a01c77bcb158ece5ae83jorton plmh=`/usr/bin/svcprop -p ${plmn}/md5sum smf/manifest \
6d00a5e2c08ddbff9614ecc17a1c085462811f89slive sh=`/usr/bin/svcprop -p $sn/md5sum smf/manifest 2>/dev/null`
4f6e78091b3f45a5782389ae25b62516a7a0c842bnicholes /usr/sbin/svccfg -s smf/manifest addpg ${gn} framework
4f6e78091b3f45a5782389ae25b62516a7a0c842bnicholes /usr/sbin/svccfg -s smf/manifest setprop ${gn}/md5sum = \
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna /usr/sbin/svccfg -s smf/manifest addpg ${gln} framework
7d15331eeb5429d7148d13d6fd914a641bf1c000pquerna /usr/sbin/svccfg -s smf/manifest setprop ${gln}/md5sum = \
1d14622beee568462689b2bbc6a9e0e9b6a40583striker /usr/sbin/svccfg -s smf/manifest addpg $pln framework
1d14622beee568462689b2bbc6a9e0e9b6a40583striker /usr/sbin/svccfg -s smf/manifest setprop $pln/md5sum = \
e978097e0bf2ae161b6f9dde40eaf089bf046c89ake /usr/sbin/svccfg -s smf/manifest setprop $plmn/md5sum = \
e777da9fa7ff3138fead7860b53ef00e67a40e26jerenkrantz /usr/sbin/svccfg -s smf/manifest addpg $sn framework
e777da9fa7ff3138fead7860b53ef00e67a40e26jerenkrantz /usr/sbin/svccfg -s smf/manifest setprop $sn/md5sum = \
8e7fb6968047a527d1ccde25ad2aed20da5150ddjerenkrantz# 0. Clean up repository
5a9fa4d75086e942f6e850e1a2e96c4c27a845d0jerenkrantzif [ -z "$X" ] && /usr/bin/svcprop smf/manifest 2>/dev/null |
5a9fa4d75086e942f6e850e1a2e96c4c27a845d0jerenkrantz /usr/bin/grep '^ar_svc_[^/]*/md5sum opaque ' >/dev/null
36c8049de63c446926139936c3d195330a0539cetrawick while read pg prop type value; do
8ff094bdec6a2e1c355c1e6e95e9952d4fae7766jerenkrantz echo "Converting obsolete repository entries: \c" > /dev/msglog
a6bb6f2fb734e488a9b6335fabea3431f9dcf253jerenkrantz echo "Converted $n obsolete repository entries"
3ca80e703a960eca0760c23636b7fe502a8f0342bnicholes# If no last-import snapshots are present on critical services, then we are
5300d4a4fabe3b594da950e4b9ab0f90e076546ejerenkrantz# creating the last-import snapshots for the first time post upgrade.
b1306729566b49fb30aed5c46adaf07a637115afjerenkrantzfor svc in single-user multi-user multi-user-server; do
b1306729566b49fb30aed5c46adaf07a637115afjerenkrantz if /usr/bin/svcprop -s last-import svc:/milestone/$svc:default \
db8551deeb08fa799e7f27e8b748a9397f747bdcjorton echo "Last import snapshots absent; preparing for re-import"
9e3209bc06ddf32f23e4b254faa45914bc323cc9jim # Apply property history files.
45ed846f4ed90f05c084f6a33d688e642be4e623jerenkrantz echo "Upgrade detected; applying property history"
54d22ed1c429b903b029bbd62621f11a9e286137minfrin if [ $? = 3 ]; then
54d22ed1c429b903b029bbd62621f11a9e286137minfrin echo "Sourcing $phist"
92e8e44864d94866eefcbfde0a53fa3d12855149jerenkrantz# 2. Manifest import. Application directories first, then
06106b6b63b112a09de1b66fa29596035c0176ffthommay# site-specific manifests.
06106b6b63b112a09de1b66fa29596035c0176ffthommaynonsite_dirs=`/usr/bin/find /var/svc/manifest/* -name site -prune -o -type d \
e335319a08e12eb7daff9afa80e985dc53f652b8jortonnonsite_manifests=`/lib/svc/bin/mfstscan $nonsite_dirs`
e335319a08e12eb7daff9afa80e985dc53f652b8jortonsite_manifests=`/lib/svc/bin/mfstscan /var/svc/manifest/site`
22dda44322067379eeba28d7ec7fc833cb04c0dfminfrin# 2b. Import the manifests while giving a running display of imports on
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wrowe# console, and a final count in the logfile.
7b6ba9c468f26bdb3492d5e8cb79628a3b04e8c8wroweif [ -n "$nonsite_manifests" -o -n "$site_manifests" ]; then
59b1b6c3fd51c83c3bb9f02a8f08751335f9fb1dminfrin echo "Loading smf(5) service descriptions: \c" > /dev/msglog
9f1a88897168c3f1e5009acb585daf01e38a0299jim i=`expr $i + 1`
5a8bb5948d2a258145174320587706de3219d8a3pquerna echo "Loaded $n smf(5) service descriptions"
0cba3a63e59bfa77f67955cb4e034264ed6c5523jerenkrantz echo "svccfg warnings:"
e5abee85fe751fc27c5d4fc9a8ebe3b80f3d6603trawick msg="$msg /var/svc/log/system-manifest-import:default.log ."
4d553781254e46f1dfc8d86b79667a74fb8a3eb5brianp# 3. Profile application. We must create the platform profile upon
74def8815c725f8128a4e76ab1f5704df80b024ajerenkrantz# first boot, as we may be a diskless client of a platform or
8f868f15482c7406db01216b6e4778ddabb26898trawick# architecture distinct from our NFS server.
1e1e4f4f810b99732f06fc05141f42ca1965a9edpquerna if [ -f /var/svc/profile/platform_$this_plat.xml ]; then
1e1e4f4f810b99732f06fc05141f42ca1965a9edpquerna elif [ -f /var/svc/profile/platform_$this_karch.xml ]; then
78fcc425fc9fc58202a1693fe40dd0ce75c031ffjorton ln -s $platform_profile /var/svc/profile/platform.xml
01847067cfc639c14e1aa77d3b3e98f239447a12jerenkrantz# 4. Upgrade handling. The upgrade file generally consists of a series
01847067cfc639c14e1aa77d3b3e98f239447a12jerenkrantz# of svcadm(1M) and svccfg(1M) commands.
9fe74ffcdea85800f04a7222f716f78ae60cce51jerenkrantz if [ -f /var/svc/profile/upgrade ]; then
9fe74ffcdea85800f04a7222f716f78ae60cce51jerenkrantz /var/svc/profile/upgrade.app.`date +\%Y\%m\%d\%H\%M\%S`
ce66c67eba79a20118d8664b65b0c9eeec1bebdabnicholes# 5. Site profile is applied last to give administrator the final say.
6cfc2ed5a8e633c5a40fec65775868d53952d992trawick# 6. Final actions.