File: console-screen.sh

package info (click to toggle)
console-tools 1%3A0.2.3-10.3
  • links: PTS
  • area: main
  • in suites: potato
  • size: 3,172 kB
  • ctags: 1,130
  • sloc: ansic: 11,866; sh: 8,109; yacc: 984; makefile: 389; lex: 287; perl: 127; sed: 93
file content (124 lines) | stat: -rw-r--r-- 2,757 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh

#
# This is the boot script for the `console-tools' package.
#
# It loads parameters from /etc/console-tools/config, maybe loads
# default screen-font, screen font-map, and application charset-map,
# and maybe start "vcstime"
#
# (c) 1997 Yann Dirson

if [ -r /etc/console-tools/config ] ; then
    . /etc/console-tools/config
fi

SETFONT="/usr/bin/consolechars"
SETFONT_OPT=""
CHARSET="/usr/bin/charset"
VCSTIME="/usr/sbin/vcstime"

# be sure the main program is installed
[ -x "${SETFONT}" ] || exit 0


# set DEVICE_PREFIX depending on devfs
if [ "`grep -c devfs /proc/filesystems`" -a -d /dev/vc ]; then
  DEVICE_PREFIX="/dev/vc/"
else
  DEVICE_PREFIX="/dev/tty"
fi


reset_vga_palette ()
{
    if ! /usr/bin/tty | grep -q ttyS ; then
       # not a serial console.
       if [ -f /proc/fb ]; then
           # They have a framebuffer device.
           # That means we have work to do...
           echo -n "]R"
       fi
    fi
}

setup ()
{
    reset_vga_palette

    # start vcstime
    if [ "${DO_VCSTIME}" = "yes" -a -x ${VCSTIME} ] ; then
      echo -n Starting clock on text console: `basename ${VCSTIME}`
      ${VCSTIME} &
      echo .
    fi


    # Global default font+sfm
    if [ "${SCREEN_FONT}" ]
    then
	echo -n "Setting up general console font... "
	SCREEN_FONT="-f ${SCREEN_FONT}"

	# maybe use an external SFM
	[ "${SCREEN_FONT_MAP}" ] && SCREEN_FONT_MAP="-u ${SCREEN_FONT_MAP}"

	${SETFONT} ${SETFONT_OPT} ${SCREEN_FONT} ${SCREEN_FONT_MAP} && echo done.
    fi


    # Per-VC font+sfm
    PERVC_FONTS=`set | grep "^SCREEN_FONT_vc[0-9]*="`
    if [ "${PERVC_FONTS}" ]
    then
	echo -n "Setting up per-VC fonts: "
	for font in ${PERVC_FONTS}
	do
	    # extract VC and FONTNAME info from variable setting
	    font=`echo $font | cut -c15-`
	    vc=`echo $font | cut -d= -f1`
	    font=`echo $font | cut -d= -f2`
	    echo -n "${DEVICE_PREFIX}${vc}, "
	    # eventually find an associated SFM
	    eval sfm=\${SCREEN_FONT_MAP_vc${vc}}
	    [ "$sfm" ] && sfm="-u $sfm"

	    ${SETFONT} --tty=${DEVICE_PREFIX}$vc ${SETFONT_OPT} -f $font $sfm
	done
	echo "done."
    fi


    # Global ACM
    [ "${APP_CHARSET_MAP}" ] && ${CHARSET} G0 ${APP_CHARSET_MAP}


    # Per-VC ACMs
    PERVC_ACMS=`set | grep "^APP_CHARSET_MAP_vc[0-9]*="`
    if [ "${PERVC_ACMS}" ]
    then
	echo -n "Setting up per-VC ACM's: "
	for acm in ${PERVC_ACMS}
	do
	    # extract VC and FONTNAME info from variable setting
	    acm=`echo $acm | cut -c19-`
	    vc=`echo $acm | cut -d= -f1`
	    acm=`echo $acm | cut -d= -f2`

	    echo -n "${DEVICE_PREFIX}${vc} ($acm), "
	    ${CHARSET} --tty=${DEVICE_PREFIX}$vc G0 $acm
	done
	echo "done."
    fi
}

case "$1" in
start|reload|restart|force-reload)
    setup
    ;;
stop)
    ;;
*)
    setup
    ;;
esac