diff options
author | Iru Cai <mytbk920423@gmail.com> | 2016-07-14 00:11:25 +0800 |
---|---|---|
committer | Iru Cai <mytbk920423@gmail.com> | 2016-08-02 12:17:03 +0800 |
commit | 05df260db64c1ffa141af22aa50920d7c62940ef (patch) | |
tree | fc17314f408152e50980fc2b1fb542c09df2d1e3 /buildlive | |
parent | 7be29a553f8bc94df3a6d67c497faa2371913dce (diff) | |
download | liveusb-builder-05df260db64c1ffa141af22aa50920d7c62940ef.tar.xz |
use fatalerror() instead of errmsg(), add UUID detection
Diffstat (limited to 'buildlive')
-rwxr-xr-x | buildlive | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -14,8 +14,9 @@ msg() { echo -e "$1" >&2 } -errmsg() { +fatalerror() { msg "\x1b[1;31m$1\x1b[0m" + exit 1 } usage() { @@ -27,14 +28,12 @@ do case "$1" in --root=*) ROOTPATH=${1/--root=} - if [ -d "$ROOTPATH" ]; then - KERNELDIR="$ROOTPATH/liveusb-kernel" - DATADIR="$ROOTPATH/liveusb-data" - install -d "$KERNELDIR" "$DATADIR" - msg "Files will be copy to $ROOTPATH" - else - errmsg "Invalid root path $ROOTPATH" - fi + UUID="$(findmnt -o UUID --raw --noheadings $ROOTPATH \ + || fatalerror "UUID of $ROOTPATH not found, not a mountpoint?")" + KERNELDIR="$ROOTPATH/liveusb-kernel" + DATADIR="$ROOTPATH/liveusb-data" + install -d "$KERNELDIR" "$DATADIR" + msg "Files will be copy to $ROOTPATH" ;; --dev=*) DEVNAME=${1/--dev=} @@ -49,8 +48,7 @@ do then DISTROLIST=(${DISTROLIST[@]} "$1") else - errmsg "directory distro/$1 not found" - exit 1 + fatalerror "directory distro/$1 not found" fi ;; esac @@ -65,12 +63,10 @@ do if [[ $CKSUM == $SHA256 ]]; then msg "$ISOFILE ok." else - errmsg "$ISOFILE checksum bad!" - exit 1 + fatalerror "$ISOFILE checksum bad!" fi else - errmsg "File isofiles/$ISOFILE not found!" - exit 1 + fatalerror "File isofiles/$ISOFILE not found!" fi install_live |