From 7f93ac9bb6481e3e0ca80d7b4cf4ca2bb2d0d5b7 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Sat, 10 Mar 2018 12:09:36 +0800 Subject: config file $HOME/.liveusb-builder, move isofiles to $ISOPATH and set default $ISOPATH location to $HOME/isofiles --- buildlive | 7 ++++++- distro/antix/32/install.sh | 2 +- distro/centos/install.sh | 2 +- distro/debian/64/install.sh | 2 +- distro/kali/install.sh | 2 +- distro/manjaro/install.sh | 2 +- distro/mint/64/install.sh | 2 +- distro/trisquel/64/mini/install.sh | 2 +- distro/ubuntu/14.04/install.sh | 2 +- distro/ubuntu/16.04/install.sh | 2 +- functions.sh | 14 +++++++------- 11 files changed, 22 insertions(+), 17 deletions(-) diff --git a/buildlive b/buildlive index 22b6a00..30fea28 100755 --- a/buildlive +++ b/buildlive @@ -35,6 +35,11 @@ options: EOF } +unset ISOPATH +CFGFILE="$HOME/.liveusb-builder" +test -f "$CFGFILE" && source "$CFGFILE" || true +ISOPATH=${ISOPATH:-"$HOME/isofiles"} + while [[ -n "$1" ]] do case "$1" in @@ -100,7 +105,7 @@ do ISOLIST=("${ISOLIST[@]}" "$ISOFILE") ISONAMELIST=("${ISONAMELIST[@]}" "$ISONAME") - if [ -f "isofiles/$ISOFILE" ] && checksum_verify; then + if [ -f "$ISOPATH/$ISOFILE" ] && checksum_verify; then true else download_iso diff --git a/distro/antix/32/install.sh b/distro/antix/32/install.sh index 9a01157..f5efb54 100644 --- a/distro/antix/32/install.sh +++ b/distro/antix/32/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/antix/32" "$DATADIR/antix" - cp "isofiles/$ISOFILE" "$DATADIR/antix/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/antix/" mount_iso cp "$ISOMNT/antiX/vmlinuz" "$ISOMNT/antiX/initrd.gz" "$KERNELDIR/antix/32/" umount_iso diff --git a/distro/centos/install.sh b/distro/centos/install.sh index a06d388..6b6d88c 100644 --- a/distro/centos/install.sh +++ b/distro/centos/install.sh @@ -1,7 +1,7 @@ install_live() { mount_iso install -d "$DATADIR/centos/" "$KERNELDIR/centos/$version" - cp "isofiles/$ISOFILE" "$DATADIR/centos/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/centos/" cp "$ISOMNT/images/pxeboot/vmlinuz" "$ISOMNT/images/pxeboot/initrd.img" "$KERNELDIR/centos/$version" umount_iso } diff --git a/distro/debian/64/install.sh b/distro/debian/64/install.sh index 651da26..6e95b31 100644 --- a/distro/debian/64/install.sh +++ b/distro/debian/64/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/debian/64" "$DATADIR/debian" - cp "isofiles/$ISOFILE" "$DATADIR/debian/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/debian/" mount_iso cp "$ISOMNT/live/vmlinuz" "$ISOMNT/live/initrd.img" "$KERNELDIR/debian/64/" umount_iso diff --git a/distro/kali/install.sh b/distro/kali/install.sh index 335ad91..6ff415c 100644 --- a/distro/kali/install.sh +++ b/distro/kali/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/kali/64" "$DATADIR/kali" - cp "isofiles/$ISOFILE" "$DATADIR/kali/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/kali/" mount_iso cp "$ISOMNT/live/vmlinuz" "$ISOMNT/live/initrd.img" "$KERNELDIR/kali/64/" umount_iso diff --git a/distro/manjaro/install.sh b/distro/manjaro/install.sh index 4641f4c..a9de58b 100644 --- a/distro/manjaro/install.sh +++ b/distro/manjaro/install.sh @@ -4,6 +4,6 @@ install_live() { cp -r "$ISOMNT/manjaro/boot/$ARCH" "$ISOMNT/manjaro/boot/intel_ucode.img" \ "$KERNELDIR/manjaro" umount_iso - cp "isofiles/$ISOFILE" "$DATADIR/manjaro/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/manjaro/" } diff --git a/distro/mint/64/install.sh b/distro/mint/64/install.sh index 4960d7b..a94793d 100644 --- a/distro/mint/64/install.sh +++ b/distro/mint/64/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/mint/64" "$DATADIR/mint" - cp "isofiles/$ISOFILE" "$DATADIR/mint/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/mint/" mount_iso cp "$ISOMNT/casper/vmlinuz" "$ISOMNT/casper/initrd.lz" "$KERNELDIR/mint/64/" umount_iso diff --git a/distro/trisquel/64/mini/install.sh b/distro/trisquel/64/mini/install.sh index e29beb5..72d4f80 100644 --- a/distro/trisquel/64/mini/install.sh +++ b/distro/trisquel/64/mini/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/trisquel/64" "$DATADIR/trisquel" - cp "isofiles/$ISOFILE" "$DATADIR/trisquel/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/trisquel/" mount_iso cp "$ISOMNT/casper/vmlinuz" "$ISOMNT/casper/initrd" "$KERNELDIR/trisquel/64/" umount_iso diff --git a/distro/ubuntu/14.04/install.sh b/distro/ubuntu/14.04/install.sh index 97addac..24ce8f9 100644 --- a/distro/ubuntu/14.04/install.sh +++ b/distro/ubuntu/14.04/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/ubuntu/14.04/64" "$DATADIR/ubuntu" - cp "isofiles/$ISOFILE" "$DATADIR/ubuntu/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/ubuntu/" mount_iso cp "$ISOMNT/casper/vmlinuz.efi" "$ISOMNT/casper/initrd.lz" "$KERNELDIR/ubuntu/14.04/64/" umount_iso diff --git a/distro/ubuntu/16.04/install.sh b/distro/ubuntu/16.04/install.sh index 653e2f5..d5a0a12 100644 --- a/distro/ubuntu/16.04/install.sh +++ b/distro/ubuntu/16.04/install.sh @@ -1,6 +1,6 @@ install_live() { install -d "$KERNELDIR/ubuntu/16.04/64" "$DATADIR/ubuntu" - cp "isofiles/$ISOFILE" "$DATADIR/ubuntu/" + cp "$ISOPATH/$ISOFILE" "$DATADIR/ubuntu/" mount_iso cp "$ISOMNT/casper/vmlinuz.efi" "$ISOMNT/casper/initrd.lz" "$KERNELDIR/ubuntu/16.04/64/" umount_iso diff --git a/functions.sh b/functions.sh index b1c804f..e57b72f 100644 --- a/functions.sh +++ b/functions.sh @@ -15,7 +15,7 @@ checksum_verify() { else fatalerror "Cannot find the SHA256, SHA1, or MD5 checksum of $ISOFILE" fi - _cksum=$("$_hashtool" "isofiles/$ISOFILE" | cut -d' ' -f1) + _cksum=$("$_hashtool" "$ISOPATH/$ISOFILE" | cut -d' ' -f1) if [[ $_cksum == $_hashsum ]]; then msg "$ISOFILE ok." else @@ -57,19 +57,19 @@ gen_grubcfg() { } download_iso() { - mkdir -p isofiles + mkdir -p "$ISOPATH" for url in ${mirrorlist[@]} do - wget -c -O "isofiles/$ISOFILE" "$url/$ISOURL" + wget -c -O "$ISOPATH/$ISOFILE" "$url/$ISOURL" if checksum_verify; then return 0 else # checksum bad, may be due to a bad partial download # so remove the file and try again - rm -f "isofiles/$ISOFILE" - wget -O "isofiles/$ISOFILE" "$url/$ISOURL" + rm -f "$ISOPATH/$ISOFILE" + wget -O "$ISOPATH/$ISOFILE" "$url/$ISOURL" checksum_verify && return 0 - rm -f "isofiles/$ISOFILE" # then try next mirror + rm -f "$ISOPATH/$ISOFILE" # then try next mirror fi done fatalerror "Fail to download $ISOFILE!" @@ -80,7 +80,7 @@ mount_iso() { then umount_iso fi - udevil mount "isofiles/$ISOFILE" "$ISOMNT" + udevil mount "$ISOPATH/$ISOFILE" "$ISOMNT" } umount_iso() { -- cgit v1.2.3