6100N/A#! /bin/ksh93
6100N/A
6100N/A#
6100N/A# CDDL HEADER START
6100N/A#
6100N/A# The contents of this file are subject to the terms of the
6100N/A# Common Development and Distribution License (the "License").
6100N/A# You may not use this file except in compliance with the License.
6100N/A#
6100N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6100N/A# or http://www.opensolaris.org/os/licensing.
6100N/A# See the License for the specific language governing permissions
6100N/A# and limitations under the License.
6100N/A#
6100N/A# When distributing Covered Code, include this CDDL HEADER in each
6100N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6100N/A# If applicable, add the following below this CDDL HEADER, with the
6100N/A# fields enclosed by brackets "[]" replaced with your own identifying
6100N/A# information: Portions Copyright [yyyy] [name of copyright owner]
6100N/A#
6100N/A# CDDL HEADER END
6100N/A#
6100N/A
6100N/A#
6100N/A# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
6100N/A#
6100N/A
6100N/APATH=/usr/bin:/usr/sbin
6100N/A
6100N/A. /lib/svc/share/smf_include.sh
6100N/A
6100N/AUSAGE="Usage: $0 <method>"
6100N/A
6100N/Aif [[ $# -ne 1 ]] ; then
6100N/A print "$USAGE" >&2
6100N/A exit 2
6100N/Afi
6100N/A
6100N/AMETHOD="$1"
6100N/A
6100N/Acase $METHOD in
6100N/A start|refresh)
6100N/A # Continue with rest of script
6100N/A ;;
6100N/A -*)
6100N/A print "$USAGE" >&2
6100N/A exit 2
6100N/A ;;
6100N/A *)
6100N/A print "Invalid method $METHOD" >&2
6100N/A exit 2
6100N/A ;;
6100N/Aesac
6100N/A
6100N/ANEED_COMPILE=0
6100N/ASCHEMA_DIR='/usr/share/glib-2.0/schemas'
6100N/ACOMPILED_FILE="${SCHEMA_DIR}/gschemas.compiled"
6100N/A
6100N/Aif [[ ! -r "${COMPILED_FILE}" ]] ; then
6100N/A # Need to create initial file
6100N/A NEED_COMPILE=1
6100N/Aelif [[ "${SCHEMA_DIR}" -nt "${COMPILED_FILE}" ]] ; then
6100N/A # Directory has been updated - file may have been added or removed
6100N/A NEED_COMPILE=1
6100N/Aelif [[ -n "$(find ${SCHEMA_DIR} -newer ${COMPILED_FILE})" ]] ; then
6100N/A # At least one file has been updated
6100N/A NEED_COMPILE=1
6100N/Afi
6100N/A
6100N/Aif [[ "${NEED_COMPILE}" -ne 0 ]] ; then
6100N/A umask 022
6100N/A /usr/bin/glib-compile-schemas "${SCHEMA_DIR}" 2>&1
6100N/A result=$?
6100N/A if [[ $result -ne 0 ]] ; then
6100N/A print "glib-compile-schemas failed with exit code $result"
6100N/A exit $SMF_EXIT_ERR_FATAL
6100N/A fi
6100N/A if [[ ! -r "${COMPILED_FILE}" ]] ; then
6611N/A if [[ -n "$(find ${SCHEMA_DIR} -name '*.gschema.xml')" ]] ; then
6611N/A exit $SMF_EXIT_ERR_FATAL
6611N/A fi
6611N/A else
6100N/A # Since glib-compile-schemas renames the result into place, update
6100N/A # the file mtime after moving so it matches the directory mtime.
6611N/A touch -c -r "${SCHEMA_DIR}" "${COMPILED_FILE}"
6611N/A fi
6100N/Afi
6100N/A
6100N/Aexit $SMF_EXIT_OK