core: 删除 localtest

This commit is contained in:
bin456789 2023-10-08 22:10:05 +08:00
parent ce7a4812a2
commit 673808d00e
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B

View File

@ -3,7 +3,6 @@
set -eE set -eE
confhome=https://raw.githubusercontent.com/bin456789/reinstall/main confhome=https://raw.githubusercontent.com/bin456789/reinstall/main
localtest_confhome=http://192.168.253.1
this_script=$(realpath "$0") this_script=$(realpath "$0")
trap 'trap_err $LINENO $?' ERR trap 'trap_err $LINENO $?' ERR
@ -238,24 +237,16 @@ setos() {
fi fi
fi fi
if [ "$localtest" = 1 ]; then # 不要用https 因为甲骨文云arm initramfs阶段不会从硬件同步时钟导致访问https出错
mirror=$confhome/alpine-netboot-3.18.0-x86_64/boot if is_in_china; then
eval ${step}_vmlinuz=$mirror/vmlinuz-$flavour mirror=http://mirrors.tuna.tsinghua.edu.cn/alpine/v$releasever
eval ${step}_initrd=$mirror/initramfs-$flavour
eval ${step}_repo=http://mirrors.tuna.tsinghua.edu.cn/alpine/v$releasever/main
eval ${step}_modloop=$mirror/modloop-$flavour
else else
# 不要用https 因为甲骨文云arm initramfs阶段不会从硬件同步时钟导致访问https出错 mirror=http://dl-cdn.alpinelinux.org/alpine/v$releasever
if is_in_china; then
mirror=http://mirrors.tuna.tsinghua.edu.cn/alpine/v$releasever
else
mirror=http://dl-cdn.alpinelinux.org/alpine/v$releasever
fi
eval ${step}_vmlinuz=$mirror/releases/$basearch/netboot/vmlinuz-$flavour
eval ${step}_initrd=$mirror/releases/$basearch/netboot/initramfs-$flavour
eval ${step}_repo=$mirror/main
eval ${step}_modloop=$mirror/releases/$basearch/netboot/modloop-$flavour
fi fi
eval ${step}_vmlinuz=$mirror/releases/$basearch/netboot/vmlinuz-$flavour
eval ${step}_initrd=$mirror/releases/$basearch/netboot/initramfs-$flavour
eval ${step}_repo=$mirror/main
eval ${step}_modloop=$mirror/releases/$basearch/netboot/modloop-$flavour
} }
setos_debian() { setos_debian() {
@ -279,20 +270,14 @@ setos() {
eval ${step}_img=$ci_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2 eval ${step}_img=$ci_mirror/cloud/$codename/latest/debian-$releasever-$ci_type-$basearch_alt.qcow2
else else
# 传统安装 # 传统安装
if [ "$localtest" = 1 ]; then if is_in_china; then
mirror=$confhome/debian/install.amd hostname=ftp.cn.debian.org
eval ${step}_vmlinuz=$mirror/vmlinuz
eval ${step}_initrd=$mirror/initrd.gz
else else
if is_in_china; then hostname=deb.debian.org
hostname=ftp.cn.debian.org
else
hostname=deb.debian.org
fi
mirror=http://$hostname/debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
eval ${step}_vmlinuz=$mirror/linux
eval ${step}_initrd=$mirror/initrd.gz
fi fi
mirror=http://$hostname/debian/dists/$codename/main/installer-$basearch_alt/current/images/netboot/debian-installer/$basearch_alt
eval ${step}_vmlinuz=$mirror/linux
eval ${step}_initrd=$mirror/initrd.gz
eval ${step}_ks=$confhome/debian.cfg eval ${step}_ks=$confhome/debian.cfg
is_virt && flavour=-cloud is_virt && flavour=-cloud
@ -315,20 +300,16 @@ setos() {
eval ${step}_img=$ci_mirror/releases/$releasever/release/ubuntu-$releasever-server-cloudimg-$basearch_alt.img eval ${step}_img=$ci_mirror/releases/$releasever/release/ubuntu-$releasever-server-cloudimg-$basearch_alt.img
else else
# 传统安装 # 传统安装
if [ "$localtest" = 1 ]; then if is_in_china; then
mirror=$confhome/ case "$basearch" in
"x86_64") mirror=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/$releasever ;;
"aarch64") mirror=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/releases/$releasever/release ;;
esac
else else
if is_in_china; then case "$basearch" in
case "$basearch" in "x86_64") mirror=https://releases.ubuntu.com/$releasever ;;
"x86_64") mirror=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/$releasever ;; "aarch64") mirror=https://cdimage.ubuntu.com/releases/$releasever/release ;;
"aarch64") mirror=https://mirrors.tuna.tsinghua.edu.cn/ubuntu-cdimage/releases/$releasever/release ;; esac
esac
else
case "$basearch" in
"x86_64") mirror=https://releases.ubuntu.com/$releasever ;;
"aarch64") mirror=https://cdimage.ubuntu.com/releases/$releasever/release ;;
esac
fi
fi fi
# iso # iso
@ -477,39 +458,35 @@ setos() {
eval ${step}_img=${ci_image} eval ${step}_img=${ci_image}
else else
# 传统安装 # 传统安装
if [ "$localtest" = 1 ]; then case $distro in
mirror=$confhome/$releasever/ "centos")
else case $releasever in
case $distro in "7") mirrorlist="http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os" ;;
"centos") "8") mirrorlist="http://mirrorlist.centos.org/?release=8-stream&arch=$basearch&repo=BaseOS" ;;
case $releasever in "9") mirrorlist="https://mirrors.centos.org/mirrorlist?repo=centos-baseos-9-stream&arch=$basearch" ;;
"7") mirrorlist="http://mirrorlist.centos.org/?release=7&arch=$basearch&repo=os" ;;
"8") mirrorlist="http://mirrorlist.centos.org/?release=8-stream&arch=$basearch&repo=BaseOS" ;;
"9") mirrorlist="https://mirrors.centos.org/mirrorlist?repo=centos-baseos-9-stream&arch=$basearch" ;;
esac
;;
"alma") mirrorlist="https://mirrors.almalinux.org/mirrorlist/$releasever/baseos" ;;
"rocky") mirrorlist="https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever" ;;
"fedora") mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?arch=$basearch&repo=fedora-$releasever" ;;
esac esac
;;
"alma") mirrorlist="https://mirrors.almalinux.org/mirrorlist/$releasever/baseos" ;;
"rocky") mirrorlist="https://mirrors.rockylinux.org/mirrorlist?arch=$basearch&repo=BaseOS-$releasever" ;;
"fedora") mirrorlist="https://mirrors.fedoraproject.org/mirrorlist?arch=$basearch&repo=fedora-$releasever" ;;
esac
# rocky/centos9 需要删除第一行注释, alma 需要替换$basearch # rocky/centos9 需要删除第一行注释, alma 需要替换$basearch
for cur_mirror in $(curl -L $mirrorlist | sed "/^#/d" | sed "s,\$basearch,$basearch,"); do for cur_mirror in $(curl -L $mirrorlist | sed "/^#/d" | sed "s,\$basearch,$basearch,"); do
host=$(get_host_by_url $cur_mirror) host=$(get_host_by_url $cur_mirror)
if is_host_has_ipv4_and_ipv6 $host && if is_host_has_ipv4_and_ipv6 $host &&
test_url_grace ${cur_mirror}images/pxeboot/vmlinuz; then test_url_grace ${cur_mirror}images/pxeboot/vmlinuz; then
mirror=$cur_mirror mirror=$cur_mirror
break break
fi
done
if [ -z "$mirror" ]; then
error_and_exit "All mirror failed."
fi fi
done
eval "${step}_mirrorlist='${mirrorlist}'" if [ -z "$mirror" ]; then
error_and_exit "All mirror failed."
fi fi
eval "${step}_mirrorlist='${mirrorlist}'"
eval ${step}_ks=$confhome/redhat.cfg eval ${step}_ks=$confhome/redhat.cfg
eval ${step}_vmlinuz=${mirror}images/pxeboot/vmlinuz eval ${step}_vmlinuz=${mirror}images/pxeboot/vmlinuz
eval ${step}_initrd=${mirror}images/pxeboot/initrd.img eval ${step}_initrd=${mirror}images/pxeboot/initrd.img
@ -847,7 +824,7 @@ if ! is_in_windows; then
fi fi
# 整理参数 # 整理参数
if ! opts=$(getopt -n $0 -o "" --long localtest,debug,sleep:,iso:,image-name:,img:,ci,cloud-image -- "$@"); then if ! opts=$(getopt -n $0 -o "" --long debug,sleep:,iso:,image-name:,img:,ci,cloud-image -- "$@"); then
usage_and_exit usage_and_exit
fi fi
@ -855,11 +832,6 @@ eval set -- "$opts"
# shellcheck disable=SC2034 # shellcheck disable=SC2034
while true; do while true; do
case "$1" in case "$1" in
--localtest)
localtest=1
confhome=$localtest_confhome
shift
;;
--debug) --debug)
set -x set -x
shift shift
@ -993,7 +965,7 @@ build_finalos_cmdline() {
} }
build_extra_cmdline() { build_extra_cmdline() {
for key in localtest confhome sleep cloud_image kernel; do for key in confhome sleep cloud_image kernel; do
value=${!key} value=${!key}
if [ -n "$value" ]; then if [ -n "$value" ]; then
extra_cmdline+=" extra.$key='$value'" extra_cmdline+=" extra.$key='$value'"