diff options
author | Christian Pointner <equinox@spreadspace.org> | 2024-03-09 04:37:29 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2024-03-09 04:37:29 +0100 |
commit | 2f548a512345e9208991219443315df305724997 (patch) | |
tree | a996a155bdcf142a2cae319231cf1fcd67e2789f /roles/raspios/image/templates | |
parent | add ch-zimablade (diff) |
raspios: add support for bookworm
Diffstat (limited to 'roles/raspios/image/templates')
-rw-r--r-- | roles/raspios/image/templates/firstrun.sh.j2 | 63 |
1 files changed, 50 insertions, 13 deletions
diff --git a/roles/raspios/image/templates/firstrun.sh.j2 b/roles/raspios/image/templates/firstrun.sh.j2 index d5e72fcc..9e398751 100644 --- a/roles/raspios/image/templates/firstrun.sh.j2 +++ b/roles/raspios/image/templates/firstrun.sh.j2 @@ -1,6 +1,12 @@ #!/bin/bash set +e +if [ -x /usr/lib/raspberrypi-sys-mods/get_fw_loc ]; then + FW_LOC=$(/usr/lib/raspberrypi-sys-mods/get_fw_loc) +else + FW_LOC=/boot +fi + raspi-config nonint do_hostname "{{ host_name }}" echo "{{ host_name }}" > /etc/hostname raspi-config nonint do_change_locale "{{ raspios_locale }}" @@ -10,7 +16,8 @@ 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)) %} +{% if raspios_codename == 'bullseye' %} +{% if not (install_dhcp | default(false)) %} cat <<EOF >> /etc/dhcpcd.conf # @@ -20,39 +27,69 @@ static routers={{ network.primary.gateway }} static domain_name_servers={{ network.nameservers | join(' ') }} EOF systemctl restart dhcpcd.service +{% endif %} +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 %} +{% else %} +cat <<EOF >> /etc/network/interfaces + +auto {{ network.primary.name }} +{% if (install_dhcp | default(false)) %} +iface {{ network.primary.name }} inet dhcp +{% else %} +iface {{ network.primary.name }} inet static + address {{ network.primary.address | ansible.utils.ipaddr('address') }} + netmask {{ network.primary.address | ansible.utils.ipaddr('netmask') }} + gateway {{ network.primary.gateway }} +{% endif %} +{% if 'wifi' in network.primary %} + wpa-ssid {{ network.primary.wifi.ssid }} + wpa-psk {{ network.primary.wifi.key }} +{% endif %} +EOF +{% if not (install_dhcp | default(false)) %} +cat <<EOF > /etc/resolv.conf +# Generated by ansible +search {{ network.domain }} +{% for nameserver in network.nameservers %} +nameserver {{ nameserver }} +{% endfor %} +EOF +{% endif %} +systemctl disable wpa_supplicant.service +rfkill unblock wlan +ifup {{ network.primary.name }} {% endif %} {% if ansible_port != 22 %} sed -e 's/^\s*#*\s*Port\s\s*[0-9][0-9]*$/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 +install -m 0644 "$FW_LOC/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#systemd.run=/boot/firstrun.sh systemd.run_success_action=reboot systemd.run_failure_action=none 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 "$FW_LOC/firstrun.authorized_keys" +rm "$FW_LOC/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 +apt-get dist-upgrade -y -q {# B1 -> Console, B2 -> console autologin, B3 -> desktop, B4 -> desktop autologin #} raspi-config nonint do_boot_behaviour B1 |