syscons revision 227366
170856Sjhb#!/bin/sh - 270856Sjhb# 370856Sjhb# Copyright (c) 2000 The FreeBSD Project 470856Sjhb# All rights reserved. 570856Sjhb# 670856Sjhb# Redistribution and use in source and binary forms, with or without 770856Sjhb# modification, are permitted provided that the following conditions 870856Sjhb# are met: 970856Sjhb# 1. Redistributions of source code must retain the above copyright 1070856Sjhb# notice, this list of conditions and the following disclaimer. 1170856Sjhb# 2. Redistributions in binary form must reproduce the above copyright 1270856Sjhb# notice, this list of conditions and the following disclaimer in the 1370856Sjhb# documentation and/or other materials provided with the distribution. 1470856Sjhb# 1570856Sjhb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1670856Sjhb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1770856Sjhb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1870856Sjhb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1970856Sjhb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2070856Sjhb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2170856Sjhb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2270856Sjhb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2370856Sjhb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2470856Sjhb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2570856Sjhb# SUCH DAMAGE. 2670856Sjhb# 2770856Sjhb# $FreeBSD: head/etc/rc.d/syscons 227366 2011-11-08 23:02:32Z jilles $ 2870856Sjhb# 2970856Sjhb 30100280Sgordon# PROVIDE: syscons 31153430Siedowse# REQUIRE: LOGIN 32136224Smtm# KEYWORD: nojail 33100280Sgordon 34100280Sgordon. /etc/rc.subr 35100280Sgordon 36100280Sgordonname="syscons" 37156331Semaxextra_commands="setkeyboard" 38156331Semaxsetkeyboard_cmd="syscons_setkeyboard" 39102993Sfennerstart_precmd="syscons_precmd" 40102993Sfennerstart_cmd="syscons_start" 41165389Syarstop_cmd=":" 42100280Sgordon 4370856Sjhb# stdin must be redirected because it might be for a serial console 4470856Sjhb# 4570856Sjhbkbddev=/dev/ttyv0 4670856Sjhbviddev=/dev/ttyv0 4770856Sjhb 48179981Smtm_sc_config="syscons" 49179981Smtm_sc_initdone= 50179981Smtmsc_init() 51179981Smtm{ 52179981Smtm if [ -z "${_sc_initdone}" ]; then 53179981Smtm echo -n "Configuring ${_sc_config}:" 54179981Smtm _sc_initdone=yes 55179981Smtm fi 56179981Smtm} 57179981Smtm 58156782Semax# helper 59156782Semaxsyscons_configure_keyboard() 60156331Semax{ 61102993Sfenner # keymap 62102993Sfenner # 63102993Sfenner case ${keymap} in 64102993Sfenner [Nn][Oo] | '') 65102993Sfenner ;; 66102993Sfenner *) 67179981Smtm sc_init 68102993Sfenner echo -n ' keymap'; kbdcontrol < ${kbddev} -l ${keymap} 69102993Sfenner ;; 70102993Sfenner esac 7170856Sjhb 72102993Sfenner # keyrate 73102993Sfenner # 74102993Sfenner case ${keyrate} in 75102993Sfenner [Nn][Oo] | '') 76102993Sfenner ;; 77102993Sfenner *) 78179981Smtm sc_init 79102993Sfenner echo -n ' keyrate'; kbdcontrol < ${kbddev} -r ${keyrate} 80102993Sfenner ;; 81102993Sfenner esac 8270856Sjhb 83102993Sfenner # keybell 84102993Sfenner # 85102993Sfenner case ${keybell} in 86102993Sfenner [Nn][Oo] | '') 87102993Sfenner ;; 88102993Sfenner *) 89179981Smtm sc_init 90102993Sfenner echo -n ' keybell'; kbdcontrol < ${kbddev} -b ${keybell} 91102993Sfenner ;; 92102993Sfenner esac 9370856Sjhb 94102993Sfenner # change function keys 95102993Sfenner # 96102993Sfenner case ${keychange} in 97102993Sfenner [Nn][Oo] | '') 98102993Sfenner ;; 99102993Sfenner *) 100179981Smtm sc_init 101102993Sfenner echo -n ' keychange' 102227366Sjilles set -- ${keychange} 103102993Sfenner while [ $# -gt 0 ]; do 104102993Sfenner kbdcontrol <${kbddev} -f "$1" "$2" 105102993Sfenner shift; shift 106102993Sfenner done 107102993Sfenner ;; 108102993Sfenner esac 10970856Sjhb 110156782Semax # set this keyboard mode for all virtual terminals 111156782Semax # 112156782Semax if [ -n "${allscreens_kbdflags}" ]; then 113179981Smtm sc_init 114156782Semax echo -n ' allscreens_kbd' 115156782Semax for ttyv in /dev/ttyv*; do 116156782Semax kbdcontrol ${allscreens_kbdflags} < ${ttyv} > ${ttyv} 2>&1 117156782Semax done 118156782Semax fi 119156782Semax} 120156782Semax 121156782Semaxsyscons_setkeyboard() 122156782Semax{ 123156782Semax kbd=$1 124208060Sdougb 125156782Semax if [ -z "${kbd}" ]; then 126156782Semax return 1 127156782Semax fi 128156782Semax 129156782Semax # Check if the kbdmux(4) is the current active keyboard 130156782Semax kbdcontrol -i < ${kbddev} | grep kbdmux > /dev/null 2>&1 131167889Sbrooks if [ $? -ne 0 ]; then 132156782Semax kbdcontrol -k ${kbd} < ${kbddev} > /dev/null 2>&1 133156782Semax fi 134156782Semax 135179981Smtm _sc_config="keyboard" 136156782Semax syscons_configure_keyboard 137179981Smtm 138179981Smtm # Terminate keyboard configuration line and reset global variables. 139179981Smtm # 140179981Smtm if [ -n "${_sc_initdone}" ]; then 141179981Smtm echo '.' 142179981Smtm _sc_config="syscons" 143179981Smtm _sc_initdone= 144179981Smtm fi 145179981Smtm 146156782Semax} 147156782Semax 148156782Semaxsyscons_precmd() 149156782Semax{ 150156782Semax if [ ! -c $kbddev ] 151156782Semax then 152156782Semax return 1 153156782Semax fi 154156782Semax return 0 155156782Semax} 156156782Semax 157156782Semaxsyscons_start() 158156782Semax{ 159156782Semax # keyboard 160156782Semax # 161156782Semax if [ -n "${keyboard}" ]; then 162179981Smtm syscons_setkeyboard ${keyboard} 163156782Semax fi 164156782Semax 165156782Semax syscons_configure_keyboard 166156782Semax 167102993Sfenner # cursor type 168102993Sfenner # 169102993Sfenner case ${cursor} in 170102993Sfenner [Nn][Oo] | '') 171102993Sfenner ;; 172102993Sfenner *) 173179981Smtm sc_init 174102993Sfenner echo -n ' cursor'; vidcontrol < ${viddev} -c ${cursor} 175102993Sfenner ;; 176102993Sfenner esac 17770856Sjhb 178102993Sfenner # screen mapping 179102993Sfenner # 180102993Sfenner case ${scrnmap} in 181102993Sfenner [Nn][Oo] | '') 182102993Sfenner ;; 183102993Sfenner *) 184179981Smtm sc_init 185102993Sfenner echo -n ' scrnmap'; vidcontrol < ${viddev} -l ${scrnmap} 186102993Sfenner ;; 187102993Sfenner esac 18870856Sjhb 189102993Sfenner # font 8x16 190102993Sfenner # 191102993Sfenner case ${font8x16} in 192102993Sfenner [Nn][Oo] | '') 193102993Sfenner ;; 194102993Sfenner *) 195179981Smtm sc_init 196102993Sfenner echo -n ' font8x16'; vidcontrol < ${viddev} -f 8x16 ${font8x16} 197102993Sfenner ;; 198102993Sfenner esac 19970856Sjhb 200102993Sfenner # font 8x14 201102993Sfenner # 202102993Sfenner case ${font8x14} in 203102993Sfenner [Nn][Oo] | '') 204102993Sfenner ;; 205102993Sfenner *) 206179981Smtm sc_init 207102993Sfenner echo -n ' font8x14'; vidcontrol < ${viddev} -f 8x14 ${font8x14} 208102993Sfenner ;; 209102993Sfenner esac 21070856Sjhb 211102993Sfenner # font 8x8 212102993Sfenner # 213102993Sfenner case ${font8x8} in 214102993Sfenner [Nn][Oo] | '') 215102993Sfenner ;; 216102993Sfenner *) 217179981Smtm sc_init 218102993Sfenner echo -n ' font8x8'; vidcontrol < ${viddev} -f 8x8 ${font8x8} 219102993Sfenner ;; 220102993Sfenner esac 22170856Sjhb 222102993Sfenner # blank time 223102993Sfenner # 224102993Sfenner case ${blanktime} in 225102993Sfenner [Nn][Oo] | '') 226102993Sfenner ;; 227102993Sfenner *) 228179981Smtm sc_init 229102993Sfenner echo -n ' blanktime'; vidcontrol < ${viddev} -t ${blanktime} 230102993Sfenner ;; 231102993Sfenner esac 23270856Sjhb 233102993Sfenner # screen saver 234102993Sfenner # 235102993Sfenner case ${saver} in 236102993Sfenner [Nn][Oo] | '') 237102993Sfenner ;; 238102993Sfenner *) 239179981Smtm sc_init 240102993Sfenner echo -n ' screensaver' 241167495Smux for i in `kldstat | awk '$5 ~ "_saver\.ko$" { print $5 }'`; do 242102993Sfenner kldunload ${i} 243102993Sfenner done 244165683Syar load_kld -e _saver ${saver}_saver 245102993Sfenner ;; 246102993Sfenner esac 24770856Sjhb 248102993Sfenner # set this mode for all virtual screens 249102993Sfenner # 250102993Sfenner if [ -n "${allscreens_flags}" ]; then 251179981Smtm sc_init 252102993Sfenner echo -n ' allscreens' 253102993Sfenner for ttyv in /dev/ttyv*; do 254102993Sfenner vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1 255102993Sfenner done 256102993Sfenner fi 257100284Sdougb 258179981Smtm [ -n "${_sc_initdone}" ] && echo '.' 259102993Sfenner} 260103161Sgordon 261103161Sgordonload_rc_config $name 262156331Semaxrun_rc_command $* 263156331Semax 264