core: 安装模式添加 tty cmdline

This commit is contained in:
bin456789 2023-08-08 23:21:28 +08:00
parent 9be306830e
commit 1f12589f47
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
5 changed files with 61 additions and 9 deletions

View File

@ -1,4 +1,6 @@
# shellcheck disable=SC2148,SC2154
# https://www.debian.org/releases/stable/amd64/apbs04.zh-cn.html
# B.4.1. 本地化
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
@ -66,6 +68,11 @@ d-i preseed/early_command string \
d-i partman/early_command string \
debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
d-i partman/early_command string \
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
ttys=$(wget $confhome/ttys.sh -O- | sh -s console=); \
debconf-set debian-installer/add-kernel-opts "$ttys"
# debian 10 没有 /target/etc/ssh/sshd_config.d/ 文件夹
d-i preseed/late_command string \
echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \

View File

@ -10,7 +10,7 @@ reboot
# 分区
ignoredisk --only-use="sda|hda|xda|vda|xvda|nvme0n1"
bootloader # 甲骨文x86输出到控制台添加 --append="console=ttyS0,9600"
%include /tmp/include-bootloader
clearpart --all --initlabel
reqpart # 如果需要,自动创建 efi 或 biosboot 分区
part / --fstype=xfs --grow
@ -44,6 +44,25 @@ for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
done
# 设置 tty
include=/tmp/include-bootloader
str=
for tty in tty0 ttyS0 ttyAMA0; do
dev_tty=/dev/$tty
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
if [ -z "$str" ]; then
str="console=$tty"
else
str="$str console=$tty"
fi
fi
done
if [ -n "$str" ]; then
echo "bootloader --append=\"$str\"" >$include
else
echo "bootloader" >$include
fi
# 有 installer 分区,表示用了两步安装
include=/tmp/include-packages-for-resize
touch $include

View File

@ -861,7 +861,7 @@ build_cmdline() {
cmdline="alpine_repo=$nextos_repo modloop=$nextos_modloop $extra_cmdline $finalos_cmdline"
else
if [ $distro = debian ]; then
cmdline="lowmem=+1 lowmem/low=1 auto=true priority=critical url=$nextos_ks"
cmdline="lowmem=+1 lowmem/low=1 auto=true priority=critical url=$nextos_ks $extra_cmdline"
else
# redhat
cmdline="root=live:$nextos_squashfs inst.ks=$nextos_ks $extra_cmdline"

View File

@ -131,6 +131,22 @@ setup_lighttpd() {
rc-service lighttpd start
}
get_ttys() {
prefix=$1
str=
for tty in tty0 ttyS0 ttyAMA0; do
dev_tty=/dev/$tty
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
if [ -z "$str" ]; then
str="$prefix$tty"
else
str="$str $prefix$tty"
fi
fi
done
echo $str
}
setup_tty_and_log() {
cat <<EOF >/reinstall.html
<!DOCTYPE html>
@ -151,12 +167,8 @@ setup_tty_and_log() {
EOF
# 显示输出到前台
# script -f /dev/tty0
for t in /dev/tty0 /dev/ttyS0 /dev/ttyAMA0; do
if [ -e $t ] && echo >$t 2>/dev/null; then
ttys="$ttys $t"
fi
done
exec > >(tee -a $ttys /reinstall.html) 2>&1
dev_ttys=$(get_ttys /dev/)
exec > >(tee -a $dev_ttys /reinstall.html) 2>&1
}
extract_env_from_cmdline() {
@ -1134,6 +1146,7 @@ install_redhat_ubuntu() {
# shellcheck disable=SC2154
if [ "$distro" = "ubuntu" ]; then
download $iso /os/installer/ubuntu.iso
console_cmdline=$(get_ttys console=)
# 正常写法应该是 ds="nocloud-net;s=https://xxx/" 但是甲骨文云的ds更优先自己的ds根本无访问记录
# $seed 是 https://xxx/
@ -1144,7 +1157,7 @@ install_redhat_ubuntu() {
# rmmod tpm
search --no-floppy --label --set=root installer
loopback loop /ubuntu.iso
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline ---
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline --- $console_cmdline
initrd (loop)/casper/initrd
}
EOF

13
ttys.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/sh
prefix=$1
for tty in tty0 ttyS0 ttyAMA0; do
dev_tty=/dev/$tty
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
if [ -z "$str" ]; then
str="$prefix$tty"
else
str="$str $prefix$tty"
fi
fi
done
echo $str