summaryrefslogtreecommitdiff
path: root/scripts/live-bottom/19keyboard
blob: 52a6a584af673b42e4de4b3de88822b13d386060 (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
#!/bin/sh

#set -e

# initramfs-tools header

PREREQ=""

prereqs()
{
	echo "${PREREQ}"
}

case "${1}" in
	prereqs)
		prereqs
		exit 0
		;;
esac

# live-initramfs header

if [ -n "${NOCONSOLEKEYBOARD}" ]
then
	exit 0
fi

. /scripts/live-functions

log_begin_msg "Setting up console keyboard"

# live-initramfs script

kbd=
cslayout=
csvariant=
csmodel=

# commandline
if [ -n "${KBD}" ]
then
	kbd="${KBD}"
else
	kbd=us
fi

really_export kbd

if [ -n "${KLAYOUT}" ]
then
	cslayout="${KLAYOUT}"
fi

if [ -n "${KVARIANT}" ]
then
	csvariant="${KVARIANT}"
fi

if [ -n "${KMODEL}" ]
then
	csmodel="${KMODEL}"
fi

if [ -x /root/bin/setupcon ]
then
	if [ -f /root/etc/default/keyboard ]
	then
		# squeeze
		KEYBOARD_FILE="/etc/default/keyboard"
	elif [ -f /root/etc/default/console-setup ]
	then
		# lenny
		KEYBOARD_FILE="/etc/default/console-setup"
	fi

	if [ -n "/root${KEYBOARD_FILE}" ]
	then
		if [ "${cslayout}" ]
		then
			chroot /root sed -i "s/^XKBLAYOUT=.*/XKBLAYOUT=\"${cslayout}\"/" \
			${KEYBOARD_FILE}

			if [ "${csvariant}" ]
			then
				chroot /root sed -i "s/^XKBVARIANT=.*/XKBVARIANT=\"${csvariant}\"/" \
				${KEYBOARD_FILE}
			else
				live-preseed /root console-setup/variantcode '' false
			fi

			if [ "${csmodel}" ]
			then
				chroot /root sed -i "s/^XKBMODEL=.*/XKBMODEL=\"${csmodel}\"/" \
				${KEYBOARD_FILE}
			else
				live-preseed /root console-setup/modelcode '' false
			fi
		else
			live-preseed /root console-setup/layoutcode '' false
			live-preseed /root console-setup/variantcode '' false
			live-preseed /root console-setup/modelcode '' false
		fi

		live-preseed /root console-setup/optionscode '' false
		live-preseed /root console-setup/codesetcode '' false

		if [ -f /root/etc/init.d/usplash ]
		then
			sed -i 's/CONSOLE_SCREEN=$/CONSOLE_SCREEN=setupcon/; t END; b; : END; n; b END' /root/etc/init.d/usplash
		fi
	fi
elif [ -e /root/usr/sbin/install-keymap ]
then
	chroot /root /usr/sbin/install-keymap ${kbd}
	live-preseed /root debian-installer/keymap "${kbd}"
	live-preseed /root kbd-chooser/method "${kbd}"
fi

log_end_msg