From 0c6ec371ba2c933be89f260f398b779fcba6a6be Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 22 Jul 2023 22:02:33 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E6=B7=BB=E5=8A=A0=20cloud-init=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nocloud.yaml | 21 +++++++++++++++++++++ trans.sh | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 nocloud.yaml diff --git a/nocloud.yaml b/nocloud.yaml new file mode 100644 index 0000000..08c0afe --- /dev/null +++ b/nocloud.yaml @@ -0,0 +1,21 @@ +#cloud-config +datasource_list: [NoCloud] +disable_root: false +ssh_pwauth: true +users: + - name: root + lock_passwd: false +chpasswd: + expire: false + # 20.04 arm 需要 + list: | + root:123@@@ + users: + - name: root + password: 123@@@ + type: text +runcmd: + # arch 没有 /etc/ssh/sshd_config.d/ 文件夹 + - echo "PermitRootLogin yes" >/etc/ssh/sshd_config.d/01-permitrootlogin.conf || echo "PermitRootLogin yes" >>/etc/ssh/sshd_config + - systemctl restart sshd + - echo -e '\nDone' >/dev/tty0 diff --git a/trans.sh b/trans.sh index 7a5b770..d21a719 100644 --- a/trans.sh +++ b/trans.sh @@ -379,7 +379,7 @@ fi update_part /dev/$xda if is_use_cloud_image; then - apk add qemu-img + apk add qemu-img lsblk mkdir -p /installer mount /dev/disk/by-label/installer /installer @@ -423,6 +423,12 @@ if is_use_cloud_image; then umount /installer/ dd if=/first-1M of=/dev/$xda update_part /dev/$xda + + # 找到系统分区,也就是最大的分区 + os_part=$(lsblk /dev/sda*[0-9] --sort SIZE -o NAME | tail -1) + mkdir -p /os + mount /dev/$os_part /os + download $confhome/nocloud.yaml /os/etc/cloud/cloud.cfg.d/99_nocloud.cfg exit else # 挂载主分区