svc-pkg-depot revision 1527
# See the License for the specific language governing permissions # and limitations under the License. # When distributing Covered Code, include this CDDL HEADER in each # 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] # Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Load SMF constants and functions echo "this script can only be invoked by smf(5)" # boolean_props are properties which are communicated to the depot # via a flag being present or absent on the command line. # short_option_props are properties which are communicated to the depot # via a single character flag which takes an argument. # short_option_props are properties which are communicated to the depot # via a long option flag which takes an argument. proxy_base sort_file_max_size ssl_cert_file ssl_dialog ssl_key_file \ "log-access" "log-errors" "proxy-base" "sort-file-max-size" \
"ssl-cert-file" "ssl-dialog" "ssl-key-file" "writable-root" # retrieve the pkg_root property. If the variable is left empty # make sure pkg_root ends with a / # adjust the PYTHONPATH to point to the current environment # we need to make sure to adjust the PYTHONPATH accordingly # to a Python 2.4 or 2.6 environment # Go through each property in boolean_props and, if its value is set # to true in SMF, add the appropriate command line flag to the string. echo "service property pkg/$b not defined for" \
# If the property is set to true, add the flag. if [[
$val ==
'true' ]];
then # Go through each property in short_option_props and, if its value is # set to something other than "", add the appropriate command line # flag and argument to the string. echo "service property pkg/$o not defined for" \
# If the SMF property is set to something other than 'none', add # the flag and its argument to the command. if [[
$val !=
'""' ]];
then # Go through each property in long_option_props and, if its value is # set to something other than "", add the appropriate command line # flag and argument to the string. echo "service property pkg/$o not defined for" \
# check if content_root is a relative or absolute path, if # relative append to pkg_root if [[ $o ==
'content_root' ]];
then # pkg_root has been checked to end with a slash # If the SMF property is set to something other than 'none', add # the flag and its argument to the command. if [[ $o ==
'ssl_dialog' &&
$val ==
'smf' ]];
then elif [[
$val !=
'""' ]];
then # Determine if fork and exec are needed. # If we don't need them, drop fork and exec. echo "Dropping fork(2) and exec(2) privileges." # If this process has net_privaddr, then we pass it along. # If not, we ensure that we don't specify it, since that will # cause ppriv to throw an error. echo "Dropping net_privaddr privilege." # We build up the privileges available starting with "basic". # This provides some protection even when the depot runs as root. # Build the command to start pkg.depotd with the specified options. # Echo the command so that the log contains the command used to start # Strategy: First, try shutting down depot using polite kill. Use up # as much as possible of the allotted timeout period waiting for polite # kill to take effect. As time runs out, try a more aggressive kill. # Note that we're working around an oddity in smf_kill_contract: it # waits in 5 second chunks and can overshoot the specified timeout # by as many as 4 seconds. Example: a specified wait of 6 will result # in a wait of 10 seconds in reality. Since we may potentially do a # first kill and then a second, we must ensure that at least 8 seconds # of slop is left in reserve. To be paranoid, we go for 10. # '2' indicates timeout with non-empty contract. echo "Gentle contract kill timed out after" "$POLITE seconds, trying SIGKILL." >&
2 # Again, despite the specified timeout, this will # take a minimum of 5 seconds to complete. # If the timeout is too short, we just try once, politely. echo "Usage: $0 { start | stop }"