-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiotlab.pkr.hcl
101 lines (89 loc) · 2.94 KB
/
iotlab.pkr.hcl
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
variable "ssh_password" {
type = string
default = "TH3P455W0RD"
}
# Some sources:
# https://github.com/multani/packer-qemu-debian/tree/master
source "qemu" "iot-base" {
iso_url = "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso"
iso_checksum = "04396d12b0f377958a070c38a923c227832fa3b3e18ddc013936ecf492e9fbb3"
output_directory = "build-iotlab"
shutdown_command = "echo '${var.ssh_password}' | sudo -S /sbin/shutdown -hP now"
disk_size = "40G"
format = "qcow2"
cpus = "4"
memory = "4096"
accelerator = "kvm"
http_directory = "http"
http_port_min = "9000"
http_port_max = "9010"
ssh_username = "laboratory"
ssh_password = "${var.ssh_password}"
ssh_timeout = "20m"
host_port_min = "2000"
host_port_max = "2010"
vm_name = "iot_base.qcow2"
net_device = "virtio-net"
disk_interface = "virtio"
boot_wait = "5s"
headless = "true"
boot_command = [
"<down><tab>",
"preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/debian-preseed.cfg ",
"language=en locale=de_DE.UTF-8 ",
"country=DE keymap=de ",
"hostname=debian domain=example.com ",
"<enter><wait>"]
}
# Necessary:
# https://askubuntu.com/questions/1309029/qemu-display-gtk-and-display-sdl-not-available-ubuntu-20-04-1-lts
build {
sources = ["source.qemu.iot-base"]
## Copy files
# Programs
provisioner "file" {
sources = [
"dependencies/openjdk-17+35_linux-x64_bin.tar.gz",
"dependencies/apache-ant-1.10.14-bin.tar.gz",
"dependencies/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2",
"dependencies/mspgcc-4.7.2-compiled.tar.bz2"
]
destination = "/tmp/"
}
# Configuration file for autologin
provisioner "file" {
source = "files/lightdm.conf"
destination = "/tmp/"
}
# Set up automatic login
provisioner "shell" {
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
inline = [
"mv /tmp/lightdm.conf /etc/lightdm/lightdm.conf"
]
}
# Install and set up contiki development environment
provisioner "shell" {
environment_vars = ["DEBIAN_FRONTEND=noninteractive"]
execute_command = "echo 'packer' | sudo -S env {{ .Vars }} {{ .Path }}"
scripts = [
# Install programs first
"scripts/programs/programs-basic.sh",
"scripts/programs/programs-network.sh",
"scripts/programs/java-17.sh",
"scripts/programs/ant.sh",
# Set up main system
"scripts/environments/contiki.sh",
"scripts/autostart.sh",
"scripts/fs_share.sh",
"scripts/startmenu.sh",
# Create desktop entries
"scripts/desktops/desktop-contiki.sh",
"scripts/desktops/desktop-exercises.sh",
"scripts/desktops/desktop-filezilla.sh",
"scripts/desktops/desktop-shell.sh",
# Fix permissions (must be called last)
"scripts/permissions.sh"
]
}
}