...
 
Commits (2)
/settings-private.sh
/system-boot/cloud-init/user-data
#!/bin/sh -e
cd "$(dirname "$0")"
source settings-public.sh
source settings-private.sh
eval "cat <<:"$'\n'"$(< user-data-template)"$'\n': > system-boot/cloud-init/user-data
PASSWD="\$6\$DummySalt\$pmv57y2eu47TsC16x0lhAOnj8A5hioy3o6VT.rD3s7XSa1Ot6bFRMbhsSto1MHbeM3T9761HYWpJNuptWGL57/"
WIFI_SSID="Dummy Network"
WIFI_PASSWD="DummyPassword"
USER="$(id -un)"
NAME="$(id -F)"
SSH_ID_RSA_PUB="$(< $HOME/.ssh/id_rsa.pub)"
HOSTNAME=pi
TIMEZONE=Europe/Stockholm
#!/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\
docker.io docker-doc\
emacs\
gnuplot\
gparted\
language-pack-sv-base\
libc6:armhf libstdc++6:armhf\
lxterminal\
usbmount
# Workaround for usbmount bug on Bionic
mkdir /etc/systemd/system/systemd-udevd.service.d
echo "[Service]"$'\n'"MountFlags=shared"$'\n' >\
/etc/systemd/system/systemd-udevd.service.d/override.conf
systemctl daemon-reload
service systemd-udevd --full-restart
echo "*** Setup complete ***"
net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait ipv6.disable=1 ds=nocloud;s=/boot/firmware/cloud-init/
#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: $USER
gecos: $NAME
groups: [adm, docker, netdev, plugdev, sudo, users]
sudo: ["ALL=NOPASSWD: /sbin/shutdown, /sbin/reboot, /bin/ls, /bin/cat"]
lock_passwd: false
shell: /bin/bash
passwd: $PASSWD
ssh_authorized_keys:
- $SSH_ID_RSA_PUB
write_files:
- content: |
network:
version: 2
wifis:
wlan0:
dhcp4: true
access-points:
"$WIFI_SSID":
password: "$WIFI_PASSWD"
path: /etc/netplan/config.yaml
- content: |
PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
PrintLastLog no
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
path: /etc/ssh/sshd_config.new
bootcmd:
- 'systemctl disable systemd-networkd-wait-online.service'
- 'systemctl mask systemd-networkd-wait-online.service'
runcmd:
- 'rm /etc/netplan/??-cloud-init.yaml'
- 'chmod go-r /etc/netplan/config.yaml'
- 'netplan apply'
- 'mv /etc/ssh/sshd_config /etc/ssh/sshd_config.bak'
- 'mv /etc/ssh/sshd_config.new /etc/ssh/sshd_config'
- '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'
- 'service ssh reload'
- 'dpkg --add-architecture armhf'
- 'apt-get update'
- 'apt-get -y install iw'
- 'iw reg set $WIFI_REGDOMAIN'
- 'mv /etc/default/crda /etc/default/crda.bak'
- 'echo REGDOMAIN=$WIFI_REGDOMAIN > /etc/default/crda'
- '/bin/sh -e /boot/firmware/cloud-init/setup.sh'
locale: C.UTF-8
hostname: $HOSTNAME
timezone: $TIMEZONE