summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-12-10 11:56:09 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2024-01-19 17:34:14 -0500
commit92548fed600496be7de00420b8e6a415b8ce2a8a (patch)
treefd958a62ef8cbb794dae17b3e2f71da39d9c7874
parent26e27d8ffce2fe0a2fd585151e0cb31bea9c9f43 (diff)
WIP - configure autologinwip-2024-01
-rwxr-xr-xsrc/pvmboot.sh16
-rwxr-xr-xsrc/pvmbootstrap.sh20
2 files changed, 35 insertions, 1 deletions
diff --git a/src/pvmboot.sh b/src/pvmboot.sh
index 210bf77..2162bc6 100755
--- a/src/pvmboot.sh
+++ b/src/pvmboot.sh
@@ -186,11 +186,20 @@ main() # ( [cli_options] imagefile "qemu_args[]" )
(( is_postinstall_boot )) && qemu_args+=( -no-reboot )
qemu_args+=( "${cli_args[@]}" )
+ # if necessary, ensure that serial login is acceptable
+ local preserve_serial_login=0
+ if [[ "$arch" == armv7h ]]
+ then if grep -q ttyAMA0 "$workdir"/etc/securetty
+ then preserve_serial_login=1
+ else echo ttyAMA0 | sudo tee -a "$workdir"/etc/securetty > /dev/null
+ fi
+ fi
+
# unmount the virtual disks before booting, for images with a boot-loader
[[ "$arch" =~ ^(i686|riscv64|x86_64)$ ]] && pvm_cleanup
local was_error
- if (( Resume )) && [[ ! -f "$workdir"/root/hooks.sh ]]
+ if (( Resume && ! is_postinstall_boot ))
then warning "Can not resume. Perhaps the post-install hook has already run to completion."
else msg "booting the virtual machine ...."
echo "$qemu_cmd $(echo ${qemu_args[@]})"
@@ -199,6 +208,11 @@ main() # ( [cli_options] imagefile "qemu_args[]" )
msg2 "VM powered-off"
fi
+ # if necessary, restore /etc/securetty
+ if (( ! preserve_serial_login ))
+ then pvm_mount && sudo sed -i '/ttyAMA0/d' "$workdir"/etc/securetty
+ fi
+
# un-mount everything
trap - INT TERM EXIT
pvm_cleanup
diff --git a/src/pvmbootstrap.sh b/src/pvmbootstrap.sh
index 0fe2545..d5e982c 100755
--- a/src/pvmbootstrap.sh
+++ b/src/pvmbootstrap.sh
@@ -438,6 +438,26 @@ declare -i was_err=0
# configure login
echo "[$HOOK_FILENAME] configuring login"
usermod -p \$(openssl passwd $ROOT_PASS) root
+## WIP autologin - may only affect armv7h ?
+if (( IS_NONSYSTEMD ))
+then echo "(auto-login NYI for non-systemd image)" # TODO:
+elif [[ "\$ARCH" == armv7h ]]
+then
+ls /etc/systemd/system/
+
+ cfg_dir=/etc/systemd/system/serial-getty@ttyAMA0.service.d
+ mkdir $cfg_dir
+ grep -E '^ExecStart=' $services_dir/serial-getty@.service |
+ sed 's|^/sbin/getty |& --autologin root |' | tee $cfg_dir/autologin
+
+ grep autologin autologin || was_err=1
+ # echo ttyAMA0 | tee /etc/securetty
+fi
+# TODO: new ./finalize script to disable autologin and/or serial login - eg:
+# if (( IS_NONSYSTEMD ))
+# then sed -i '/ttyAMA0/d' /etc/securetty
+# else sed -i '/ttyS0/d' /etc/securetty
+# fi
# generate the locale
locale-gen