commit: d7bf9bcdb3fcc901445137881858602fe6d720eb
Author: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 13 17:03:38 2024 +0000
Commit: Andreas K. Hüttel <dilfridge <AT> gentoo <DOT> org>
CommitDate: Sun Oct 13 17:03:38 2024 +0000
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=d7bf9bcd
First shot at sshd image
Signed-off-by: Andreas K. Hüttel <dilfridge <AT> gentoo.org>
catalyst/targets/diskimage_stage2.py | 1 +
targets/support/diskimagefs-update.sh | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/catalyst/targets/diskimage_stage2.py
b/catalyst/targets/diskimage_stage2.py
index bcad8b0d..8fab976d 100644
--- a/catalyst/targets/diskimage_stage2.py
+++ b/catalyst/targets/diskimage_stage2.py
@@ -33,6 +33,7 @@ class diskimage_stage2(StageBase):
"diskimage/readme",
"diskimage/rm",
"diskimage/type", # generic, cloud-init, ssh, console
+ "diskimage/sshkey",
"diskimage/unmerge",
"diskimage/users",
"diskimage/verify",
diff --git a/targets/support/diskimagefs-update.sh
b/targets/support/diskimagefs-update.sh
index 45d870a5..d7d005de 100755
--- a/targets/support/diskimagefs-update.sh
+++ b/targets/support/diskimagefs-update.sh
@@ -16,6 +16,24 @@ if [[ $(readlink /etc/portage/make.profile) == *systemd* ]]
; then
# generic - an image with no means of logging in... needs postprocessing
# no services are started
+configure_dhcp() {
+ echo "Configuring DHCP on all ethernet devices"
+ cat > /etc/systemd/network/default.network <<'END'
+[Match]
+Name=en*
+
+[Network]
+DHCP=yes
+END
+}
+
+configure_sshd() {
+ echo "Configuring sshd"
+ mkdir -vp /root/.ssh
+ chown root:root /root/.ssh
+ echo "${clst_diskimage_sshkey}" > /root/.ssh/authorized_keys
+}
+
echo "Generating /etc/locale.gen"
cat > /etc/locale.gen <<END
en_US ISO-8859-1
@@ -45,7 +63,16 @@ case ${clst_diskimage_type} in
passwd -d root || die "Failed removing root password"
echo "Running systemd-firstboot"
systemd-firstboot --timezone=UTC || die "Failed running
systemd-firstboot"
+ configure_dhcp
;;
+ ssh)
+ echo "Setting up ssh log-in image, using key ${xxx}"
+ echo "Running systemd-firstboot"
+ systemd-firstboot --timezone=UTC || die "Failed running
systemd-firstboot"
+ configure_dhcp
+ configure_sshd
+ echo "Adding sshd service"
+ systemctl enable sshd
*)
die "As yet unsupported image type"
;;