blob: 2ff0fd59eac33d670f8460f26795653314d30f06 (
plain) (
blame)
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
|
#!/bin/bash
set +e
raspi-config nonint do_hostname "{{ host_name }}"
echo "{{ host_name }}" > /etc/hostname
raspi-config nonint do_change_locale "{{ raspios_locale }}"
raspi-config nonint do_change_timezone "{{ raspios_timezone }}"
raspi-config nonint do_configure_keyboard "{{ raspios_keyboard_layout }}"
{# 0 -> predictable interface names, 1 -> legacy (eth0...) #}
raspi-config nonint do_net_names 1
{% if not (install_dhcp | default(false)) %}
cat <<EOF >> /etc/dhcpcd.conf
#
interface {{ network.primary.name }}
static ip_address={{ network.primary.address }}
static routers={{ network.primary.gateway }}
static domain_name_servers={{ network.nameservers | join(' ') }}
EOF
systemctl restart dhcpcd.service
{% endif %}
{% if ansible_port != 22 %}
sed -e 's/^#*Port .*$/Port {{ ansible_port }}/' -i /etc/ssh/sshd_config
{% endif %}
install -m 0700 -d /root/.ssh
install -m 0644 /boot/firstrun.authorized_keys /root/.ssh/authorized_keys
{# 0 -> enable ssh, 1 -> disable ssh #}
raspi-config nonint do_ssh 0
systemctl disable hciuart.service
{% if 'wifi' in network.primary %}
raspi-config nonint do_wifi_ssid_passphrase "{{ network.primary.wifi.ssid }}" "{{ network.primary.wifi.key }}"
raspi-config nonint do_wifi_country "AT"
{% else %}
systemctl disable wpa_supplicant.service
{% endif %}
export DEBIAN_FRONTEND=noninteractive
export SUDO_FORCE_REMOVE=yes
apt-get purge -q -y userconf-pi avahi-daemon triggerhappy rsync dpkg-dev patch gdb make strace ssh-import-id network-manager udisks2 p7zip p7zip-full sudo
apt-get autoremove -q -y
dpkg -l | grep "^rc" | awk "{ print(\$2) }" | xargs -r dpkg -P
sed 's#systemd.run=/boot/firstrun.sh systemd.run_success_action=reboot systemd.unit=kernel-command-line.target##' -i /boot/cmdline.txt
sed 's#\s*$##' -i /boot/cmdline.txt
rm /boot/firstrun.authorized_keys
rm /boot/firstrun.sh
rm -f /etc/sudoers.d/010_pi-nopasswd
rm -f /etc/apt/sources.list.d/vscode.list
rm -f /etc/apt/trusted.gpg.d/microsoft.gpg
apt-get update -q
apt-get upgrade -y -q
{# B1 -> Console, B2 -> console autologin, B3 -> desktop, B4 -> desktop autologin #}
raspi-config nonint do_boot_behaviour B1
systemctl --quiet enable getty@tty1
|