724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#!/bin/ksh93
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# Permission is hereby granted, free of charge, to any person obtaining a
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# copy of this software and associated documentation files (the "Software"),
9afe19d634946d50eab30e3b90cb5cebcde39eeaDaniel Lezcano# to deal in the Software without restriction, including without limitation
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# the rights to use, copy, modify, merge, publish, distribute, sublicense,
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# and/or sell copies of the Software, and to permit persons to whom the
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# Software is furnished to do so, subject to the following conditions:
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# The above copyright notice and this permission notice (including the next
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# paragraph) shall be included in all copies or substantial portions of the
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# Software.
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# DEALINGS IN THE SOFTWARE.
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand
724e753cb0055b84f896522e8c5ec45ad996c195Michel NormandUSAGE="Usage: $0 [-d <display>] [-c <class>] <method> [-- <X server arguments>]"
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand
724e753cb0055b84f896522e8c5ec45ad996c195Michel NormandPATH=/usr/bin:/usr/sbin
91480a0f0a62732f3115d556b689d62d574294aeDaniel Lezcano
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#########
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand# Default values
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand#
2a59a68183e55e38beedb6442938e31eb7d4749cSerge Hallyn# Users must not modify this script to change them - change via SMF properties
2a59a68183e55e38beedb6442938e31eb7d4749cSerge Hallyn#
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand
00b3c2e2845792face31017e905f9b8b4ea48653Cedric Le GoaterDISPLAY="0"
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight EngenCLASSES=""
00b3c2e2845792face31017e905f9b8b4ea48653Cedric Le Goater
00b3c2e2845792face31017e905f9b8b4ea48653Cedric Le Goaterwhile getopts c:d: opt; do
2a59a68183e55e38beedb6442938e31eb7d4749cSerge Hallyn case $opt in
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand c) if [[ "$OPTARG" != "default" ]] ; then
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand CLASSES="$CLASSES -c $OPTARG"
b515981702133b9aaea1aff378493f054c14d46cDwight Engen fi ;;
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engen d) DISPLAY="$OPTARG";;
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand ?) echo $USAGE ; exit 2;;
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand esac
adaeaa992a6a7a6af923416a1c36b63858055533Daniel Lezcanodone
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcanoshift `expr $OPTIND - 1`
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engen
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight EngenMETHOD=$1
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engenif [[ $# -lt 1 ]] ; then
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano print -u2 $USAGE
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engen exit 2
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engenfi
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcanoshift
ef6e34eec8d5a9f1447462d6080facb674b3ccdbDwight Engen
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcanocase $METHOD in
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano start)
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano # Continue with rest of script
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano ;;
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn *)
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn echo "Invalid method $METHOD"
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn exit 2
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn ;;
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallynesac
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallynif [[ "$1" = "--" ]] ; then
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn shift
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallynelse
80bcb05357a90cc9a2e21e942a2b0a53cddfa7a6Serge Hallyn if [[ "$1" != "" ]] ; then
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano echo $USAGE
ded1d23faabc31a5bbbf5f52c17423c59f63e23aDaniel Lezcano exit 2
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normand fi
724e753cb0055b84f896522e8c5ec45ad996c195Michel Normandfi
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn# If the X server is started with SIGUSR1 set to ignore, then it
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn# sends SIGUSR1 to its parent process when it is ready to run
67e571de63a8e465dc8f1b17e16744a1d3fb552cStéphane GraberXserver_ready() {
2a59a68183e55e38beedb6442938e31eb7d4749cSerge Hallyn exit 0
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn}
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyntrap Xserver_ready USR1
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn(trap '' USR1 ; exec /usr/bin/Xserver $CLASSES :$DISPLAY $* &)
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn
13f5be6276100761eaeddd77b7b55fbec6b0c9abSerge Hallyn