xref: /illumos-gate/usr/src/cmd/svc/milestone/console-login (revision d3477c6d12fcb86e8bb78faf6993ae16c81cbe12)
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# Copyright 2015 Joyent, Inc.
27#
28# This method script manages all vt logins including system
29# console login.
30#
31# For modifying parameters passed to ttymon, do not edit
32# this script. Instead use svccfg(8) to modify the SMF
33# repository. For example:
34#
35# # svccfg
36# svc:> select system/console-login
37# svc:/system/console-login> setprop ttymon/terminal_type = "xterm"
38# svc:/system/console-login> exit
39
40. /lib/svc/share/smf_include.sh
41
42getproparg() {
43	val=`svcprop -p $2 $SMF_FMRI`
44	[ -n "$val" ] && [ "$val" != "\"\"" ] && echo $1 $val
45}
46
47# The service configuration invokes this script with "%i", the name of the
48# instance, as the first argument.
49instance="$1"
50if [ -z "$instance" ]; then
51	exit $SMF_EXIT_ERR_CONFIG
52fi
53
54case "$instance" in
55vt*)
56	# This instance is for one of the virtual terminal devices.  Check to
57	# see if the vt subsystem is initialised:
58	if smf_dont_configure_vt; then
59		/usr/sbin/svcadm disable "$SMF_FMRI"
60		exit $SMF_EXIT_OK
61	fi
62	;;
63esac
64
65args="-g"
66
67val=`svcprop -p ttymon/device $SMF_FMRI`
68# if this isn't set, recover a little
69[ -z "$val" ] && val="/dev/console"
70
71if [ "$val" = "/dev/vt/1" ]; then
72	echo "ERROR: ttymon/device cannot be configured to /dev/vt/1."
73	exit $SMF_EXIT_ERR_CONFIG
74fi
75
76args="$args -d $val"
77
78args="$args `getproparg -l ttymon/label`"
79
80args="$args `getproparg -T ttymon/terminal_type`"
81
82args="$args `getproparg -m ttymon/modules`"
83
84val=`svcprop -p ttymon/nohangup $SMF_FMRI`
85[ "$val" = "true" ] && args="$args -h"
86
87val=`svcprop -p ttymon/timeout $SMF_FMRI`
88[ -n "$val" -a "$val" != "0" ] && args="$args -t $val"
89
90val=`svcprop -p ttymon/prompt $SMF_FMRI`
91if [ -n "$val" ]; then
92	prompt=`eval echo $val`
93	exec /usr/lib/saf/ttymon $args -p "`eval echo $prompt` "
94else
95	exec /usr/lib/saf/ttymon $args
96fi
97