Skip to content

Commit

Permalink
* Overall refactoring
Browse files Browse the repository at this point in the history
* Update base image to Armbian buster
* Enable support for MCP2515 CAN controller
* Install SignalK, canboat, etc.
  • Loading branch information
alexsomesan committed Sep 21, 2022
1 parent 373389d commit 4942691
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 174 deletions.
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
Armbian*.img
armbian_first_run.txt
armbian_first_run.txt.template
armbianEnv.txt
armbianEnv.txt.template
*.img*
tmp
output-arm-image/
47 changes: 0 additions & 47 deletions build-home-wifi.json

This file was deleted.

71 changes: 0 additions & 71 deletions build.json

This file was deleted.

181 changes: 181 additions & 0 deletions build.pkr.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,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",
]
}
}
24 changes: 0 additions & 24 deletions provision/Hotspot.nmconnection

This file was deleted.

20 changes: 11 additions & 9 deletions provision/build-from-src.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
mkdir -p /tmp/build
cd /tmp/build

wget -O kplex.zip https://github.com/stripydog/kplex/archive/master.zip
unzip kplex.zip
cd kplex-master
git clone --depth 1 https://github.com/stripydog/kplex.git
cd kplex
make && make install
cd ..

wget -O rtl-sdr.zip https://github.com/osmocom/rtl-sdr/archive/master.zip
unzip rtl-sdr.zip
cd rtl-sdr-master
git clone --depth 1 https://gitea.osmocom.org/sdr/rtl-sdr.git
cd rtl-sdr
mkdir _build && cd _build
cmake ../ -Wno-dev -DDETACH_KERNEL_DRIVER=ON -DINSTALL_UDEV_RULES=ON
make install
ldconfig
cd ..

wget -O rtl-ais.zip https://github.com/dgiardini/rtl-ais/archive/master.zip
unzip rtl-ais.zip
cd rtl-ais-master
git clone --depth 1 https://github.com/dgiardini/rtl-ais.git
cd rtl-ais
make && cp rtl_ais /usr/local/bin/
cd ..

git clone --depth 1 https://github.com/canboat/canboat.git
# cd canboat
# make install
# cd ..
5 changes: 5 additions & 0 deletions provision/can0.ifconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
auto can0
iface can0 inet manual
pre-up /sbin/ip link set can0 type can bitrate 250000 triple-sampling on restart-ms 100
up /sbin/ifconfig can0 up
down /sbin/ifconfig can0 down
5 changes: 0 additions & 5 deletions provision/configure-hotspot.sh

This file was deleted.

2 changes: 1 addition & 1 deletion provision/dt-overlays.sed
Original file line number Diff line number Diff line change
@@ -1 +1 @@
s/^overlays=.*$/overlays=uart1 uart2 uart3 usbhost0 usbhost1 usbhost2 usbhost3/
s/^overlays=.*$/overlays=uart1 uart2 usbhost0 usbhost1 usbhost2 usbhost3/
Loading

0 comments on commit 4942691

Please sign in to comment.