Skip to content

Commit 8804c98

Browse files
authored
Fix Kali provisioning (Parallels#63)
Use the local Packer http server to provision the post-install.sh script on preseed. Fix the Vagrant Kali provisionig script using USER instead of USERNAME
1 parent 3fc4166 commit 8804c98

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

http/kali-linux/preseed.cfg.pkrtpl.hcl

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ d-i cdrom-detect/eject boolean true
129129

130130
# Post-install commands
131131
d-i preseed/late_command string \
132-
in-target curl -L -o /root/post-install.sh "https://raw.githubusercontent.com/Parallels/packer-examples/main/http/kali/post-install.sh"; \
132+
in-target curl -L -o /root/post-install.sh "`cat /proc/cmdline | sed -n 's/.*url=\([^ ]*\)\/\.\/*.*$/\1/p'`/post-install.sh"; \
133133
in-target chmod +x /root/post-install.sh; \
134134
in-target /root/post-install.sh; \
135135
echo "${username} ALL=(ALL:ALL) NOPASSWD:ALL" > /target/etc/sudoers.d/${username} && chmod 0440 /target/etc/sudoers.d/${username}

kali-linux/provisioner.pkr.hcl

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ locals {
1616
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
1717
"<bs><bs><bs><bs><bs><bs><bs><bs><bs><bs>",
1818
"<bs><bs><bs><bs><bs><bs><bs><bs><bs>",
19-
"auto=true url=http://{{.HTTPIP}}:{{.HTTPPort}}/kali-linux/preseed.cfg priority=critical<f10><wait>"
19+
"auto=true url=http://{{.HTTPIP}}:{{.HTTPPort}}/kali-linux/./preseed.cfg priority=critical<f10><wait>"
2020
] : var.boot_command
2121

2222
iso_url = var.iso_url == "" ? "https://cdimage.kali.org/kali-${var.version == "" ? "2023.3" : var.version}/kali-linux-${var.version == "" ? "2023.3" : var.version}-installer-arm64.iso" : var.iso_url
@@ -52,6 +52,7 @@ source "parallels-iso" "image" {
5252
http_content = {
5353
"/kali-linux/meta-data" = templatefile("${path.root}/../http/kali-linux/meta-data.pkrtpl.hcl", { hostname = "${local.hostname}" })
5454
"/kali-linux/preseed.cfg" = templatefile("${path.root}/../http/kali-linux/preseed.cfg.pkrtpl.hcl", { username = "${local.username}", password = "${local.password}", hostname = "${local.hostname}", desktop = "${var.desktop}" })
55+
"/kali-linux/post-install.sh" = file("${path.root}/../http/kali-linux/post-install.sh")
5556
}
5657

5758
iso_url = local.iso_url

scripts/kali-linux/base/vagrant.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh -eux
22

33
# set a default HOME_DIR environment variable if not set
4-
HOME_DIR="${HOME_DIR:-/home/$USERNAME}"
4+
HOME_DIR="${HOME_DIR:-/home/$USER}"
55

66
pubkey_url="https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub"
77
mkdir -p "$HOME_DIR"/.ssh
@@ -18,5 +18,5 @@ fi
1818

1919
wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/authorized_keys
2020

21-
chown -R $USERNAME "$HOME_DIR"/.ssh
21+
chown -R "$USER" "$HOME_DIR"/.ssh
2222
chmod -R go-rwsx "$HOME_DIR"/.ssh

0 commit comments

Comments
 (0)