17c478bd9Sstevel@tonic-gate#!/sbin/sh
27c478bd9Sstevel@tonic-gate#
37c478bd9Sstevel@tonic-gate# CDDL HEADER START
47c478bd9Sstevel@tonic-gate#
57c478bd9Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6fea9cb91Slq# Common Development and Distribution License (the "License").
7fea9cb91Slq# You may not use this file except in compliance with the License.
87c478bd9Sstevel@tonic-gate#
97c478bd9Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate# See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate# and limitations under the License.
137c478bd9Sstevel@tonic-gate#
147c478bd9Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate#
207c478bd9Sstevel@tonic-gate# CDDL HEADER END
217c478bd9Sstevel@tonic-gate#
22fea9cb91Slq
237c478bd9Sstevel@tonic-gate#
24aecfc01dSrui zang - Sun Microsystems - Beijing China# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate# Use is subject to license terms.
26*d3477c6dSJoshua M. Clulow# Copyright 2015 Joyent, Inc.
277c478bd9Sstevel@tonic-gate#
28aecfc01dSrui zang - Sun Microsystems - Beijing China# This method script manages all vt logins including system
29aecfc01dSrui zang - Sun Microsystems - Beijing China# console login.
307c478bd9Sstevel@tonic-gate#
317c478bd9Sstevel@tonic-gate# For modifying parameters passed to ttymon, do not edit
32bbf21555SRichard Lowe# this script. Instead use svccfg(8) to modify the SMF
337c478bd9Sstevel@tonic-gate# repository. For example:
347c478bd9Sstevel@tonic-gate#
357c478bd9Sstevel@tonic-gate# # svccfg
367c478bd9Sstevel@tonic-gate# svc:> select system/console-login
377c478bd9Sstevel@tonic-gate# svc:/system/console-login> setprop ttymon/terminal_type = "xterm"
387c478bd9Sstevel@tonic-gate# svc:/system/console-login> exit
397c478bd9Sstevel@tonic-gate
40aecfc01dSrui zang - Sun Microsystems - Beijing China. /lib/svc/share/smf_include.sh
41aecfc01dSrui zang - Sun Microsystems - Beijing China
427c478bd9Sstevel@tonic-gategetproparg() {
43a1e4d62bShshaw	val=`svcprop -p $2 $SMF_FMRI`
44fea9cb91Slq	[ -n "$val" ] && [ "$val" != "\"\"" ] && echo $1 $val
457c478bd9Sstevel@tonic-gate}
467c478bd9Sstevel@tonic-gate
47*d3477c6dSJoshua M. Clulow# The service configuration invokes this script with "%i", the name of the
48*d3477c6dSJoshua M. Clulow# instance, as the first argument.
49*d3477c6dSJoshua M. Clulowinstance="$1"
50*d3477c6dSJoshua M. Clulowif [ -z "$instance" ]; then
51*d3477c6dSJoshua M. Clulow	exit $SMF_EXIT_ERR_CONFIG
52*d3477c6dSJoshua M. Clulowfi
53*d3477c6dSJoshua M. Clulow
54*d3477c6dSJoshua M. Clulowcase "$instance" in
55*d3477c6dSJoshua M. Clulowvt*)
56*d3477c6dSJoshua M. Clulow	# This instance is for one of the virtual terminal devices.  Check to
57*d3477c6dSJoshua M. Clulow	# see if the vt subsystem is initialised:
58*d3477c6dSJoshua M. Clulow	if smf_dont_configure_vt; then
59*d3477c6dSJoshua M. Clulow		/usr/sbin/svcadm disable "$SMF_FMRI"
60*d3477c6dSJoshua M. Clulow		exit $SMF_EXIT_OK
61*d3477c6dSJoshua M. Clulow	fi
62*d3477c6dSJoshua M. Clulow	;;
63*d3477c6dSJoshua M. Clulowesac
64*d3477c6dSJoshua M. Clulow
657c478bd9Sstevel@tonic-gateargs="-g"
667c478bd9Sstevel@tonic-gate
67a1e4d62bShshawval=`svcprop -p ttymon/device $SMF_FMRI`
687c478bd9Sstevel@tonic-gate# if this isn't set, recover a little
69aecfc01dSrui zang - Sun Microsystems - Beijing China[ -z "$val" ] && val="/dev/console"
70aecfc01dSrui zang - Sun Microsystems - Beijing China
71aecfc01dSrui zang - Sun Microsystems - Beijing Chinaif [ "$val" = "/dev/vt/1" ]; then
72aecfc01dSrui zang - Sun Microsystems - Beijing China	echo "ERROR: ttymon/device cannot be configured to /dev/vt/1."
73aecfc01dSrui zang - Sun Microsystems - Beijing China	exit $SMF_EXIT_ERR_CONFIG
74aecfc01dSrui zang - Sun Microsystems - Beijing Chinafi
75aecfc01dSrui zang - Sun Microsystems - Beijing China
767c478bd9Sstevel@tonic-gateargs="$args -d $val"
777c478bd9Sstevel@tonic-gate
787c478bd9Sstevel@tonic-gateargs="$args `getproparg -l ttymon/label`"
79fea9cb91Slq
807c478bd9Sstevel@tonic-gateargs="$args `getproparg -T ttymon/terminal_type`"
81fea9cb91Slq
827c478bd9Sstevel@tonic-gateargs="$args `getproparg -m ttymon/modules`"
837c478bd9Sstevel@tonic-gate
84a1e4d62bShshawval=`svcprop -p ttymon/nohangup $SMF_FMRI`
857c478bd9Sstevel@tonic-gate[ "$val" = "true" ] && args="$args -h"
867c478bd9Sstevel@tonic-gate
87a1e4d62bShshawval=`svcprop -p ttymon/timeout $SMF_FMRI`
887c478bd9Sstevel@tonic-gate[ -n "$val" -a "$val" != "0" ] && args="$args -t $val"
897c478bd9Sstevel@tonic-gate
90a1e4d62bShshawval=`svcprop -p ttymon/prompt $SMF_FMRI`
917c478bd9Sstevel@tonic-gateif [ -n "$val" ]; then
927c478bd9Sstevel@tonic-gate	prompt=`eval echo $val`
937c478bd9Sstevel@tonic-gate	exec /usr/lib/saf/ttymon $args -p "`eval echo $prompt` "
947c478bd9Sstevel@tonic-gateelse
957c478bd9Sstevel@tonic-gate	exec /usr/lib/saf/ttymon $args
967c478bd9Sstevel@tonic-gatefi
97