mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +08:00
core: 修复未指定文件名时下载路径出错
This commit is contained in:
parent
8069507336
commit
fef3dd1700
30
trans.sh
30
trans.sh
@ -48,8 +48,20 @@ download() {
|
|||||||
# HTTP/1.1 403 Forbidden
|
# HTTP/1.1 403 Forbidden
|
||||||
|
|
||||||
# axel 在 lightsail 上会占用大量cpu
|
# axel 在 lightsail 上会占用大量cpu
|
||||||
|
# 构造 aria2 参数
|
||||||
|
# 没有指定文件名的情况
|
||||||
|
if [ -z $file ]; then
|
||||||
|
save=""
|
||||||
|
else
|
||||||
|
# 文件名是绝对路径
|
||||||
|
if [[ "$file" = "/*" ]]; then
|
||||||
|
save="-d / -o $file"
|
||||||
|
else
|
||||||
|
# 文件名是相对路径
|
||||||
|
save="-o $file"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
# 先用 aria2 下载
|
# 先用 aria2 下载
|
||||||
[ -z $file ] && save="" || save="-d / -o $file"
|
|
||||||
if ! aria2c -x4 --allow-overwrite=true $url $save; then
|
if ! aria2c -x4 --allow-overwrite=true $url $save; then
|
||||||
# 出错再用 curl
|
# 出错再用 curl
|
||||||
[ -z $file ] && save="-O" || save="-o $file"
|
[ -z $file ] && save="-O" || save="-o $file"
|
||||||
@ -595,10 +607,8 @@ grub_cfg=/os/boot/grub/grub.cfg
|
|||||||
# 新版grub不区分linux/linuxefi
|
# 新版grub不区分linux/linuxefi
|
||||||
# shellcheck disable=SC2154
|
# shellcheck disable=SC2154
|
||||||
if [ "$distro" = "ubuntu" ]; then
|
if [ "$distro" = "ubuntu" ]; then
|
||||||
cd /os/installer/
|
download $iso /os/installer/ubuntu.iso
|
||||||
download $iso ubuntu.iso
|
|
||||||
|
|
||||||
iso_file=/ubuntu.iso
|
|
||||||
# 正常写法应该是 ds="nocloud-net;s=https://xxx/" 但是甲骨文云的ds更优先,自己的ds根本无访问记录
|
# 正常写法应该是 ds="nocloud-net;s=https://xxx/" 但是甲骨文云的ds更优先,自己的ds根本无访问记录
|
||||||
# $seed 是 https://xxx/
|
# $seed 是 https://xxx/
|
||||||
cat <<EOF >$grub_cfg
|
cat <<EOF >$grub_cfg
|
||||||
@ -607,18 +617,16 @@ if [ "$distro" = "ubuntu" ]; then
|
|||||||
# https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311
|
# https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311
|
||||||
# rmmod tpm
|
# rmmod tpm
|
||||||
search --no-floppy --label --set=root installer
|
search --no-floppy --label --set=root installer
|
||||||
loopback loop $iso_file
|
loopback loop /ubuntu.iso
|
||||||
linux (loop)/casper/vmlinuz iso-scan/filename=$iso_file 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 ---
|
||||||
initrd (loop)/casper/initrd
|
initrd (loop)/casper/initrd
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
cd /os/ || exit
|
download $vmlinuz /os/vmlinuz
|
||||||
download $vmlinuz
|
download $initrd /os/initrd.img
|
||||||
download $initrd
|
|
||||||
|
|
||||||
cd /os/installer/ || exit
|
download $squashfs /os/installer/install.img
|
||||||
download $squashfs install.img
|
|
||||||
|
|
||||||
cat <<EOF >$grub_cfg
|
cat <<EOF >$grub_cfg
|
||||||
set timeout=5
|
set timeout=5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user