3216N/A#!/sbin/sh
3216N/A#
3216N/A# CDDL HEADER START
3216N/A#
3216N/A# The contents of this file are subject to the terms of the
3216N/A# Common Development and Distribution License (the "License").
3216N/A# You may not use this file except in compliance with the License.
3216N/A#
3216N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3216N/A# or http://www.opensolaris.org/os/licensing.
3216N/A# See the License for the specific language governing permissions
3216N/A# and limitations under the License.
3216N/A#
3216N/A# When distributing Covered Code, include this CDDL HEADER in each
3216N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3216N/A# If applicable, add the following below this CDDL HEADER, with the
3216N/A# fields enclosed by brackets "[]" replaced with your own identifying
3216N/A# information: Portions Copyright [yyyy] [name of copyright owner]
3216N/A#
3216N/A# CDDL HEADER END
3216N/A#
3216N/A#
3237N/A# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3216N/A#
3216N/A
3216N/A. /lib/svc/share/smf_include.sh
3216N/A
3216N/Agetprop() {
3216N/A PROPVAL=""
3216N/A if [ -z "$2" ]; then
3216N/A FMRI=svc:/application/pkg/system-repository:default
3216N/A else
3216N/A FMRI=${SMF_FMRI}
3216N/A fi
3216N/A svcprop -q -p $1 ${FMRI}
3216N/A if [ $? -eq 0 ] ; then
3216N/A PROPVAL=$(svcprop -p $1 ${FMRI})
3216N/A if [ "${PROPVAL}" = "\"\"" ] ; then
3216N/A PROPVAL=""
3216N/A fi
3216N/A return
3216N/A fi
3216N/A}
3216N/A
3216N/Acheck_failure() {
3216N/A RESULT=$1
3216N/A MESSAGE=$2
3216N/A NON_FATAL=$3
3216N/A if [ $RESULT -ne 0 ]; then
3216N/A echo $MESSAGE
3216N/A if [ -n "$NON_FATAL" ]; then
3216N/A return
3216N/A fi
3216N/A exit $SMF_EXIT_ERR_FATAL
3216N/A fi
3216N/A}
3216N/A
3216N/Arun_htcacheclean() {
3216N/A if [ "${SYSREPO_CACHE_DIR}" != "None" ] && [ "${SYSREPO_CACHE_DIR}" != "memory" ]; then
3216N/A # Start a cache cleaning process, limiting the cache to
3216N/A # ${SYSREPO_CACHE_MAX} megabytes, being nice about
3216N/A # scheduling and removing empty directories if needed.
3237N/A /usr/apache2/2.4/bin/htcacheclean \
3216N/A -l ${SYSREPO_CACHE_MAX}M -n \
3216N/A -p ${SYSREPO_CACHE_DIR} \
3216N/A -P ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid \
3216N/A -t
3216N/A check_failure $? "htcacheclean failed to run cleanly"
3216N/A fi
3216N/A}
3216N/A
3216N/Akill_htcacheclean() {
3216N/A if [ -f ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid ]; then
3216N/A PID=$(< ${SYSREPO_CACHE_DIR}/../sysrepo_htcacheclean.pid)
3216N/A echo "Previous htcacheclean pid file found - killing process $PID"
3216N/A /usr/bin/kill -TERM $PID
3216N/A check_failure $? "failed to kill htcacheclean process $PID" \
3216N/A "not_fatal"
3216N/A fi
3216N/A}
3216N/A
3216N/Agetprop config/cache_dir
3216N/Aif [ "${PROPVAL}" != "" ] ; then
3216N/A SYSREPO_CACHE_DIR=${PROPVAL}
3216N/Afi
3216N/A
3216N/Agetprop config/cache_max
3216N/Aif [ "${PROPVAL}" != "" ] ; then
3216N/A SYSREPO_CACHE_MAX=${PROPVAL}
3216N/Afi
3216N/A
3216N/Akill_htcacheclean
3216N/Arun_htcacheclean
3216N/A
3216N/Aexit $SMF_EXIT_OK