xref: /illumos-gate/usr/src/cmd/svc/milestone/console-login (revision 8b80e8cb6855118d46f605e91b5ed4ce83417395)
1#!/sbin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License (the "License").
7# You may not use this file except in compliance with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22
23#
24# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27# This method script manages all vt logins including system
28# console login.
29#
30# For modifying parameters passed to ttymon, do not edit
31# this script. Instead use svccfg(1m) to modify the SMF
32# repository. For example:
33#
34# # svccfg
35# svc:> select system/console-login
36# svc:/system/console-login> setprop ttymon/terminal_type = "xterm"
37# svc:/system/console-login> exit
38
39. /lib/svc/share/smf_include.sh
40
41if [ "$1" != "default" ]; then
42	if smf_dont_configure_vt; then
43		/usr/sbin/svcadm disable $SMF_FMRI
44		exit $SMF_EXIT_OK
45	fi
46fi
47
48getproparg() {
49	val=`svcprop -p $2 $SMF_FMRI`
50	[ -n "$val" ] && [ "$val" != "\"\"" ] && echo $1 $val
51}
52
53args="-g"
54
55val=`svcprop -p ttymon/device $SMF_FMRI`
56# if this isn't set, recover a little
57[ -z "$val" ] && val="/dev/console"
58
59if [ "$val" = "/dev/vt/1" ]; then
60	echo "ERROR: ttymon/device cannot be configured to /dev/vt/1."
61	exit $SMF_EXIT_ERR_CONFIG
62fi
63
64args="$args -d $val"
65
66args="$args `getproparg -l ttymon/label`"
67
68args="$args `getproparg -T ttymon/terminal_type`"
69
70args="$args `getproparg -m ttymon/modules`"
71
72val=`svcprop -p ttymon/nohangup $SMF_FMRI`
73[ "$val" = "true" ] && args="$args -h"
74
75val=`svcprop -p ttymon/timeout $SMF_FMRI`
76[ -n "$val" -a "$val" != "0" ] && args="$args -t $val"
77
78val=`svcprop -p ttymon/prompt $SMF_FMRI`
79if [ -n "$val" ]; then
80	prompt=`eval echo $val`
81	exec /usr/lib/saf/ttymon $args -p "`eval echo $prompt` "
82else
83	exec /usr/lib/saf/ttymon $args
84fi
85