Initial commit - it works!

This commit is contained in:
B.J. Dweck 2020-10-11 23:51:01 +02:00
commit 29269cc031
8 changed files with 103 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build/
parameters.env

29
build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
source parameters.env
rm -rf build
mkdir build
eval "cat <<~
$(cat src/cmdline.txt)
~" > build/cmdline.txt
mkdir build/cloud-init
eval "cat <<~
$(cat src/user-data)
~" > build/cloud-init/user-data
cp src/meta-data build/cloud-init/
cp src/initial-setup.sh build/cloud-init/
cp src/install-torch.sh build/cloud-init/
cp src/torch-agent_0.0.4-1_all.deb build/cloud-init/
mkdir build/cloud-init/torch-config
cp -r $TORCH_CONFIG_DIR/* build/cloud-init/torch-config/
tar -C build -czvf build/rpi-cloud-init.tgz cmdline.txt cloud-init
rm -rf build/cloud-init
rm build/cmdline.txt

1
src/cmdline.txt Normal file
View File

@ -0,0 +1 @@
net.ifnames=0 dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=LABEL=writable rootfstype=ext4 elevator=deadline rootwait fixrtc ipv6.disable=$DISABLE_IPV6 ds=nocloud;s=/boot/firmware/cloud-init/

30
src/initial-setup.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh -e
export DEBIAN_FRONTEND=noninteractive
apt-get -y purge\
cloud-init cloud-guest-utils\
cloud-initramfs-copymods cloud-initramfs-dyn-netconf\
open-iscsi
rm -rf /etc/cloud/ /var/lib/cloud/
apt-get update
apt-get -y\
-o Dpkg::Options::="--force-confdef"\
-o Dpkg::Options::="--force-confold"\
upgrade
apt-get -y install\
vim\
gparted\
libc6:armhf libstdc++6:armhf\
lxterminal\
usbmount
# Workaround for usbmount bug on Bionic
mkdir -p /etc/systemd/system/systemd-udevd.service.d
echo "[Service]\nMountFlags=shared\n" >\
/etc/systemd/system/systemd-udevd.service.d/override.conf
systemctl daemon-reload
service systemd-udevd --full-restart

7
src/install-torch.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh -e
apt-get -y install /boot/firmware/cloud-init/torch-agent_0.0.4-1_all.deb
cp -r /boot/firmware/cloud-init/torch-config/* /etc/torch/
chown torch -R /etc/torch
systemctl daemon-reload
systemctl enable torch-agent

1
src/meta-data Normal file
View File

@ -0,0 +1 @@
dsmode: local

Binary file not shown.

33
src/user-data Normal file
View File

@ -0,0 +1,33 @@
#cloud-config
# The networking setup is a bit of a hack, because the cloud-init network
# configuration doesn't support WiFi, see
# https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html.
users:
- name: $USERNAME
gecos: $USERFULLNAME
groups: [sudo, users]
sudo: ALL=(ALL) NOPASSWD:ALL
lock_passwd: false
shell: /bin/bash
ssh_authorized_keys:
- $SSH_PUBKEY
runcmd:
# Disable optional PAM features for faster SSH login
# - 'mv /etc/pam.d/sshd /etc/pam.d/sshd.bak'
# - 'sed "s/^session[ \t]\+optional/#\0/" /etc/pam.d/sshd.bak > /etc/pam.d/sshd'
# Back up the SSH default config and activate the new config
# - 'mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak'
# - 'mv /etc/ssh/sshd_config.new /etc/ssh/sshd_config'
# - 'service ssh reload'
# Multi-arch support on aarch64
- 'dpkg --add-architecture armhf'
# Run optional script for additoinal package setup
- '/boot/firmware/cloud-init/initial-setup.sh'
- '/boot/firmware/cloud-init/install-torch.sh'
- 'reboot now'