svc-pkg-sysrepo revision 2858
af062818b47340eef15700d2f0211576ba3506eevboxsync# CDDL HEADER START
af062818b47340eef15700d2f0211576ba3506eevboxsync# The contents of this file are subject to the terms of the
af062818b47340eef15700d2f0211576ba3506eevboxsync# Common Development and Distribution License (the "License").
af062818b47340eef15700d2f0211576ba3506eevboxsync# You may not use this file except in compliance with the License.
af062818b47340eef15700d2f0211576ba3506eevboxsync# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
af062818b47340eef15700d2f0211576ba3506eevboxsync# See the License for the specific language governing permissions
af062818b47340eef15700d2f0211576ba3506eevboxsync# and limitations under the License.
af062818b47340eef15700d2f0211576ba3506eevboxsync# When distributing Covered Code, include this CDDL HEADER in each
af062818b47340eef15700d2f0211576ba3506eevboxsync# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
af062818b47340eef15700d2f0211576ba3506eevboxsync# If applicable, add the following below this CDDL HEADER, with the
af062818b47340eef15700d2f0211576ba3506eevboxsync# fields enclosed by brackets "[]" replaced with your own identifying
af062818b47340eef15700d2f0211576ba3506eevboxsync# information: Portions Copyright [yyyy] [name of copyright owner]
af062818b47340eef15700d2f0211576ba3506eevboxsync# CDDL HEADER END
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync# Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.
af062818b47340eef15700d2f0211576ba3506eevboxsync# Calling $APACHE_BIN/apachectl would source $APACHE_BIN/envvars, which
af062818b47340eef15700d2f0211576ba3506eevboxsync# in turn would source /etc/apache2/2.2/envvars, if it exists.
af062818b47340eef15700d2f0211576ba3506eevboxsync# We want to keep the system-repository service completely separate from
af062818b47340eef15700d2f0211576ba3506eevboxsync# the site system configuration used by svc:/network/http:apache22 avoiding
af062818b47340eef15700d2f0211576ba3506eevboxsync# /etc/apache2, which means we must avoid apachectl.
af062818b47340eef15700d2f0211576ba3506eevboxsync# In this method script, we call httpd directly instead, but as a result,
af062818b47340eef15700d2f0211576ba3506eevboxsync# we also need to include the relevant contents of $APACHE_BIN/envvars -
af062818b47340eef15700d2f0211576ba3506eevboxsync# setting $LD_LIBRARY_PATH as it does.
af062818b47340eef15700d2f0211576ba3506eevboxsyncLD_LIBRARY_PATH=${APACHE_HOME}/lib/64:${LD_LIBRARY_PATH}
af062818b47340eef15700d2f0211576ba3506eevboxsync if [ $? -eq 0 ] ; then
af062818b47340eef15700d2f0211576ba3506eevboxsync if [ $RESULT -ne 0 ]; then
af062818b47340eef15700d2f0211576ba3506eevboxsync check_failure $? "pkg.sysrepo: failed to create Apache configuration"
af062818b47340eef15700d2f0211576ba3506eevboxsync # if we dropped to maintenance and are in the process of clearing
af062818b47340eef15700d2f0211576ba3506eevboxsync # that state, we may have a htcacheclean processes hanging around.
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync # Start a cache cleaning daemon, scanning every 2 weeks,
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync # being intelligent about only running if the cache has changed,
af062818b47340eef15700d2f0211576ba3506eevboxsync # limiting the cache to ${SYSREPO_CACHE_MAX} megabytes, being
af062818b47340eef15700d2f0211576ba3506eevboxsync # nice about scheduling and removing empty directories if
af062818b47340eef15700d2f0211576ba3506eevboxsync -d${interval} -i -l ${SYSREPO_CACHE_MAX}M -n \
af062818b47340eef15700d2f0211576ba3506eevboxsync -P ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid \
af062818b47340eef15700d2f0211576ba3506eevboxsync check_failure $? "htcacheclean failed to run cleanly"
af062818b47340eef15700d2f0211576ba3506eevboxsync if [ -f ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid ]; then
040b4a09341f574825386333398110f4db3e1e51vboxsync PID=$(< ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid)
040b4a09341f574825386333398110f4db3e1e51vboxsync check_failure $? "failed to kill htcacheclean process $PID" \
af062818b47340eef15700d2f0211576ba3506eevboxsync # drop privileges now that we've written our configuration
af062818b47340eef15700d2f0211576ba3506eevboxsync ${HTTPD} -f ${SYSREPO_RUNTIME_DIR}/sysrepo_httpd.conf \
af062818b47340eef15700d2f0211576ba3506eevboxsync check_failure $? "Server failed to start. Check the SMF service log or the error log at ${SYSREPO_LOG_DIR}/error_log for more information, if any."
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync # drop privileges now that we've written our configuration
af062818b47340eef15700d2f0211576ba3506eevboxsync ${HTTPD} -f ${SYSREPO_RUNTIME_DIR}/sysrepo_httpd.conf \
af062818b47340eef15700d2f0211576ba3506eevboxsync check_failure $? "Server failed to refresh. Check the SMF service log or the error log at ${SYSREPO_LOG_DIR}/error_log for more information, if any."
a3133ef29cdf3656735d569fd64e54c9286effc0vboxsync ${HTTPD} -f ${SYSREPO_RUNTIME_DIR}/sysrepo_httpd.conf \
589fd26cedb2b4ebbed14f2964cad03cc8ebbca2vboxsync check_failure $? "Server failed to stop. Check the SMF service log or the error log at ${SYSREPO_LOG_DIR}/error_log for more information, if any."
af062818b47340eef15700d2f0211576ba3506eevboxsync echo "Usage: $0 {start|stop|refresh}"