#
# Script for investigating postponed post-installation jobs submitted
# using postrun
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
LC_ALL=C
export LC_ALL
if [ "$PKG_INSTALL_ROOT" != "" ]; then
else
fi
if [ $postrun_root_found = no ]; then
echo "ERROR: postrun-query cannot find SUNWpostrun-root"
exit 1
fi
if [ "$PKG_INSTALL_ROOT" != "" ]; then
else
fi
echo 'Usage: postrun-query [options]'
echo
echo 'Options:'
echo ' -c <class>, --class <class>'
echo ' Only consider jobs the belong to class <class>'
echo
echo ' -e, --exists'
echo ' return 0 if spooled jobs exist 1 otherwise'
echo
echo ' -n, --count'
echo ' print the number of spooled jobs only. The default'
echo ' behaviour is to list all jobs'
echo
echo ' -j <job>, --job <job>'
echo ' display job number <job>'
echo
echo ' -h, -?, --help'
echo ' Display this help'
exit 1
}
# process the command line
while [ $# -gt 0 ]; do
case "$1" in
-h|-\?|--help)
;;
-e|--exists)
;;
-n|--count)
;;
-j|--job)
opt="$1"
if [ $# == 0 ]; then
echo "postrun-query: error: argument expected after $opt"
exit 1
fi
shift
postrun_query_job="$1"
;;
-c|--class)
opt="$1"
if [ $# == 0 ]; then
echo "postrun-query: error: argument expected after $opt"
exit 1
fi
shift
postrun_query_class="$1\$"
;;
--)
break
;;
*)
echo "postrun: error: invalid argument: $1"
exit 1
;;
esac
shift
done
# exit 0 if jobs exist
# exit 1 if no jobs exist
if [ $postrun_query_check_exists = yes ]; then
&& exit 0 || exit 1
fi
# print the # of jobs
if [ $postrun_query_count = yes ]; then
| wc -l
exit 0
fi
# print info about a job
if [ "x$postrun_query_job" != x ]; then
echo "postrun-query: job $postrun_query_job not found"
exit 1
}
echo Job $postrun_query_job
echo "Class(es): $classes"
echo "---commands follow---"
echo "$job_commands"
echo "---end of commands---"
exit 0
fi
# list the jobs
test "x$ctrls" = x \
&& echo "No spooled jobs found." \
|| echo "Job # Class(es) Package(s)"
done