860N/A#!/usr/bin/sh
860N/A#
860N/A# Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
860N/A#
860N/A# This script should be run from the CUPS scheduler service start method.
860N/A#
860N/A# usage: /usr/lib/cups/startup/gutenprint <fmri> <pg/prop>
860N/A#
860N/A# where: <fmri> ... FMRI of the CUPS scheduler service
860N/A# <pg/prop> ... property group/name where to store status
860N/A#
860N/A
860N/ASVC=$1
860N/APROP=$2
860N/A
860N/A# verify input arguments
860N/Aif [ -z "$SVC" -o -z "$PROP" ] ; then
860N/A echo "$0: Invalid arguments."
860N/A echo "usage: $0 <fmri> <pg/prop>"
860N/A exit 1
860N/Afi
860N/A
912N/A# package name
912N/APKG="pkg:/print/filter/gutenprint"
912N/A
860N/A# determine the package version
912N/AVER=`pkg contents -H -a name=pkg.fmri -o value $PKG | cut -d @ -f 2`
860N/Aif [ -z "$VER" ] ; then
912N/A echo "$0: Failed to read $PKG package version."
860N/A exit 1
860N/Afi
860N/A
860N/A# read the value of status property, if it exists
860N/Aif svcprop -q -p "$PROP" "$SVC" ; then
860N/A VAL=`svcprop -p "$PROP" "$SVC"`
860N/Afi
860N/A
860N/A# compare the value with package version
860N/Aif [ "$VAL" = "$VER" ] ; then
860N/A # PPD files already updated for this package version
860N/A exit 0
860N/Afi
860N/A
860N/A# update PPD files
860N/Aif ! /usr/sbin/cups-genppdupdate ; then
860N/A echo "$0: Failed to update PPD files."
860N/A exit 1
860N/Afi
860N/A
860N/A# store status into the SMF repository
860N/Asvccfg -s "$SVC" setprop "$PROP" = astring: "$VER"
860N/A
860N/Aexit 0