forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
modify from https://github.com/armbian/build/pull/3774/files | ||
|
||
Firstrun 2 | ||
|
||
--- | ||
lib/functions/image/rootfs-to-image.sh | 4 ++++ | ||
lib/functions/main/rootfs-image.sh | 3 +++ | ||
.../systemd/system/armbian-firstrun-config.service | 6 ++++-- | ||
.../lib/systemd/system/armbian-firstrun.service | 5 +++-- | ||
packages/bsp/common/usr/lib/armbian/armbian-firstrun | 12 +++--------- | ||
5 files changed, 17 insertions(+), 13 deletions(-) | ||
|
||
diff --git a/lib/functions/image/rootfs-to-image.sh b/lib/functions/image/rootfs-to-image.sh | ||
index b592b2fe6..6f1374b51 100644 | ||
--- a/lib/functions/image/rootfs-to-image.sh | ||
+++ b/lib/functions/image/rootfs-to-image.sh | ||
@@ -71,6 +71,10 @@ PRE_UPDATE_INITRAMFS | ||
# fix wrong / permissions | ||
chmod 755 $MOUNT | ||
|
||
+ # cleanup image according to systemd.io/BUILDING_IMAGES/ | ||
+ echo -e "uninitialized\n" > ${MOUNT}/etc/machine-id | ||
+ rm ${MOUNT}/var/lib/systemd/random-seed ${MOUNT}/var/lib/dbus/machine-id | ||
+ | ||
call_extension_method "pre_umount_final_image" "config_pre_umount_final_image" << 'PRE_UMOUNT_FINAL_IMAGE' | ||
*allow config to hack into the image before the unmount* | ||
Called before unmounting both `/root` and `/boot`. | ||
diff --git a/lib/functions/main/rootfs-image.sh b/lib/functions/main/rootfs-image.sh | ||
index 9847350ce..7a957f183 100644 | ||
--- a/lib/functions/main/rootfs-image.sh | ||
+++ b/lib/functions/main/rootfs-image.sh | ||
@@ -81,6 +81,9 @@ PRE_INSTALL_DISTRIBUTION_SPECIFIC | ||
# install from apt.armbian.com | ||
[[ $EXTERNAL_NEW == prebuilt ]] && chroot_installpackages "yes" | ||
|
||
+ # remove existing ssh keys | ||
+ rm -f ${SDCARD}/etc/ssh/ssh_host_* | ||
+ | ||
# stage: user customization script | ||
# NOTE: installing too many packages may fill tmpfs mount | ||
customize_image | ||
diff --git a/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service b/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service | ||
index 20943ec42..08e701d96 100644 | ||
--- a/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service | ||
+++ b/packages/bsp/common/lib/systemd/system/armbian-firstrun-config.service | ||
@@ -3,13 +3,15 @@ | ||
|
||
[Unit] | ||
Description=Armbian first run optional user configuration | ||
-Wants=network-online.target | ||
+Wants=network-online.target first-boot-complete.target | ||
After=network.target network-online.target | ||
+Before=first-boot-complete.target | ||
ConditionPathExists=/boot/armbian_first_run.txt | ||
ConditionPathExists=/root/.not_logged_in_yet | ||
+ConditionFirstBoot=yes | ||
|
||
[Service] | ||
-Type=idle | ||
+Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/lib/armbian/armbian-firstrun-config | ||
TimeoutStartSec=2min | ||
diff --git a/packages/bsp/common/lib/systemd/system/armbian-firstrun.service b/packages/bsp/common/lib/systemd/system/armbian-firstrun.service | ||
index 64a390950..a22ef42e3 100644 | ||
--- a/packages/bsp/common/lib/systemd/system/armbian-firstrun.service | ||
+++ b/packages/bsp/common/lib/systemd/system/armbian-firstrun.service | ||
@@ -4,10 +4,11 @@ | ||
|
||
[Unit] | ||
Description=Armbian first run tasks | ||
-Before=getty.target system-getty.slice | ||
+Before=getty.target system-getty.slice first-boot-complete.target ssh.service | ||
+Wants=first-boot-complete.target | ||
|
||
[Service] | ||
-Type=simple | ||
+Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/lib/armbian/armbian-firstrun start | ||
TimeoutStartSec=2min | ||
diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstrun b/packages/bsp/common/usr/lib/armbian/armbian-firstrun | ||
index 32f3e88c7..8fa123328 100755 | ||
--- a/packages/bsp/common/usr/lib/armbian/armbian-firstrun | ||
+++ b/packages/bsp/common/usr/lib/armbian/armbian-firstrun | ||
@@ -53,10 +53,8 @@ case "$1" in | ||
sed '1s/^/IMAGE_UUID=/' /proc/sys/kernel/random/uuid >> /etc/armbian-image-release | ||
|
||
# SSH Keys creation | ||
- rm -f /etc/ssh/ssh_host* | ||
read entropy_before </proc/sys/kernel/random/entropy_avail | ||
- dpkg-reconfigure openssh-server >/dev/null 2>&1 | ||
- service sshd restart | ||
+ ssh-keygen -A >/dev/null 2>&1 | ||
read entropy_after </proc/sys/kernel/random/entropy_avail | ||
echo -e "\n### [firstrun] Recreated SSH keys (entropy: ${entropy_before} ${entropy_after})" >>${Log} | ||
|
||
@@ -107,12 +105,9 @@ case "$1" in | ||
|
||
mvebu64|mt7623) | ||
# configure/enable/start systemd-networkd | ||
- systemctl start systemd-networkd.service | ||
- systemctl start systemd-resolved.service | ||
- systemctl enable systemd-networkd.service | ||
- systemctl enable systemd-resolved.service | ||
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf | ||
- systemctl restart systemd-networkd | ||
+ systemctl enable --now systemd-networkd.service | ||
+ systemctl enable --now systemd-resolved.service | ||
;; | ||
x86|arm64) | ||
[[ -n "$(dmesg | grep "No NVIDIA GPU found")" ]] && sudo apt-get -y -qq purge nvidia-dkms-510 nvidia-driver-510 nvidia-settings nvidia-common >> /dev/null | ||
@@ -126,7 +121,6 @@ case "$1" in | ||
[[ $BRANCH == dev && $LINUXFAMILY == rockchip ]] && set_fixed_mac | ||
[[ $LINUXFAMILY == meson ]] && set_fixed_mac | ||
[[ $LINUXFAMILY == meson64 ]] && set_fixed_mac | ||
- systemctl disable armbian-firstrun | ||
exit 0 | ||
;; | ||
|
||
-- | ||
2.34.1 | ||
|