Do not hardcode scancodes that change isolinux boot params

We have a "skipfuelmenu" variable in virtualbox scripts, which allows to
skip "fuelmenu" step during the installation procedure. This option is
enabled by default.

Currently, we have a hardcoded variable $boot_line, which contains scan
codes, passed by VirtualBox into isolinux on an emulated keyboard.

We should generate these scancodes from a user specified line instead of
hardcoding them.

Partial-Bug: 1525967
Change-Id: Ia2419b5e2eaa4b30cd2876112d7c080abbebcba5
This commit is contained in:
Dmitry Bilunov 2015-12-16 17:37:52 +03:00
parent c5cbe939d6
commit 95a5cfb6f1
3 changed files with 1436 additions and 2 deletions

View File

@ -24,6 +24,7 @@ source ./config.sh
source ./functions/vm.sh
source ./functions/network.sh
source ./functions/product.sh
source ./functions/translate.sh
# Create master node for the product
# Get variables "host_nic_name" for the master node
@ -49,8 +50,9 @@ if [ ${headless} -eq 1 ]; then
fi
if [ "$skipfuelmenu" = "yes" ]; then
# " vmlinuz initrd=initrd.img biosdevname=0 ks=cdrom:/ks.cfg ip=10.20.0.2 gw=10.20.0.1 dns1=10.20.0.1 netmask=255.255.255.0 hostname=fuel.domain.tld showmenu=no" line is coded
boot_line=" 39 b9 2f af 32 b2 26 a6 17 97 31 b1 16 96 2c ac 39 b9 17 97 31 b1 17 97 14 94 13 93 20 a0 0d 8d 17 97 31 b1 17 97 14 94 13 93 20 a0 34 b4 17 97 32 b2 22 a2 39 b9 30 b0 17 97 18 98 1f 9f 20 a0 12 92 2f af 31 b1 1e 9e 32 b2 12 92 0d 8d 0b 8b 39 b9 25 a5 1f 9f 0d 8d 2e ae 20 a0 13 93 18 98 32 b2 2a 27 a7 aa 35 b5 25 a5 1f 9f 34 b4 2e ae 21 a1 22 a2 39 b9 17 97 19 99 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 03 83 39 b9 22 a2 11 91 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 02 82 39 b9 20 a0 31 b1 1f 9f 02 82 0d 8d 02 82 0b 8b 34 b4 03 83 0b 8b 34 b4 0b 8b 34 b4 02 82 39 b9 31 b1 12 92 14 94 32 b2 1e 9e 1f 9f 25 a5 0d 8d 03 83 06 86 06 86 34 b4 03 83 06 86 06 86 34 b4 03 83 06 86 06 86 34 b4 0b 8b 39 b9 23 a3 18 98 1f 9f 14 94 31 b1 1e 9e 32 b2 12 92 0d 8d 21 a1 16 96 12 92 26 a6 34 b4 20 a0 18 98 32 b2 1e 9e 17 97 31 b1 34 b4 14 94 26 a6 20 a0 39 b9 1f 9f 23 a3 18 98 11 91 32 b2 12 92 31 b1 16 96 0d 8d 31 b1 18 98 1c 9c"
cmdline="$(grep 'append initrd' ../iso/isolinux/isolinux.cfg -m1 2> /dev/null | sed -e 's/^[ ]*append//')"
cmdline="${cmdline:- initrd=initrd.img net.ifnames=0 biosdevname=0 ks=hd:sr0:/ks.cfg ip=10.20.0.2::10.20.0.1:255.255.255.0:fuel.domain.tld:eth0:off::: dns1=10.20.0.1 selinux=0}"
boot_line="$(translate "$cmdline showmenu=no"$'\n')"
fi
# Start virtual machine with the master node

1348
dumpkeys.cache Normal file

File diff suppressed because it is too large Load Diff

84
functions/translate.sh Normal file
View File

@ -0,0 +1,84 @@
#!/bin/bash -eu
# AT translated set 2 encoder
type xxd > /dev/null || exit 1
if ! test -f dumpkeys.cache; then
sudo dumpkeys --keys-only > dumpkeys.cache
fi
# XXX: hardcoded values are generated by:
#make_break_shift="$(eval echo \$at_table_$(echo -n Shift | xxd -ps))"
#make_shift="${make_break_shift% *}"
#break_shift="${make_break_shift#* }"
make_shift=36
break_shift=b6
map_set() {
# $1 - keycode
# $2 - normal value
# $3 - shifted value
[ "${2}${3}" = "nulnul" ] && return 1
make=$(printf %02x "$1")
break=$(printf %02x "$(($1 | 128))")
eval "at_table_$(echo -n "${3#+}" | xxd -ps)='$make_shift $make $break $break_shift'"
eval "at_table_$(echo -n "${2#+}" | xxd -ps)='$make $break'"
}
map_alias() {
# $1,$3,$5,... - names
# $2,$4,$6,... - aliases
while [ -n "$1" -a -n "$2" ]; do
eval "at_table_$(echo -n "${2#+}" | xxd -ps)=\${at_table_$(echo -n "${1#+}" | xxd -ps)}"
shift
shift
done
}
# at_table_$normal = n
# at_table_$shifted = n
while read keycode n _ normal shifted rest; do
[ "$keycode" = "keycode" ] || continue
map_set "${n}" "${normal}" "${shifted}"
done < dumpkeys.cache
# Extra mapping
map_alias \
one 1 exclam '!' \
two 2 at '@' \
three 3 numbersign '#' \
four 4 dollar '$' \
five 5 percent '%' \
six 6 asciicircum '^' \
seven 7 ampersand '&' \
eight 8 asterisk '*' \
nine 9 parenleft '(' \
zero 0 parenright ')' \
minus '-' underscore '_' \
equal '=' plus '+'
map_alias \
bracketleft '[' braceleft '{' \
bracketright ']' braceright '}' \
semicolon ';' colon ':' \
apostrophe "'" quotedbl '"' \
grave '`' asciitilde '~' \
backslash "\\" bar '|' \
comma ',' less '<' \
period '.' greater '>' \
slash '/' question '?' \
space ' ' Return $'\n'
translate() {
for t in $(echo -n "$*" | xxd -ps | sed -e 's/../& /g'); do
n="at_table_$t"
v="${!n}"
[ -z "$v" ] && echo "$0: unknown char: '$t'." >&2
echo -n " ${v}"
done
echo
}
[ "$(basename "$0")" = "translate.sh" ] && translate " vmlinuz initrd=initrd.img biosdevname=0 ks=cdrom:/ks.cfg ip=10.20.0.2 gw=10.20.0.1 dns1=10.20.0.1 netmask=255.255.255.0 hostname=fuel.domain.tld showmenu=no
"