From fef3dd17005f32fdbb8ae6dea51afe70e0fa86bd Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 8 Jul 2023 15:55:06 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E4=BF=AE=E5=A4=8D=E6=9C=AA=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E6=96=87=E4=BB=B6=E5=90=8D=E6=97=B6=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trans.sh | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/trans.sh b/trans.sh index ee9561b..2386b53 100644 --- a/trans.sh +++ b/trans.sh @@ -48,8 +48,20 @@ download() { # HTTP/1.1 403 Forbidden # axel 在 lightsail 上会占用大量cpu + # 构造 aria2 参数 + # 没有指定文件名的情况 + if [ -z $file ]; then + save="" + else + # 文件名是绝对路径 + if [[ "$file" = "/*" ]]; then + save="-d / -o $file" + else + # 文件名是相对路径 + save="-o $file" + fi + fi # 先用 aria2 下载 - [ -z $file ] && save="" || save="-d / -o $file" if ! aria2c -x4 --allow-overwrite=true $url $save; then # 出错再用 curl [ -z $file ] && save="-O" || save="-o $file" @@ -595,10 +607,8 @@ grub_cfg=/os/boot/grub/grub.cfg # 新版grub不区分linux/linuxefi # shellcheck disable=SC2154 if [ "$distro" = "ubuntu" ]; then - cd /os/installer/ - download $iso ubuntu.iso + download $iso /os/installer/ubuntu.iso - iso_file=/ubuntu.iso # 正常写法应该是 ds="nocloud-net;s=https://xxx/" 但是甲骨文云的ds更优先,自己的ds根本无访问记录 # $seed 是 https://xxx/ cat <$grub_cfg @@ -607,18 +617,16 @@ if [ "$distro" = "ubuntu" ]; then # https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1851311 # rmmod tpm search --no-floppy --label --set=root installer - loopback loop $iso_file - linux (loop)/casper/vmlinuz iso-scan/filename=$iso_file autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline --- + loopback loop /ubuntu.iso + linux (loop)/casper/vmlinuz iso-scan/filename=/ubuntu.iso autoinstall noprompt noeject cloud-config-url=$ks $extra_cmdline --- initrd (loop)/casper/initrd } EOF else - cd /os/ || exit - download $vmlinuz - download $initrd + download $vmlinuz /os/vmlinuz + download $initrd /os/initrd.img - cd /os/installer/ || exit - download $squashfs install.img + download $squashfs /os/installer/install.img cat <$grub_cfg set timeout=5