472N/A#!/bin/ksh93
472N/A#
1356N/A# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
472N/A#
1610N/A# Permission is hereby granted, free of charge, to any person obtaining a
472N/A# copy of this software and associated documentation files (the "Software"),
472N/A# to deal in the Software without restriction, including without limitation
919N/A# the rights to use, copy, modify, merge, publish, distribute, sublicense,
919N/A# and/or sell copies of the Software, and to permit persons to whom the
919N/A# Software is furnished to do so, subject to the following conditions:
919N/A#
919N/A# The above copyright notice and this permission notice (including the next
919N/A# paragraph) shall be included in all copies or substantial portions of the
919N/A# Software.
919N/A#
919N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
919N/A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
919N/A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
919N/A# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
919N/A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
919N/A# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
919N/A# DEALINGS IN THE SOFTWARE.
919N/A#
919N/A###########################################################################
472N/A#
472N/A#
472N/A
472N/APATH=/usr/bin:/usr/sbin
493N/A
472N/A. /lib/svc/share/smf_include.sh
970N/A
970N/AUSAGE="Usage: $0 <method>"
970N/A
970N/Aif [ $# -ne 1 ] ; then
1003N/A echo $USAGE
1003N/A exit 2
1003N/Afi
1003N/A
1356N/AMETHOD=$1
1356N/A
1515N/Acase $METHOD in
1356N/A start)
493N/A # Continue with rest of script
493N/A ;;
493N/A -*)
493N/A echo $USAGE
493N/A exit 2
472N/A ;;
472N/A *)
472N/A echo "Invalid method $METHOD"
472N/A exit 2
1451N/A ;;
1451N/Aesac
1451N/A
1451N/Agetprop() {
1466N/A PROPVAL=""
1466N/A svcprop -q -p $1 application/font/fc-cache
493N/A if [ $? -eq 0 ] ; then
472N/A PROPVAL=$(svcprop -p $1 application/font/fc-cache)
1466N/A if [ "$PROPVAL" == "\"\"" ] ; then
1466N/A PROPVAL=""
1466N/A fi
1466N/A return
1466N/A fi
1610N/A return
472N/A}
970N/A
970N/AARGS=""
970N/APOSTCMD=""
472N/ARETVAL=$SMF_EXIT_OK
472N/A
getprop options/force_rebuild
if [ "$PROPVAL" = "true" ] ; then
ARGS="$ARGS -f"
POSTCMD="svccfg -s application/font/fc-cache setprop options/force_rebuild=false"
fi
case "$(uname -p)" in
sparc) ARCH32="sparcv7" ARCH64="sparcv9" ;;
i386) ARCH32="i86" ARCH64="amd64" ;;
*) echo "Unknown architecture $(uname -p)"
exit $SMF_EXIT_ERR_FATAL ;;
esac
# Clean out obsolete cache-file versions - current version is *.cache-7
/usr/bin/find /var/cache/fontconfig -name '*.cache-[2-6]' -exec /bin/rm \{\} \+
# Run 32-bit & 64-bit cache builds in parallel
/usr/bin/${ARCH32}/fc-cache $ARGS &
pid32=$!
/usr/bin/${ARCH64}/fc-cache $ARGS &
pid64=$!
wait $pid32
if [ $? -ne 0 ] ; then
RETVAL=$SMF_EXIT_MON_DEGRADE
fi
wait $pid64
if [ $? -ne 0 ] ; then
RETVAL=$SMF_EXIT_MON_DEGRADE
fi
if [ "$POSTCMD" != "" ] ; then
eval $POSTCMD
fi
exit $RETVAL