smf_include.sh revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
[ -r /etc/svc/volatile/repository_door ] && \
[ ! -f /etc/svc/volatile/repository_door ]
}
unset \
SMF_FMRI \
}
# smf_console
#
# Use as "echo message 2>&1 | smf_console". If SMF_MSGLOG_REDIRECT is
# unset, message will be displayed to console. SMF_MSGLOG_REDIRECT is
# reserved for future use.
#
}
# smf_zonename
#
# Prints the name of this zone.
}
# smf_is_globalzone
#
# Returns zero (success) if this is the global zone. 1 otherwise.
#
return 1
}
# smf_is_nonglobalzone
#
# Returns zero (success) if this is not the global zone. 1 otherwise.
#
return 1
}
# smf_configure_ip
#
# Returns zero (success) if this zone needs IP to be configured i.e.
# the global zone or has an exclusive stack. 1 otherwise.
#
return 1
}
# smf_dont_configure_ip
#
# Inverse of smf_configure_ip
#
return 1
}
# smf_is_system_labeled
#
# Returns zero (success) if system is labeled (aka Trusted Extensions).
# 1 otherwise.
#
return $?
}
# smf_netstrategy
# -> (_INIT_NET_IF, _INIT_NET_STRATEGY)
#
# Sets _INIT_NET_IF to the name for the network-booted
# interface if we are booting from the network. _INIT_NET_STRATEGY is
# assigned the value of the current network configuration strategy.
# Valid values for _INIT_NET_STRATEGY are "none", "dhcp", and "rarp".
#
# The network boot strategy for a zone is always "none".
#
if smf_is_nonglobalzone; then
return 0
fi
set -- `/sbin/netstrategy`
if [ $? -eq 0 ]; then
[ "$1" = "nfs" -o "$1" = "cachefs" ] && \
else
return 1
fi
}
#
# smf_kill_contract CONTRACT SIGNAL WAIT TIMEOUT
#
# To be called from stop methods of non-transient services.
# Sends SIGNAL to the service contract CONTRACT. If the
# WAIT argument is non-zero, smf_kill_contract will wait
# until the contract is empty before returning, or until
# TIMEOUT expires.
#
# Example, send SIGTERM to contract 200:
#
# smf_kill_contract 200 TERM
#
# Since killing a contract with pkill(1) is not atomic,
# smf_kill_contract will continue to send SIGNAL to CONTRACT
# every second until the contract is empty. This will catch
# races between fork(2) and pkill(1).
#
# Returns 1 if the contract is invalid.
# Returns 2 if WAIT is "1", TIMEOUT is > 0, and TIMEOUT expires.
# Returns 0 on success.
#
time_to_wait=$4
# Verify contract id is valid using pgrep
ret=$?
echo "Error, invalid contract \"$1\"" >&2
return 1
fi
# Return if contract is already empty.
# Kill contract.
if [ $? -gt 1 ] ; then
echo "Error, could not kill contract \"$1\"" >&2
return 1
fi
# Return if WAIT is not set or is "0"
[ -z "$3" ] && return 0
# If contract does not empty, keep killing the contract to catch
# any child processes missed because they were forking
while [ $? -eq 0 ] ; do
time_waited=`/usr/bin/expr $time_waited + 5`
# Return if TIMEOUT was passed, and it has expired
return 2
done
return 0
}
#
# smf(5) method and monitor exit status definitions
# SMF_EXIT_ERR_OTHER, although not defined, encompasses all non-zero
# exit status values.
#