-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.pkr.hcl
181 lines (154 loc) · 4.99 KB
/
build.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
variable "login_user" {
type = string
default = "alex"
}
variable "login_pass" {
type = string
default = "daedalus"
}
variable "local_ssh_public_key" {
type = string
default = "/home/alex/.ssh/id_rsa.pub"
}
variable "root_pass" {
type = string
default = "daedalus"
}
variable "output_img_size" {
type = number
default = 4 * 1024 * 1024 * 1024
}
variable "hotspot_dev" {
type = string
default = "wlan0"
}
variable "hotspot_ssid" {
type = string
default = "Fenix"
}
variable "hotspot_pass" {
type = string
default = "Macanache"
}
locals {
image_home_dir = "/home/${var.login_user}"
}
source "arm-image" "armbian" {
image_mounts = ["/"]
iso_checksum = "sha256:f43e88596e736f44d72ed7ad98de447405bf908739d5981fdb36293fd3e295ec"
iso_url = "https://armbian.hosthatch.com/archive/orangepizeroplus2-h5/archive/Armbian_21.08.1_Orangepizeroplus2-h5_buster_current_5.10.60.img.xz"
iso_target_path = "./Armbian.img"
qemu_binary = "qemu-aarch64-static"
target_image_size = var.output_img_size
}
build {
sources = ["source.arm-image.armbian"]
provisioner "shell" {
inline = [
"rm -f /etc/systemd/system/[email protected]/override.conf",
"rm -f /etc/systemd/system/[email protected]/override.conf",
"rm -r /root/.not_logged_in_yet",
"echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list",
"curl -sL https://deb.nodesource.com/setup_16.x | bash -",
"apt-get --allow-releaseinfo-change update",
"apt-get upgrade -y",
"apt-get install -y build-essential cmake rustc-mozilla cargo-mozilla python3 python3-dev python3-pip python3-venv libffi-dev git libusb-1.0-0-dev pkg-config dnsmasq-base avahi-daemon tmux can-utils nodejs libnss-mdns avahi-utils libavahi-compat-libdnssd-dev xsltproc libxml2-utils",
"apt install -y -t buster-backports cockpit",
"npm install -g npm@latest",
"npm install -g signalk-server",
"/usr/sbin/useradd -m -r signalk",
"/usr/sbin/useradd -p '${var.login_pass}' -s /usr/bin/zsh -m ${var.login_user}",
"echo '${var.login_user} ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers",
"(echo '${var.root_pass}'; echo '${var.root_pass}';) | passwd root",
"mkdir -p /root/.ssh",
"/usr/sbin/usermod -s /usr/bin/zsh root"
]
}
provisioner "file" {
source = pathexpand(var.local_ssh_public_key)
destination = "/root/.ssh/authorized_keys"
}
provisioner "file" {
direction = "download"
source = "/boot/armbianEnv.txt"
destination = "tmp/armbianEnv.txt.orig"
}
provisioner "shell-local" {
command = "sed -f provision/dt-overlays.sed < tmp/armbianEnv.txt.orig > tmp/armbianEnv.txt"
}
provisioner "file" {
direction = "upload"
generated = true
source = "tmp/armbianEnv.txt"
destination = "/boot/armbianEnv.txt"
}
provisioner "file" {
direction = "upload"
source = "provision/blacklist-rtlsdr.conf"
destination = "/etc/modprobe.d/blacklist-rtlsdr.conf"
}
provisioner "file" {
direction = "upload"
source = "provision/sun50i-h5-mcp2515.dts"
destination = "/root/sun50i-h5-mcp2515.dts"
}
provisioner "file" {
direction = "upload"
source = "provision/kplex.conf"
destination = "/etc/kplex.conf"
}
provisioner "file" {
direction = "upload"
source = "provision/can0.ifconfig"
destination = "/etc/network/interfaces.d/can0"
}
provisioner "file" {
direction = "upload"
source = "provision/kplex.service"
destination = "/etc/systemd/system/kplex.service"
}
provisioner "file" {
direction = "upload"
source = "provision/rtl-ais.service"
destination = "/etc/systemd/system/rtl-ais.service"
}
provisioner "file" {
direction = "upload"
source = "provision/signalk-service.service"
destination = "/etc/systemd/system/signalk-service.service"
}
provisioner "file" {
direction = "upload"
source = "provision/reload-rtlmod.service"
destination = "/etc/systemd/system/reload-rtlmod.service"
}
provisioner "shell" {
inline = [
"pip3 install -U pip",
"pip3 install -U setuptools",
"pip3 install -U wheel",
"pip3 install -U esptool",
]
}
provisioner "shell" {
inline = [
"sudo armbian-add-overlay /root/sun50i-h5-mcp2515.dts",
# "systemctl enable rtl-ais.service",
# "systemctl enable kplex.service",
"systemctl enable signalk-service.service",
"systemctl enable reload-rtlmod.service",
"systemctl set-default multi-user.target",
]
}
provisioner "shell" {
inline = [
# "nmcli con add type wifi ifname ${var.hotspot_dev} con-name Hostspot autoconnect yes ssid '${var.hotspot_ssid}' 802-11-wireless.mode ap ipv4.method shared wifi-sec.key-mgmt wpa-psk wifi-sec.psk '${var.hotspot_pass}'",
"",
]
}
provisioner "shell" {
scripts = [
"provision/build-from-src.sh",
]
}
}