From 05df260db64c1ffa141af22aa50920d7c62940ef Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Thu, 14 Jul 2016 00:11:25 +0800 Subject: use fatalerror() instead of errmsg(), add UUID detection --- buildlive | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'buildlive') diff --git a/buildlive b/buildlive index 6a1d578..94b2101 100755 --- a/buildlive +++ b/buildlive @@ -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 -- cgit v1.2.3