From 8b2420f74367e4973be0dd9556c021588abfe591 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 30 May 2026 09:58:45 +0200 Subject: Initial commit --- board/common/common.sh | 28 ++++++++++++++++ board/common/network.sh | 36 +++++++++++++++++++++ board/common/post-build.sh | 37 ++++++++++++++++++++++ .../etc/ssh/sshd_config.d/locale.conf | 1 + .../etc/ssh/sshd_config.d/no_password.conf | 2 ++ .../etc/systemd/resolved.conf.d/listen_all.conf | 3 ++ 6 files changed, 107 insertions(+) create mode 100644 board/common/common.sh create mode 100644 board/common/network.sh create mode 100755 board/common/post-build.sh create mode 100644 board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf create mode 100644 board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf create mode 100644 board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf (limited to 'board/common') diff --git a/board/common/common.sh b/board/common/common.sh new file mode 100644 index 0000000..ee1af1f --- /dev/null +++ b/board/common/common.sh @@ -0,0 +1,28 @@ +create_missing_dir() { + echo "creating directory ${TARGET_DIR}/$1" + test -d "${TARGET_DIR}/$1" || mkdir -p "${TARGET_DIR}/$1" +} + +remove_text() { + echo sed --in-place "s/$2//" $1 + sed --in-place "s/$2//" $1 +} + +add_tmpfs() { + create_missing_dir "$1" + if ! grep -q "$1" "${TARGET_DIR}/etc/fstab"; then + cat << __EOF__ >> "${TARGET_DIR}/etc/fstab" +tmpfs $1 tmpfs rw 0 0 +__EOF__ + fi +} + +# Enable a systemd service +enable_service() { + if [ -e "$BR2_EXTERNAL_BASTION_PATH/local/services/$1" ]; then + cp "$BR2_EXTERNAL_BASTION_PATH/local/services/$1" "${TARGET_DIR}/etc/systemd/system/$1" + else + echo "WARN: local/services/$1 does not exists" + fi + ln -sf /etc/systemd/system/$1 "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/$1" +} diff --git a/board/common/network.sh b/board/common/network.sh new file mode 100644 index 0000000..d28997e --- /dev/null +++ b/board/common/network.sh @@ -0,0 +1,36 @@ +########################### +# # +# Network configuration # +# # +########################### + +# Add default wpa_supplicant.conf if it exists +if [ -f "$BR2_EXTERNAL_BASTION_PATH/wpa_supplicant.conf" ]; then + create_missing_dir "/etc/wpa_supplicant/" + cat "$BR2_EXTERNAL_BASTION_PATH/wpa_supplicant.conf" > "${TARGET_DIR}/etc/wpa_supplicant/wpa_supplicant-wlan0.conf" + + +# cat << __EOF__ > "${TARGET_DIR}/etc/systemd/network/wireless.network" +#[Match] +#Name=wlan0 +# +#[Network] +#DHCP=yes +#__EOF__ + + # Create the link to interface wlan0 directly in the system configuration + ln -sf /usr/lib/systemd/system/wpa_supplicant@.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/wpa_supplicant@wlan0.service" + +fi + + +cat << __EOF__ > "${TARGET_DIR}/etc/systemd/network/dhcp.network" +[Match] +Name=* + +[Network] +DHCP=yes + +[DHCP] +UseDNS=true +__EOF__ diff --git a/board/common/post-build.sh b/board/common/post-build.sh new file mode 100755 index 0000000..d96b74b --- /dev/null +++ b/board/common/post-build.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +set -u +set -e + +# Copie des fichiers de clef ssh +cp -v $BR2_EXTERNAL_BASTION_PATH/local/ssh/* ${TARGET_DIR}/etc/ssh +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_ecdsa_key +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_ed25519_key +chmod go-r ${TARGET_DIR}/etc/ssh/ssh_host_rsa_key +if ! grep -qF 'Include /etc/ssh/sshd_config.d/*.conf' "${TARGET_DIR}/etc/ssh/sshd_config"; then + cat << __EOF__ >> "${TARGET_DIR}/etc/ssh/sshd_config" +Include /etc/ssh/sshd_config.d/*.conf +__EOF__ +fi + + +#touch ${TARGET_DIR}/home/sebastien/test + +. "${BR2_EXTERNAL_BASTION_PATH}/board/common/common.sh" +. "${BR2_EXTERNAL_BASTION_PATH}/board/common/network.sh" +add_tmpfs '/tmp' +# +## Add a console on tty1 +#if [ -e ${TARGET_DIR}/etc/inittab ]; then +# grep -qE '^tty1::' ${TARGET_DIR}/etc/inittab || \ +# sed -i '/GENERIC_SERIAL/a\ +#tty1::respawn:/sbin/getty -L tty1 0 vt100 # HDMI console' ${TARGET_DIR}/etc/inittab +#fi + +# Put the whole system in readonly +#sed -ie '/^\/dev\/root/ s/rw 0 1/ro 0 0/' "${TARGET_DIR}/etc/fstab" + +mkdir -p "${TARGET_DIR}"/etc/systemd/system/getty.target.wants +# Add a console on ttyAMA0 and enable auto login +ln -sf /usr/lib/systemd/system/serial-getty@.service "${TARGET_DIR}"/etc/systemd/system/getty.target.wants/serial-getty@ttyGS0.service +sed '/^ExecStart=/ s/-o .-p -- ..u./--skip-login --noclear --noissue --login-options "-f root"/' -i "${TARGET_DIR}"/usr/lib/systemd/system/serial-getty@.service diff --git a/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf new file mode 100644 index 0000000..cce7f73 --- /dev/null +++ b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/locale.conf @@ -0,0 +1 @@ +AcceptEnv LANG LC_* COLORTERM NO_COLOR diff --git a/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf new file mode 100644 index 0000000..1efa6ab --- /dev/null +++ b/board/common/rootfs_overlay/etc/ssh/sshd_config.d/no_password.conf @@ -0,0 +1,2 @@ +PasswordAuthentication no +PubkeyAuthentication yes diff --git a/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf b/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf new file mode 100644 index 0000000..9e68b7a --- /dev/null +++ b/board/common/rootfs_overlay/etc/systemd/resolved.conf.d/listen_all.conf @@ -0,0 +1,3 @@ +[Resolve] +DNSStubListenerExtra=0.0.0.0 +DNSStubListenerExtra=:: -- cgit v1.2.3