From a87ad05866346d6c610fa49caf5bdb72e6877975 Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Sun, 31 Jul 2016 19:05:10 +0100 Subject: [PATCH 1/5] Add support for ctrl, shift and alt keys. Add support for using ctrl, shift and alt as key modifiers. So you can now achieve ctrl+c by using "c". Updated documentation for new key stroke tokens. --- .../common/step_type_boot_command.go | 79 ++++++++ builder/qemu/step_type_boot_command.go | 174 ++++++++++++++++++ .../common/step_type_boot_command.go | 78 ++++++++ .../vmware/common/step_type_boot_command.go | 138 ++++++++++++++ .../docs/builders/parallels-iso.html.md | 20 ++ website/source/docs/builders/qemu.html.md | 20 ++ .../docs/builders/virtualbox-iso.html.md | 20 ++ .../source/docs/builders/vmware-iso.html.md | 20 ++ 8 files changed, 549 insertions(+) diff --git a/builder/parallels/common/step_type_boot_command.go b/builder/parallels/common/step_type_boot_command.go index a1b3d562d..37637fc65 100644 --- a/builder/parallels/common/step_type_boot_command.go +++ b/builder/parallels/common/step_type_boot_command.go @@ -186,6 +186,13 @@ func scancodes(message string) []string { special[""] = []string{"49", "c9"} special[""] = []string{"51", "d1"} + special[""] = []string{"38", "b8"} + special[""] = []string{"1d", "9d"} + special[""] = []string{"2a", "aa"} + special[""] = []string{"e038", "e0b8"} + special[""] = []string{"e01d", "e09d"} + special[""] = []string{"36", "b6"} + shiftedChars := "!@#$%^&*()_+{}:\"~|<>?" scancodeIndex := make(map[string]uint) @@ -214,6 +221,78 @@ func scancodes(message string) []string { for len(message) > 0 { var scancode []string + if strings.HasPrefix(message, "") { + scancode = []string{"38"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 38") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"1d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 1d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"2a"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 2a") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"b8"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: b8") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"9d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 9d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"aa"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: aa") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e038"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e038") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e01d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e01d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"36"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 36") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e0b8"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e0b8") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e09d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e09d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"b6"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: b6") + } + if strings.HasPrefix(message, "") { log.Printf("Special code found, will sleep 1 second at this point.") scancode = []string{"wait"} diff --git a/builder/qemu/step_type_boot_command.go b/builder/qemu/step_type_boot_command.go index f720d6f12..fc999429f 100644 --- a/builder/qemu/step_type_boot_command.go +++ b/builder/qemu/step_type_boot_command.go @@ -136,6 +136,12 @@ func vncSendString(c *vnc.ClientConn, original string) { special[""] = 0xFF57 special[""] = 0xFF55 special[""] = 0xFF56 + special[""] = 0xFFE9 + special[""] = 0xFFE3 + special[""] = 0xFFE1 + special[""] = 0xFFEA + special[""] = 0xFFE4 + special[""] = 0xFFE2 shiftedChars := "~!@#$%^&*()_+{}|:\"<>?" @@ -144,6 +150,174 @@ func vncSendString(c *vnc.ClientConn, original string) { var keyCode uint32 keyShift := false + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + // qemu is picky, so no matter what, wait a small period + time.Sleep(100 * time.Millisecond) + + continue + } + if strings.HasPrefix(original, "") { log.Printf("Special code '' found, sleeping one second") time.Sleep(1 * time.Second) diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index d227cf760..ab9cd5c70 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -141,6 +141,12 @@ func scancodes(message string) []string { special[""] = []string{"4f", "cf"} special[""] = []string{"49", "c9"} special[""] = []string{"51", "d1"} + special[""] = []string{"38", "b8"} + special[""] = []string{"1d", "9d"} + special[""] = []string{"2a", "aa"} + special[""] = []string{"e038", "e0b8"} + special[""] = []string{"e01d", "e09d"} + special[""] = []string{"36", "b6"} shiftedChars := "~!@#$%^&*()_+{}|:\"<>?" @@ -170,6 +176,78 @@ func scancodes(message string) []string { for len(message) > 0 { var scancode []string + if strings.HasPrefix(message, "") { + scancode = []string{"38"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 38") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"1d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 1d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"2a"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 2a") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"b8"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: b8") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"9d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 9d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"aa"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: aa") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e038"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e038") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e01d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e01d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"36"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: 36") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e0b8"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e0b8") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"e09d"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: e09d") + } + + if strings.HasPrefix(message, "") { + scancode = []string{"b6"} + message = message[len(""):] + log.Printf("Special code '' found, replacing with: b6") + } + if strings.HasPrefix(message, "") { log.Printf("Special code found, will sleep 1 second at this point.") scancode = []string{"wait"} diff --git a/builder/vmware/common/step_type_boot_command.go b/builder/vmware/common/step_type_boot_command.go index 9750aaa71..b74dff32e 100644 --- a/builder/vmware/common/step_type_boot_command.go +++ b/builder/vmware/common/step_type_boot_command.go @@ -159,6 +159,12 @@ func vncSendString(c *vnc.ClientConn, original string) { special[""] = 0xFF57 special[""] = 0xFF55 special[""] = 0xFF56 + special[""] = 0xFFE9 + special[""] = 0xFFE3 + special[""] = 0xFFE1 + special[""] = 0xFFEA + special[""] = 0xFFE4 + special[""] = 0xFFE2 shiftedChars := "~!@#$%^&*()_+{}|:\"<>?" @@ -167,6 +173,138 @@ func vncSendString(c *vnc.ClientConn, original string) { var keyCode uint32 keyShift := false + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, true) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + + if strings.HasPrefix(original, "") { + keyCode = special[""] + original = original[len(""):] + log.Printf("Special code '' found, replacing with: %s", keyCode) + + c.KeyEvent(keyCode, false) + time.Sleep(time.Second / 10) + + continue + } + if strings.HasPrefix(original, "") { log.Printf("Special code '' found, sleeping one second") time.Sleep(1 * time.Second) diff --git a/website/source/docs/builders/parallels-iso.html.md b/website/source/docs/builders/parallels-iso.html.md index 61fef28f9..649c8ebb0 100644 --- a/website/source/docs/builders/parallels-iso.html.md +++ b/website/source/docs/builders/parallels-iso.html.md @@ -256,10 +256,30 @@ proper key: - `` `` - Simulates pressing the page up and page down keys. +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + - `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: diff --git a/website/source/docs/builders/qemu.html.md b/website/source/docs/builders/qemu.html.md index e5aee5ce1..15cb91700 100644 --- a/website/source/docs/builders/qemu.html.md +++ b/website/source/docs/builders/qemu.html.md @@ -354,6 +354,24 @@ by the proper key: - `` `` - Simulates pressing the page up and page down keys. +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + - `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. @@ -361,6 +379,8 @@ by the proper key: - ` ` - Add user defined time.Duration pause before sending any additional keys. For example `` or `` +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: diff --git a/website/source/docs/builders/virtualbox-iso.html.md b/website/source/docs/builders/virtualbox-iso.html.md index 59f7d1e59..48fcbe9f1 100644 --- a/website/source/docs/builders/virtualbox-iso.html.md +++ b/website/source/docs/builders/virtualbox-iso.html.md @@ -290,10 +290,30 @@ by the proper key: - `` `` - Simulates pressing the page up and page down keys. +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + - `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: diff --git a/website/source/docs/builders/vmware-iso.html.md b/website/source/docs/builders/vmware-iso.html.md index 54cdc2615..9599c0630 100644 --- a/website/source/docs/builders/vmware-iso.html.md +++ b/website/source/docs/builders/vmware-iso.html.md @@ -314,10 +314,30 @@ by the proper key: - `` `` - Simulates pressing the page up and page down keys. +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + - `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: From 1155c6d4d61d78df5a55da27665eb03b9d361f2b Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Sun, 31 Jul 2016 19:46:38 +0100 Subject: [PATCH 2/5] Use the correct fmt verb for log output --- builder/qemu/step_type_boot_command.go | 24 +++++++++---------- .../vmware/common/step_type_boot_command.go | 24 +++++++++---------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/builder/qemu/step_type_boot_command.go b/builder/qemu/step_type_boot_command.go index fc999429f..6138f6cdd 100644 --- a/builder/qemu/step_type_boot_command.go +++ b/builder/qemu/step_type_boot_command.go @@ -153,7 +153,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -167,7 +167,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -181,7 +181,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -195,7 +195,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -209,7 +209,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -223,7 +223,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -237,7 +237,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -251,7 +251,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -265,7 +265,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -279,7 +279,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -293,7 +293,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -307,7 +307,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) diff --git a/builder/vmware/common/step_type_boot_command.go b/builder/vmware/common/step_type_boot_command.go index b74dff32e..d68e809c7 100644 --- a/builder/vmware/common/step_type_boot_command.go +++ b/builder/vmware/common/step_type_boot_command.go @@ -176,7 +176,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -187,7 +187,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -198,7 +198,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -209,7 +209,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -220,7 +220,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -231,7 +231,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -242,7 +242,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -253,7 +253,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -264,7 +264,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, true) time.Sleep(time.Second / 10) @@ -275,7 +275,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -286,7 +286,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) @@ -297,7 +297,7 @@ func vncSendString(c *vnc.ClientConn, original string) { if strings.HasPrefix(original, "") { keyCode = special[""] original = original[len(""):] - log.Printf("Special code '' found, replacing with: %s", keyCode) + log.Printf("Special code '' found, replacing with: %d", keyCode) c.KeyEvent(keyCode, false) time.Sleep(time.Second / 10) From e3361eec55b8ffcdd5c1a943ae7179be9a3c76ce Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Sun, 31 Jul 2016 22:50:59 +0100 Subject: [PATCH 3/5] Added ctrl, shift and alt keys to documentation --- .../docs/builders/parallels-pvm.html.md | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/website/source/docs/builders/parallels-pvm.html.md b/website/source/docs/builders/parallels-pvm.html.md index cb40a81b9..c75d9f63b 100644 --- a/website/source/docs/builders/parallels-pvm.html.md +++ b/website/source/docs/builders/parallels-pvm.html.md @@ -198,10 +198,30 @@ proper key: - `` `` - Simulates pressing the page up and page down keys. +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + - `` `` `` - Adds a 1, 5 or 10 second pause before sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: From 3a5b9e8546240bac964875aa25aff9903e77dedd Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Tue, 2 Aug 2016 21:58:04 +0100 Subject: [PATCH 4/5] Add missing boot_command documentation. --- .../docs/builders/virtualbox-ovf.html.md | 88 +++++++++++++++++++ .../source/docs/builders/vmware-vmx.html.md | 88 +++++++++++++++++++ 2 files changed, 176 insertions(+) diff --git a/website/source/docs/builders/virtualbox-ovf.html.md b/website/source/docs/builders/virtualbox-ovf.html.md index 0e53b0316..302d94683 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.md +++ b/website/source/docs/builders/virtualbox-ovf.html.md @@ -215,6 +215,94 @@ builder. port in this range that appears available. By default this is 5900 to 6000. The minimum and maximum ports are inclusive. +## Boot Command + +The `boot_command` configuration is very important: it specifies the keys to +type when the virtual machine is first booted in order to start the OS +installer. This command is typed after `boot_wait`, which gives the virtual +machine some time to actually load the ISO. + +As documented above, the `boot_command` is an array of strings. The strings are +all typed in sequence. It is an array only to improve readability within the +template. + +The boot command is "typed" character for character over a VNC connection to the +machine, simulating a human actually typing the keyboard. There are a set of +special keys available. If these are in your boot command, they will be replaced +by the proper key: + +- `` - Backspace + +- `` - Delete + +- `` and `` - Simulates an actual "enter" or "return" keypress. + +- `` - Simulates pressing the escape key. + +- `` - Simulates pressing the tab key. + +- `` - `` - Simulates pressing a function key. + +- `` `` `` `` - Simulates pressing an arrow key. + +- `` - Simulates pressing the spacebar. + +- `` - Simulates pressing the insert key. + +- `` `` - Simulates pressing the home and end keys. + +- `` `` - Simulates pressing the page up and page down keys. + +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + +- `` `` `` - Adds a 1, 5 or 10 second pause before + sending any additional keys. This is useful if you have to generally wait + for the UI to update before typing more. + +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + +In addition to the special keys, each command to type is treated as a +[configuration template](/docs/templates/configuration-templates.html). The +available variables are: + +- `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server + that is started serving the directory specified by the `http_directory` + configuration parameter. If `http_directory` isn't specified, these will be + blank! + +Example boot command. This is actually a working boot command used to start an +Ubuntu 12.04 installer: + +``` {.text} +[ + "", + "/install/vmlinuz noapic ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", + "hostname={{ .Name }} ", + "fb=false debconf/frontend=noninteractive ", + "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", + "keyboard-configuration/variant=USA console-setup/ask_detect=false ", + "initrd=/install/initrd.gz -- " +] +``` + ## Guest Additions Packer will automatically download the proper guest additions for the version of diff --git a/website/source/docs/builders/vmware-vmx.html.md b/website/source/docs/builders/vmware-vmx.html.md index fc30811c7..e26c6f0c4 100644 --- a/website/source/docs/builders/vmware-vmx.html.md +++ b/website/source/docs/builders/vmware-vmx.html.md @@ -153,3 +153,91 @@ builder. the initial `boot_command`. Because Packer generally runs in parallel, Packer uses a randomly chosen port in this range that appears available. By default this is 5900 to 6000. The minimum and maximum ports are inclusive. + +## Boot Command + +The `boot_command` configuration is very important: it specifies the keys to +type when the virtual machine is first booted in order to start the OS +installer. This command is typed after `boot_wait`, which gives the virtual +machine some time to actually load the ISO. + +As documented above, the `boot_command` is an array of strings. The strings are +all typed in sequence. It is an array only to improve readability within the +template. + +The boot command is "typed" character for character over a VNC connection to the +machine, simulating a human actually typing the keyboard. There are a set of +special keys available. If these are in your boot command, they will be replaced +by the proper key: + +- `` - Backspace + +- `` - Delete + +- `` and `` - Simulates an actual "enter" or "return" keypress. + +- `` - Simulates pressing the escape key. + +- `` - Simulates pressing the tab key. + +- `` - `` - Simulates pressing a function key. + +- `` `` `` `` - Simulates pressing an arrow key. + +- `` - Simulates pressing the spacebar. + +- `` - Simulates pressing the insert key. + +- `` `` - Simulates pressing the home and end keys. + +- `` `` - Simulates pressing the page up and page down keys. + +- `` `` - Simulates pressing the alt key. + +- `` `` - Simulates pressing the ctrl key. + +- `` `` - Simulates pressing the shift key. + +- `` `` - Simulates pressing and holding the alt key. + +- `` `` - Simulates pressing and holding the ctrl key. + +- `` `` - Simulates pressing and holding the shift key. + +- `` `` - Simulates releasing a held alt key. + +- `` `` - Simulates releasing a held ctrl key. + +- `` `` - Simulates releasing a held shift key. + +- `` `` `` - Adds a 1, 5 or 10 second pause before + sending any additional keys. This is useful if you have to generally wait + for the UI to update before typing more. + +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. + +In addition to the special keys, each command to type is treated as a +[configuration template](/docs/templates/configuration-templates.html). The +available variables are: + +- `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server + that is started serving the directory specified by the `http_directory` + configuration parameter. If `http_directory` isn't specified, these will be + blank! + +Example boot command. This is actually a working boot command used to start an +Ubuntu 12.04 installer: + +``` {.text} +[ + "", + "/install/vmlinuz noapic ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", + "hostname={{ .Name }} ", + "fb=false debconf/frontend=noninteractive ", + "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", + "keyboard-configuration/variant=USA console-setup/ask_detect=false ", + "initrd=/install/initrd.gz -- " +] +``` \ No newline at end of file From ec6ea326189c93abfc86f90500bb065414874db8 Mon Sep 17 00:00:00 2001 From: Taliesin Sisson Date: Tue, 20 Sep 2016 16:55:56 +0100 Subject: [PATCH 5/5] Made requested documentation changes. Line break at 80 chars. --- website/source/docs/builders/parallels-iso.html.md | 6 +++++- website/source/docs/builders/parallels-pvm.html.md | 2 -- website/source/docs/builders/virtualbox-iso.html.md | 6 +++++- website/source/docs/builders/virtualbox-ovf.html.md | 5 +---- website/source/docs/builders/vmware-iso.html.md | 6 +++++- website/source/docs/builders/vmware-vmx.html.md | 11 +++++------ 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/website/source/docs/builders/parallels-iso.html.md b/website/source/docs/builders/parallels-iso.html.md index 649c8ebb0..6954f8698 100644 --- a/website/source/docs/builders/parallels-iso.html.md +++ b/website/source/docs/builders/parallels-iso.html.md @@ -278,7 +278,11 @@ proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, +otherwise they will be held down until the machine reboots. Use lowercase +characters as well inside modifiers. + +For example: to simulate ctrl+c use `c`. In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The diff --git a/website/source/docs/builders/parallels-pvm.html.md b/website/source/docs/builders/parallels-pvm.html.md index c75d9f63b..d02dd9f10 100644 --- a/website/source/docs/builders/parallels-pvm.html.md +++ b/website/source/docs/builders/parallels-pvm.html.md @@ -220,8 +220,6 @@ proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. - In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: diff --git a/website/source/docs/builders/virtualbox-iso.html.md b/website/source/docs/builders/virtualbox-iso.html.md index 48fcbe9f1..8a8cca4f0 100644 --- a/website/source/docs/builders/virtualbox-iso.html.md +++ b/website/source/docs/builders/virtualbox-iso.html.md @@ -312,7 +312,11 @@ by the proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, +otherwise they will be held down until the machine reboots. Use lowercase +characters as well inside modifiers. + +For example: to simulate ctrl+c use `c`. In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The diff --git a/website/source/docs/builders/virtualbox-ovf.html.md b/website/source/docs/builders/virtualbox-ovf.html.md index 302d94683..bfba94221 100644 --- a/website/source/docs/builders/virtualbox-ovf.html.md +++ b/website/source/docs/builders/virtualbox-ovf.html.md @@ -219,8 +219,7 @@ builder. The `boot_command` configuration is very important: it specifies the keys to type when the virtual machine is first booted in order to start the OS -installer. This command is typed after `boot_wait`, which gives the virtual -machine some time to actually load the ISO. +installer. This command is typed after `boot_wait`. As documented above, the `boot_command` is an array of strings. The strings are all typed in sequence. It is an array only to improve readability within the @@ -275,8 +274,6 @@ by the proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. - In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: diff --git a/website/source/docs/builders/vmware-iso.html.md b/website/source/docs/builders/vmware-iso.html.md index 9599c0630..8c56b4f9b 100644 --- a/website/source/docs/builders/vmware-iso.html.md +++ b/website/source/docs/builders/vmware-iso.html.md @@ -336,7 +336,11 @@ by the proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. +When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, +otherwise they will be held down until the machine reboots. Use lowercase +characters as well inside modifiers. + +For example: to simulate ctrl+c use `c`. In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The diff --git a/website/source/docs/builders/vmware-vmx.html.md b/website/source/docs/builders/vmware-vmx.html.md index e26c6f0c4..1ed8110c1 100644 --- a/website/source/docs/builders/vmware-vmx.html.md +++ b/website/source/docs/builders/vmware-vmx.html.md @@ -158,8 +158,7 @@ builder. The `boot_command` configuration is very important: it specifies the keys to type when the virtual machine is first booted in order to start the OS -installer. This command is typed after `boot_wait`, which gives the virtual -machine some time to actually load the ISO. +installer. This command is typed after `boot_wait`. As documented above, the `boot_command` is an array of strings. The strings are all typed in sequence. It is an array only to improve readability within the @@ -200,9 +199,11 @@ by the proper key: - `` `` - Simulates pressing and holding the alt key. -- `` `` - Simulates pressing and holding the ctrl key. +- `` `` - Simulates pressing and holding the ctrl + key. -- `` `` - Simulates pressing and holding the shift key. +- `` `` - Simulates pressing and holding the + shift key. - `` `` - Simulates releasing a held alt key. @@ -214,8 +215,6 @@ by the proper key: sending any additional keys. This is useful if you have to generally wait for the UI to update before typing more. -When using modifier keys `ctrl`, `alt`, `shift` ensure that you release them, otherwise they will be held down until the machine reboots. Use lowercase characters as well inside modifiers. For example: to simulate ctrl+c use `c`. - In addition to the special keys, each command to type is treated as a [configuration template](/docs/templates/configuration-templates.html). The available variables are: