#!/bin/bash set -e DISTROLIST=() ROOTPATH= DEVNAME= KERNELDIR= DATADIR= . functions.sh msg() { echo -e "$1" >&2 } fatalerror() { msg "\x1b[1;31m$1\x1b[0m" exit 1 } usage() { msg "$0 --root= --dev= [distro 1] [distro 2] ..." } while [[ -n "$1" ]] do case "$1" in --root=*) ROOTPATH=${1/--root=} UUID="$(findmnt -o UUID --raw --noheadings $ROOTPATH \ || fatalerror "UUID of $ROOTPATH not found, not a mountpoint?")" KERNELDIR="$ROOTPATH/liveusb-kernel" DATADIR="$ROOTPATH/liveusb-data" GRUBCFG="$ROOTPATH/grub/grub.cfg" install -d "$KERNELDIR" "$DATADIR" msg "Files will be copy to $ROOTPATH" ;; --dev=*) DEVNAME=${1/--dev=} msg "Boot sector will be written to $DEVNAME" ;; *=*) usage exit 1 ;; *) if [ -d "distro/$1" ] then DISTROLIST=(${DISTROLIST[@]} "$1") else fatalerror "directory distro/$1 not found" fi ;; esac shift done install -d "$ROOTPATH/grub" echo "uuid=$UUID" > "$GRUBCFG" for i in ${DISTROLIST[@]} do process_distro "$i" if [ -f "isofiles/$ISOFILE" ]; then checksum_verify else fatalerror "File isofiles/$ISOFILE not found!" fi install_live cat "distro/$i/grub.cfg" >> "$GRUBCFG" done