summaryrefslogtreecommitdiffstats
path: root/etc/rc.d/wscons
blob: 36fd1b1a88cf89d8584380308e77dd188a22be6d (plain)
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/sh
#
# $NetBSD: wscons,v 1.9 2002/04/26 00:06:54 lukem Exp $
# $FreeBSD$
#

# PROVIDE: wscons
# REQUIRE: mountcritremote
# BEFORE:  LOGIN

. /etc/rc.subr

name="wscons"
rcvar=$name
start_cmd="wscons_start"
stop_cmd=":"

wscons_start()
{
	wscfg=/usr/sbin/wsconscfg
	wsfld=/usr/sbin/wsfontload
	wsctl=/sbin/wsconsctl
	config=/etc/wscons.conf
	usage="Usage: wsconfig [-n] [-f configfile] [-font fontpgm] [-screen screenpgm]"
	DOIT=

	while [ $# -gt 0 ]; do
		case $1 in
			-n)
				DOIT=echo
				;;
			-f)
				config=$2
				shift
				;;
			-font)
				wsfld=$2
				shift
				;;
			-screen)
				wscfg=$2
				shift
				;;
			*)
				echo $usage
				exit 1
				;;
		esac
		shift
	done


	# args mean:
	#	screen idx scr emul
	#	font   name width height enc file
	( while read type arg1 arg2 arg3 arg4 arg5; do
		case "$type" in
			\#*|"")
				continue
				;;

			font)
				name=$arg1
				width=$arg2
				height=$arg3
				enc=$arg4
				file=$arg5
				cmd=$wsfld

				case $width in
					-)
						;;
					*)
						cmd="$cmd -w $width"
						;;
				esac
				case $height in
					-)
						;;
					*)
						cmd="$cmd -h $height"
						;;
				esac
				case $enc in
					-)
						;;
					*)
						cmd="$cmd -e $enc"
						;;
				esac
				cmd="$cmd -N $name $file"
				eval $DOIT $cmd
				;;

			screen)
				idx=$arg1
				scr=$arg2
				emul=$arg3
				cmd=$wscfg

				case $scr in
					-)
						;;
					*)
						cmd="$cmd -t $scr"
						;;
				esac
				case $emul in
					-)
						;;
					*)
						cmd="$cmd -e $emul"
						;;
				esac
				cmd="$cmd $idx"
				eval $DOIT $cmd
				;;

			keyboard)
				kbd=$arg1
				cmd=$wscfg
				case $kbd in
					-|auto)
						cmd="$cmd -k"
						;;
					*)
						cmd="$cmd -k $kbd"
						;;
				esac
				eval $DOIT $cmd
				;;

			encoding)
				map=$arg1
				cmd="$wsctl -w \"encoding=$map\""
				eval $DOIT $cmd
				;;

			mapfile)
				mapfile=$arg1
				( while read entry; do
					case "$entry" in
						\#*|"")
						continue
						;;
					*)
						cmd="$wsctl -w \"map+=$entry\""
						cmd="$cmd >/dev/null"
						eval $DOIT $cmd
						;;
					esac
				done ) < $mapfile
				;;

			mux)
				cmd="$wscfg -m $arg1"
				eval $DOIT $cmd
				;;

			setvar)
				cmd="$wsctl -w $arg1"
				eval $DOIT $cmd
				;;

		esac
	done ) < $config
}

load_rc_config $name
run_rc_command "$1"
OpenPOWER on IntegriCloud