Browse Source

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
tags/9.0
Dmitry Bilunov 3 years ago
parent
commit
95a5cfb6f1
3 changed files with 1436 additions and 2 deletions
  1. 4
    2
      actions/master-node-create-and-install.sh
  2. 1348
    0
      dumpkeys.cache
  3. 84
    0
      functions/translate.sh

+ 4
- 2
actions/master-node-create-and-install.sh View File

@@ -24,6 +24,7 @@ source ./config.sh
24 24
 source ./functions/vm.sh
25 25
 source ./functions/network.sh
26 26
 source ./functions/product.sh
27
+source ./functions/translate.sh
27 28
 
28 29
 # Create master node for the product
29 30
 # Get variables "host_nic_name" for the master node
@@ -49,8 +50,9 @@ if [ ${headless} -eq 1 ]; then
49 50
 fi
50 51
 
51 52
 if [ "$skipfuelmenu" = "yes" ]; then
52
-  # " 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
53
-   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"
53
+  cmdline="$(grep 'append initrd' ../iso/isolinux/isolinux.cfg -m1 2> /dev/null | sed -e 's/^[ ]*append//')"
54
+  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}"
55
+  boot_line="$(translate "$cmdline showmenu=no"$'\n')"
54 56
 fi
55 57
 
56 58
 # Start virtual machine with the master node

+ 1348
- 0
dumpkeys.cache
File diff suppressed because it is too large
View File


+ 84
- 0
functions/translate.sh View File

@@ -0,0 +1,84 @@
1
+#!/bin/bash -eu
2
+# AT translated set 2 encoder
3
+
4
+type xxd > /dev/null || exit 1
5
+
6
+if ! test -f dumpkeys.cache; then
7
+        sudo dumpkeys --keys-only > dumpkeys.cache
8
+fi
9
+
10
+# XXX: hardcoded values are generated by:
11
+#make_break_shift="$(eval echo \$at_table_$(echo -n Shift | xxd -ps))"
12
+#make_shift="${make_break_shift% *}"
13
+#break_shift="${make_break_shift#* }"
14
+
15
+make_shift=36
16
+break_shift=b6
17
+
18
+map_set() {
19
+        # $1 - keycode
20
+        # $2 - normal value
21
+        # $3 - shifted value
22
+        [ "${2}${3}" = "nulnul" ] && return 1
23
+        make=$(printf %02x "$1")
24
+        break=$(printf %02x "$(($1 | 128))")
25
+        eval "at_table_$(echo -n "${3#+}" | xxd -ps)='$make_shift $make $break $break_shift'"
26
+        eval "at_table_$(echo -n "${2#+}" | xxd -ps)='$make $break'"
27
+}
28
+
29
+map_alias() {
30
+        # $1,$3,$5,... - names
31
+        # $2,$4,$6,... - aliases
32
+        while [ -n "$1" -a -n "$2" ]; do
33
+               eval "at_table_$(echo -n "${2#+}" | xxd -ps)=\${at_table_$(echo -n "${1#+}" | xxd -ps)}"
34
+               shift
35
+               shift
36
+        done
37
+}
38
+
39
+# at_table_$normal = n
40
+# at_table_$shifted = n
41
+while read keycode n _ normal shifted rest; do
42
+        [ "$keycode" = "keycode" ] || continue
43
+        map_set "${n}" "${normal}" "${shifted}"
44
+done < dumpkeys.cache
45
+
46
+# Extra mapping
47
+map_alias \
48
+        one 1 exclam '!' \
49
+	two 2 at '@' \
50
+	three 3 numbersign '#' \
51
+	four 4 dollar '$' \
52
+	five 5 percent '%' \
53
+	six 6 asciicircum '^' \
54
+	seven 7 ampersand '&' \
55
+	eight 8 asterisk '*' \
56
+	nine 9 parenleft '(' \
57
+	zero 0 parenright ')' \
58
+	minus '-' underscore '_' \
59
+	equal '=' plus '+'
60
+
61
+map_alias \
62
+        bracketleft '[' braceleft '{' \
63
+        bracketright ']' braceright '}' \
64
+        semicolon ';' colon ':' \
65
+        apostrophe "'" quotedbl '"' \
66
+        grave '`' asciitilde '~' \
67
+        backslash "\\" bar '|' \
68
+        comma ',' less '<' \
69
+        period '.' greater '>' \
70
+        slash '/' question '?' \
71
+        space ' ' Return $'\n'
72
+
73
+translate() {
74
+        for t in $(echo -n "$*" | xxd -ps | sed -e 's/../& /g'); do
75
+                n="at_table_$t"
76
+                v="${!n}"
77
+                [ -z "$v" ] && echo "$0: unknown char: '$t'." >&2
78
+                echo -n " ${v}"
79
+        done
80
+        echo
81
+}
82
+
83
+[ "$(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
84
+"

Loading…
Cancel
Save