svc-pkg-depot revision 1902
0N/A# The contents of this file are subject to the terms of the 0N/A# Common Development and Distribution License (the "License"). 0N/A# You may not use this file except in compliance with the License. 0N/A# See the License for the specific language governing permissions 0N/A# and limitations under the License. 0N/A# When distributing Covered Code, include this CDDL HEADER in each 0N/A# If applicable, add the following below this CDDL HEADER, with the 0N/A# fields enclosed by brackets "[]" replaced with your own identifying 0N/A# information: Portions Copyright [yyyy] [name of copyright owner] 0N/A# Copyright (c) 2009, 2010 Oracle and/or its affiliates. All rights reserved. 0N/A# Load SMF constants and functions 0N/A echo "this script can only be invoked by smf(5)" 0N/A # Handles depot startup 0N/A # boolean_props are properties which are communicated to the depot 0N/A # via a flag being present or absent on the command line. 0N/A # short_option_props are properties which are communicated to the depot 0N/A # via a single character flag which takes an argument. 0N/A # short_option_props are properties which are communicated to the depot 0N/A # via a long option flag which takes an argument. 0N/A log_errors proxy_base sort_file_max_size ssl_cert_file \ 0N/A ssl_dialog ssl_key_file writable_root" 0N/A "file-root" "log-access" "log-errors" "proxy-base" \
0N/A "sort-file-max-size" "ssl-cert-file" "ssl-dialog" "ssl-key-file" \
0N/A # retrieve the pkg_root property. If the variable is left empty 1667N/A # make sure pkg_root ends with a / 0N/A # adjust the PYTHONPATH to point to the current environment 0N/A # 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 }"