Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../lib/svc/share/./sysconfig_include.sh
Real path: /lib/svc/share/sysconfig_include.sh
Zurück
#!/bin/ksh # # Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. # # # This file provides private functions, to be used only by the sysconfig # framework. # # Common properties to config and unconfig milestones. PROP_SYSCONFIG_TIMESTAMP=sysconfig/timestamp # Records previous value of $SVC_RESTARTER:/properties/config_ovr/milestone. # This property exists in $SVC_MILESTONE_CONFIG. PROP_SC_OVR_MILESTONE=sysconfig_ovr/milestone # Tracks whether $SVC_RESTARTER:/properties/config_ovr/milestone was set by part # of the sysconfig framework. This property exists in $SVC_RESTARTER. PROP_OVR_SETBY=options_ovr/milestone_set_by # Unconfiguration and configuration milestones store their properties in # different places for no good reason. This must continue because compatibility # in reconfiguration profiles needs to be maintained back to Solaris 11.2 - the # first release to support kernel zones. SVC_MILESTONE_UNCONFIG=svc:/milestone/unconfig SVC_MILESTONE_CONFIG=svc:/milestone/config:default SVC_RESTARTER=svc:/system/svc/restarter:default # Apply any profiles that are directly within /etc/svc/profile/incoming. This # is used to trigger milestone/unconfig and/or milestone/config to do some work. # Installers only need to drop a profile in the incoming directory - they have # no need to perform altroot operations on the repo. # # Care must be taken to only apply them once - not repeatedly on each reboot. # To ensure that they are only applied once, they need to be moved out of the # incoming directory. Various services may call 'svccfg cleanup', which will # remove all of the settings from these profiles if the profiles are no longer # in the location they were at when they were applied. For this reason: # # - early-manifest-import moves them to the backup directory then applies # them from the backup directory. # - milestone/unconfig, milestone/config, and any other service responsible # for one-time work based on the settings in these profiles must take # appropriate steps to delete customizations or otherwise change values # when their one-time work is successful. # # Some operations (e.g. system cloning) will delete or not preserve the backups. # This will likely be followed by a 'svccfg cleanup'. Thus, the profiles in # /etc/svc/profile/backup should not be used for anything other than transient # settings. # function apply_incoming { typeset incoming=/etc/svc/profile/incoming typeset file typeset bkupdir if ! ls "$incoming"/*.xml >/dev/null 2>&1; then return fi bkupdir=/etc/svc/profile/backup/sc_service-$(sysconfig_timestamp) mkdir "$bkupdir" if (( $? != 0 )); then print "Unable to create $bkupdir; incoming profiles not applied" print "Incoming SMF profiles not applied" | smf_console exit $SMF_EXIT_ERR_FATAL fi # # The "move" is really a copy, apply new, delete old sequence. # cp -p "$incoming"/*.xml "$bkupdir" if (( $? != 0 )); then print "Unable to copy incoming profiles to $bkupdir" print "Incoming SMF profiles not applied" | smf_console exit $SMF_EXIT_ERR_FATAL fi for file in "$bkupdir"/*.xml; do svccfg_apply "$file" if (( $? != 0 )); then print "Unable to apply incoming profile $file" print "Incoming SMF profiles not applied" | smf_console rm -rf "$bkupdir" exit $SMF_EXIT_ERR_FATAL fi done rm -f "$incoming"/*.xml } function svccfg_apply { print "Applying profile: $1" $X /usr/sbin/svccfg apply $1 if [ $? -ne 0 ]; then echo "WARNING: svccfg apply $1 failed" | tee /dev/msglog return 1 fi activity=true return 0 } # # If sysconfig generated unconfig and/or config profiles, it will have set # sysconfig/timestamp to allow the work done as the milestones start to be # associated with the work it started. This function will get that timestamp or # make up a new one. # function sysconfig_timestamp { typeset when when=$(smf_get_prop "$PROP_SYSCONFIG_TIMESTAMP" 2>/dev/null) if [[ -n $when ]]; then echo "$when" return fi # Fall back to now date "+%Y%m%d-%H%M%S" } # # If milestone/config has any work to do and the target milestone hasn't already # been set to a milestone earlier than milestone/config, go directly to # milestone/config. This will make it so that only those services that are # required for milestone/config will come online before it applies profiles. # This is needed so that services that most services that milestone/config will # configure will not start until after any profiles that may alter their # behavior have been applied. # function set_milestone_config { typeset do_config milestone_ovr milestone set_by # $too_early has the milestones that happen before milestone/config. # Do not substitute $SVC_MILESTONE_UNCONFIG. That variable must not # have the instance name and this variable requires the instance name. typeset too_early='@(none|svc:/system/milestone/unconfig:default)' do_config=$(smf_get_prop sysconfig/configure "$SVC_MILESTONE_CONFIG") if [[ $do_config != true ]]; then return fi set_by=$(smf_get_prop "$PROP_OVR_SETBY" "$SVC_RESTARTER" 2>/dev/null) if [[ -n $set_by ]]; then print "Advancing to milestone set by $set_by" return fi milestone_ovr=$(smf_get_prop options_ovr/milestone \ "$SVC_RESTARTER" 2>/dev/null) if [[ $milestone_ovr == $SVC_MILESTONE_CONFIG ]]; then # An earlier service has already been here, nothing to do return fi if [[ -z $milestone_ovr ]]; then # Fall back to default milestone, if defined. milestone=$(smf_get_prop options/milestone "$SVC_RESTARTER" \ 2>/dev/null) else milestone=$milestone_ovr fi if [[ $milestone == $too_early ]]; then print "Configuration required but milestone/config" \ "comes after $milestone;" \ "Not forcing milestone/config" return fi print "Configuration required; advancing to milestone/config before" \ "going to milestone ${milestone:-all}" _create_nonpersist_pg "$SVC_RESTARTER" options_ovr framework && /usr/sbin/svccfg -s "$SVC_RESTARTER" \ setprop "$PROP_OVR_SETBY" = astring: "$SMF_FMRI" if (( $? != 0 )); then print "Failed to set milestone hint in $SVC_RESTARTER;" \ "Not forcing milestone config" return fi # Save the current value of the restarter's options_ovr/milestone in # milestone/config's sysconfig_ovr/milestone. _create_nonpersist_pg "$SVC_MILESTONE_CONFIG" sysconfig_ovr framework && /usr/sbin/svccfg -s "$SVC_MILESTONE_CONFIG" \ setprop "$PROP_SC_OVR_MILESTONE" = astring: "$milestone_ovr" if (( $? != 0 )); then print "Failed to set milestone hint in" \ "$SVC_MILESTONE_CONFIG;" \ "Not forcing milestone config" /usr/sbin/svccfg -s "$SVC_RESTARTER" \ delprop "$PROP_OVR_SETBY" return fi # # milestone/config is not one of the milestones generally allowed by # svcadm, so we need to poke the value directly into the repo. # /usr/sbin/svccfg -s "$SVC_RESTARTER" \ setprop options_ovr/milestone = astring: "$SVC_MILESTONE_CONFIG" if (( $? != 0 )); then print "Failed to set target milestone;" \ "progressing to $milestone" /usr/sbin/svccfg -s "$SVC_RESTARTER" \ delprop "$PROP_OVR_SETBY" /usr/sbin/svccfg -s "$SVC_MILESTONE_CONFIG" \ delprop "$PROP_SC_OVR_MILESTONE" return fi # Give the graph a bit of time to settle so that startd realizes that # milestone/config will be starting and it should not start sulogin # ahead of that. sleep 3 } function _create_nonpersist_pg { typeset svc=$1 typeset pg=$2 typeset pgtype=$3 typeset -a curpg /usr/sbin/svccfg -s "$svc" listpg "$pg" 2>/dev/null | read -A curpg if [[ -z ${curpg[0]} ]]; then /usr/sbin/svccfg -s "$svc" addpg "$pg" "$pgtype" P && return 0 print -u2 "Failed to create property group $pg of type" \ "$pgtype in $svc" return 1 fi if [[ ${curpg[1]} != $pgtype ]]; then print -u2 "Property group $pg already exists with type" \ "${curpg[1]} (not $pgtype) in $svc" return 1 fi if [[ ${curpg[2]} != *NONPERSISTENT* ]]; then print -u2 "Property group $pg is persistent in $svc" return 1 fi return 0 }