mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 使用 extra_xxx=yyy 而不是 extra.xxx=yyy
This commit is contained in:
parent
fe660063ce
commit
3b679732c1
@ -123,7 +123,7 @@ d-i preseed/early_command string true; \
|
|||||||
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
|
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
|
||||||
# os-prober 卡太久,因此跳过
|
# os-prober 卡太久,因此跳过
|
||||||
d-i partman/early_command string true; \
|
d-i partman/early_command string true; \
|
||||||
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
confhome="$(grep -o 'extra_confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||||
|
|
||||||
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
|
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
|
||||||
cp $postinst $postinst.orig; \
|
cp $postinst $postinst.orig; \
|
||||||
@ -161,7 +161,7 @@ d-i partman/early_command string true; \
|
|||||||
# 另一种方法处理 cloudcone
|
# 另一种方法处理 cloudcone
|
||||||
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
# if [ "$link_grub_dir" = 1 ]; then mkdir /target/boot/grub2; echo 'chainloader (hd0)+1' >/target/boot/grub2/grub.cfg; fi; \
|
||||||
d-i preseed/late_command string true; \
|
d-i preseed/late_command string true; \
|
||||||
link_grub_dir="$(grep -o 'extra\.link_grub_dir=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
link_grub_dir="$(grep -o 'extra_link_grub_dir=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
||||||
if [ "$link_grub_dir" = 1 ]; then ln -s grub /target/boot/grub2; fi; \
|
if [ "$link_grub_dir" = 1 ]; then ln -s grub /target/boot/grub2; fi; \
|
||||||
|
|
||||||
in-target systemctl enable ssh; \
|
in-target systemctl enable ssh; \
|
||||||
|
@ -10,7 +10,7 @@ get_all_disks() {
|
|||||||
get_xda() {
|
get_xda() {
|
||||||
# 如果没找到 main_disk 或 xda
|
# 如果没找到 main_disk 或 xda
|
||||||
# 返回假的值,防止意外地格式化全部盘
|
# 返回假的值,防止意外地格式化全部盘
|
||||||
main_disk="$(grep -o 'extra\.main_disk=[^ ]*' /proc/cmdline | cut -d= -f2)"
|
main_disk="$(grep -o 'extra_main_disk=[^ ]*' /proc/cmdline | cut -d= -f2)"
|
||||||
|
|
||||||
if [ -z "$main_disk" ]; then
|
if [ -z "$main_disk" ]; then
|
||||||
echo 'MAIN_DISK_NOT_FOUND'
|
echo 'MAIN_DISK_NOT_FOUND'
|
||||||
|
12
redhat.cfg
12
redhat.cfg
@ -38,10 +38,10 @@ distro=$(awk -F: '{ print $3 }' </etc/system-release-cpe)
|
|||||||
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
releasever=$(awk -F: '{ print $5 }' </etc/system-release-cpe)
|
||||||
|
|
||||||
# 重新整理 extra,grub把两侧的引号吃掉了,eval出错,要重新添加引号
|
# 重新整理 extra,grub把两侧的引号吃掉了,eval出错,要重新添加引号
|
||||||
# 提取 extra.confhome extra.mirrorlist extra.main_disk
|
# 提取 extra_confhome extra_mirrorlist extra_main_disk
|
||||||
prefix=extra
|
prefix=extra
|
||||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||||
eval "$(echo "$var" | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
eval "$(echo "$var" | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||||
done
|
done
|
||||||
|
|
||||||
# centos7 证书链未更新,需要 --no-check-certificate
|
# centos7 证书链未更新,需要 --no-check-certificate
|
||||||
@ -151,10 +151,10 @@ fi
|
|||||||
|
|
||||||
# 分步安装的系统,要将最后一个分区(installer)合并到系统分区
|
# 分步安装的系统,要将最后一个分区(installer)合并到系统分区
|
||||||
if [ -e /dev/disk/by-label/installer ]; then
|
if [ -e /dev/disk/by-label/installer ]; then
|
||||||
# 提取 extra.localtest extra.confhome extra.mirrorlist
|
# 提取 extra_localtest extra_confhome extra_mirrorlist
|
||||||
prefix=extra
|
prefix=extra
|
||||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||||
eval "$(echo "$var" | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
eval "$(echo "$var" | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||||
done
|
done
|
||||||
|
|
||||||
cd /
|
cd /
|
||||||
|
15
reinstall.sh
15
reinstall.sh
@ -2069,30 +2069,35 @@ build_finalos_cmdline() {
|
|||||||
value=${!key}
|
value=${!key}
|
||||||
key=${key#finalos_}
|
key=${key#finalos_}
|
||||||
if [ -n "$value" ] && [ $key != "mirrorlist" ]; then
|
if [ -n "$value" ] && [ $key != "mirrorlist" ]; then
|
||||||
finalos_cmdline+=" finalos.$key='$value'"
|
finalos_cmdline+=" finalos_$key='$value'"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
build_extra_cmdline() {
|
build_extra_cmdline() {
|
||||||
|
# 使用 extra_xxx=yyy 而不是 extra.xxx=yyy
|
||||||
|
# 因为 debian installer /lib/debian-installer-startup.d/S02module-params
|
||||||
|
# 会将 extra.xxx=yyy 写入新系统的 /etc/modprobe.d/local.conf
|
||||||
|
# https://answers.launchpad.net/ubuntu/+question/249456
|
||||||
|
# https://salsa.debian.org/installer-team/rootskel/-/blob/master/src/lib/debian-installer-startup.d/S02module-params?ref_type=heads
|
||||||
for key in confhome hold force cloud_image main_disk; do
|
for key in confhome hold force cloud_image main_disk; do
|
||||||
value=${!key}
|
value=${!key}
|
||||||
if [ -n "$value" ]; then
|
if [ -n "$value" ]; then
|
||||||
extra_cmdline+=" extra.$key='$value'"
|
extra_cmdline+=" extra_$key='$value'"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# 指定最终安装系统的 mirrorlist,链接有&,在grub中是特殊字符,所以要加引号
|
# 指定最终安装系统的 mirrorlist,链接有&,在grub中是特殊字符,所以要加引号
|
||||||
if [ -n "$finalos_mirrorlist" ]; then
|
if [ -n "$finalos_mirrorlist" ]; then
|
||||||
extra_cmdline+=" extra.mirrorlist='$finalos_mirrorlist'"
|
extra_cmdline+=" extra_mirrorlist='$finalos_mirrorlist'"
|
||||||
elif [ -n "$nextos_mirrorlist" ]; then
|
elif [ -n "$nextos_mirrorlist" ]; then
|
||||||
extra_cmdline+=" extra.mirrorlist='$nextos_mirrorlist'"
|
extra_cmdline+=" extra_mirrorlist='$nextos_mirrorlist'"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# cloudcone 特殊处理
|
# cloudcone 特殊处理
|
||||||
if is_grub_dir_linked; then
|
if is_grub_dir_linked; then
|
||||||
finalos_cmdline+=" extra.link_grub_dir=1"
|
finalos_cmdline+=" extra_link_grub_dir=1"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
trans.sh
12
trans.sh
@ -322,7 +322,7 @@ extract_env_from_cmdline() {
|
|||||||
value=$(echo $line | cut -d= -f2-)
|
value=$(echo $line | cut -d= -f2-)
|
||||||
eval "$key='$value'"
|
eval "$key='$value'"
|
||||||
fi
|
fi
|
||||||
done < <(xargs -n1 </proc/cmdline | grep "^$prefix" | sed "s/^$prefix\.//")
|
done < <(xargs -n1 </proc/cmdline | grep "^${prefix}_" | sed "s/^${prefix}_//")
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3556,13 +3556,13 @@ install_redhat_ubuntu() {
|
|||||||
|
|
||||||
# 重新整理 extra,因为grub会处理掉引号,要重新添加引号
|
# 重新整理 extra,因为grub会处理掉引号,要重新添加引号
|
||||||
extra_cmdline=''
|
extra_cmdline=''
|
||||||
for var in $(grep -o '\bextra\.[^ ]*' /proc/cmdline | xargs); do
|
for var in $(grep -o '\bextra_[^ ]*' /proc/cmdline | xargs); do
|
||||||
if [[ "$var" = "extra.main_disk="* ]]; then
|
if [[ "$var" = "extra_main_disk="* ]]; then
|
||||||
# 重新记录主硬盘
|
# 重新记录主硬盘
|
||||||
refind_main_disk
|
refind_main_disk
|
||||||
extra_cmdline="$extra_cmdline extra.main_disk=$main_disk"
|
extra_cmdline="$extra_cmdline extra_main_disk=$main_disk"
|
||||||
else
|
else
|
||||||
extra_cmdline="$extra_cmdline $(echo $var | sed -E "s/(extra\.[^=]*)=(.*)/\1='\2'/")"
|
extra_cmdline="$extra_cmdline $(echo $var | sed -E "s/(extra_[^=]*)=(.*)/\1='\2'/")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -3588,7 +3588,7 @@ install_redhat_ubuntu() {
|
|||||||
insmod all_video
|
insmod all_video
|
||||||
search --no-floppy --label --set=root installer
|
search --no-floppy --label --set=root installer
|
||||||
loopback loop /ubuntu.iso
|
loopback loop /ubuntu.iso
|
||||||
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline extra.kernel=$kernel --- $console_cmdline
|
linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline extra_kernel=$kernel --- $console_cmdline
|
||||||
initrd (loop)/casper/initrd
|
initrd (loop)/casper/initrd
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
12
ubuntu.yaml
12
ubuntu.yaml
@ -20,10 +20,10 @@ autoinstall:
|
|||||||
# https://askubuntu.com/questions/1302392/ubuntu-server-20-04-setup-stuck-at-block-probing-did-not-discover-any-disks
|
# https://askubuntu.com/questions/1302392/ubuntu-server-20-04-setup-stuck-at-block-probing-did-not-discover-any-disks
|
||||||
mount | grep /isodevice && { losetup -d /dev/loop0; umount -l /isodevice; } || true
|
mount | grep /isodevice && { losetup -d /dev/loop0; umount -l /isodevice; } || true
|
||||||
|
|
||||||
# 提取 extra.confhome extra.kernel
|
# 提取 extra_confhome extra_kernel
|
||||||
prefix=extra
|
prefix=extra
|
||||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||||
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
eval "$(echo $var | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||||
done
|
done
|
||||||
|
|
||||||
# 生成分区信息
|
# 生成分区信息
|
||||||
@ -49,10 +49,10 @@ autoinstall:
|
|||||||
# 还原 DNS
|
# 还原 DNS
|
||||||
# sed -i -E 's/^#(nameserver )/\1/' /etc/resolv.conf
|
# sed -i -E 's/^#(nameserver )/\1/' /etc/resolv.conf
|
||||||
|
|
||||||
# 提取 extra.confhome
|
# 提取 extra_confhome
|
||||||
prefix=extra
|
prefix=extra
|
||||||
for var in $(grep -o "\b$prefix\.[^ ]*" /proc/cmdline | xargs); do
|
for var in $(grep -o "\b${prefix}_[^ ]*" /proc/cmdline | xargs); do
|
||||||
eval "$(echo $var | sed -E "s/$prefix\.([^=]*)=(.*)/\1='\2'/")"
|
eval "$(echo $var | sed -E "s/${prefix}_([^=]*)=(.*)/\1='\2'/")"
|
||||||
done
|
done
|
||||||
|
|
||||||
# 下载合并分区脚本
|
# 下载合并分区脚本
|
||||||
|
Loading…
x
Reference in New Issue
Block a user