syscons revision 167495
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 167495 2007-03-12 22:35:43Z mux $ 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 48156782Semax# helper 49156782Semaxsyscons_configure_keyboard() 50156331Semax{ 51102993Sfenner # keymap 52102993Sfenner # 53102993Sfenner case ${keymap} in 54102993Sfenner [Nn][Oo] | '') 55102993Sfenner ;; 56102993Sfenner *) 57102993Sfenner echo -n ' keymap'; kbdcontrol < ${kbddev} -l ${keymap} 58102993Sfenner ;; 59102993Sfenner esac 6070856Sjhb 61102993Sfenner # keyrate 62102993Sfenner # 63102993Sfenner case ${keyrate} in 64102993Sfenner [Nn][Oo] | '') 65102993Sfenner ;; 66102993Sfenner *) 67102993Sfenner echo -n ' keyrate'; kbdcontrol < ${kbddev} -r ${keyrate} 68102993Sfenner ;; 69102993Sfenner esac 7070856Sjhb 71102993Sfenner # keybell 72102993Sfenner # 73102993Sfenner case ${keybell} in 74102993Sfenner [Nn][Oo] | '') 75102993Sfenner ;; 76102993Sfenner *) 77102993Sfenner echo -n ' keybell'; kbdcontrol < ${kbddev} -b ${keybell} 78102993Sfenner ;; 79102993Sfenner esac 8070856Sjhb 81102993Sfenner # change function keys 82102993Sfenner # 83102993Sfenner case ${keychange} in 84102993Sfenner [Nn][Oo] | '') 85102993Sfenner ;; 86102993Sfenner *) 87102993Sfenner echo -n ' keychange' 88102993Sfenner set - ${keychange} 89102993Sfenner while [ $# -gt 0 ]; do 90102993Sfenner kbdcontrol <${kbddev} -f "$1" "$2" 91102993Sfenner shift; shift 92102993Sfenner done 93102993Sfenner ;; 94102993Sfenner esac 9570856Sjhb 96156782Semax # set this keyboard mode for all virtual terminals 97156782Semax # 98156782Semax if [ -n "${allscreens_kbdflags}" ]; then 99156782Semax echo -n ' allscreens_kbd' 100156782Semax for ttyv in /dev/ttyv*; do 101156782Semax kbdcontrol ${allscreens_kbdflags} < ${ttyv} > ${ttyv} 2>&1 102156782Semax done 103156782Semax fi 104156782Semax} 105156782Semax 106156782Semaxsyscons_setkeyboard() 107156782Semax{ 108156782Semax kbd=$1 109156782Semax 110156782Semax if [ -z "${kbd}" ]; then 111156782Semax return 1 112156782Semax fi 113156782Semax 114156782Semax # Check if the kbdmux(4) is the current active keyboard 115156782Semax kbdcontrol -i < ${kbddev} | grep kbdmux > /dev/null 2>&1 116156782Semax if [ $? != 0 ]; then 117156782Semax kbdcontrol -k ${kbd} < ${kbddev} > /dev/null 2>&1 118156782Semax fi 119156782Semax 120156782Semax echo -n 'Configuring keyboard:' 121156782Semax syscons_configure_keyboard 122156782Semax echo '.' 123156782Semax} 124156782Semax 125156782Semaxsyscons_precmd() 126156782Semax{ 127156782Semax if [ ! -c $kbddev ] 128156782Semax then 129156782Semax return 1 130156782Semax fi 131156782Semax return 0 132156782Semax} 133156782Semax 134156782Semaxsyscons_start() 135156782Semax{ 136156782Semax echo -n 'Configuring syscons:' 137156782Semax 138156782Semax # keyboard 139156782Semax # 140156782Semax if [ -n "${keyboard}" ]; then 141156782Semax echo -n ' keyboard'; syscons_setkeyboard ${keyboard} 142156782Semax fi 143156782Semax 144156782Semax syscons_configure_keyboard 145156782Semax 146102993Sfenner # cursor type 147102993Sfenner # 148102993Sfenner case ${cursor} in 149102993Sfenner [Nn][Oo] | '') 150102993Sfenner ;; 151102993Sfenner *) 152102993Sfenner echo -n ' cursor'; vidcontrol < ${viddev} -c ${cursor} 153102993Sfenner ;; 154102993Sfenner esac 15570856Sjhb 156102993Sfenner # screen mapping 157102993Sfenner # 158102993Sfenner case ${scrnmap} in 159102993Sfenner [Nn][Oo] | '') 160102993Sfenner ;; 161102993Sfenner *) 162102993Sfenner echo -n ' scrnmap'; vidcontrol < ${viddev} -l ${scrnmap} 163102993Sfenner ;; 164102993Sfenner esac 16570856Sjhb 166102993Sfenner # font 8x16 167102993Sfenner # 168102993Sfenner case ${font8x16} in 169102993Sfenner [Nn][Oo] | '') 170102993Sfenner ;; 171102993Sfenner *) 172102993Sfenner echo -n ' font8x16'; vidcontrol < ${viddev} -f 8x16 ${font8x16} 173102993Sfenner ;; 174102993Sfenner esac 17570856Sjhb 176102993Sfenner # font 8x14 177102993Sfenner # 178102993Sfenner case ${font8x14} in 179102993Sfenner [Nn][Oo] | '') 180102993Sfenner ;; 181102993Sfenner *) 182102993Sfenner echo -n ' font8x14'; vidcontrol < ${viddev} -f 8x14 ${font8x14} 183102993Sfenner ;; 184102993Sfenner esac 18570856Sjhb 186102993Sfenner # font 8x8 187102993Sfenner # 188102993Sfenner case ${font8x8} in 189102993Sfenner [Nn][Oo] | '') 190102993Sfenner ;; 191102993Sfenner *) 192102993Sfenner echo -n ' font8x8'; vidcontrol < ${viddev} -f 8x8 ${font8x8} 193102993Sfenner ;; 194102993Sfenner esac 19570856Sjhb 196102993Sfenner # blank time 197102993Sfenner # 198102993Sfenner case ${blanktime} in 199102993Sfenner [Nn][Oo] | '') 200102993Sfenner ;; 201102993Sfenner *) 202102993Sfenner echo -n ' blanktime'; vidcontrol < ${viddev} -t ${blanktime} 203102993Sfenner ;; 204102993Sfenner esac 20570856Sjhb 206102993Sfenner # screen saver 207102993Sfenner # 208102993Sfenner case ${saver} in 209102993Sfenner [Nn][Oo] | '') 210102993Sfenner ;; 211102993Sfenner *) 212102993Sfenner echo -n ' screensaver' 213167495Smux for i in `kldstat | awk '$5 ~ "_saver\.ko$" { print $5 }'`; do 214102993Sfenner kldunload ${i} 215102993Sfenner done 216165683Syar load_kld -e _saver ${saver}_saver 217102993Sfenner ;; 218102993Sfenner esac 21970856Sjhb 220102993Sfenner # set this mode for all virtual screens 221102993Sfenner # 222102993Sfenner if [ -n "${allscreens_flags}" ]; then 223102993Sfenner echo -n ' allscreens' 224102993Sfenner for ttyv in /dev/ttyv*; do 225102993Sfenner vidcontrol ${allscreens_flags} < ${ttyv} > ${ttyv} 2>&1 226102993Sfenner done 227102993Sfenner fi 228100284Sdougb 229102993Sfenner echo '.' 230102993Sfenner} 231103161Sgordon 232103161Sgordonload_rc_config $name 233156331Semaxrun_rc_command $* 234156331Semax 235