#!/bin/bash PATH=/sbin:$PATH # mount.dragfs self=`basename "$0"` if (($# < 2)) || [[ "$1" = '-h' ]] || [[ "$1" = '--help' ]]; then cat << END This program merges several dragon isotope libraries into one. Usage: $self result library1 ... END exit fi result="$1" if ! [[ -e "$1" ]]; then echo "$2" cp "$2" "$1" || exit $? shift fi shift workdir=`mktemp -t $self.XXXXXX` && rm "$workdir" && mkdir "$workdir" || exit $? clean() { [[ -e "$workdir/2" ]] && fusermount -u "$workdir/2" 2> /dev/null [[ -e "$workdir/1" ]] && fusermount -u "$workdir/1" rm -r "$workdir" } trap clean exit mkdir "$workdir/1" && mkdir "$workdir/2" && mount.dragfs "$result" "$workdir/1" || exit $? while (($# > 0)); do echo "$1" mount.dragfs "$1" "$workdir/2" || { echo "$self: unable to mount $1" >&2 exit $? } cmp "$workdir/1/energy.real" "$workdir/2/energy.real" || { echo "$self: energy grid is different in $1" >&2 exit 1 } for f in "$workdir/2"/*; do [[ "$f" =~ (energy\.real|signature|version)$ ]] && continue cp -r "$f" "$workdir/1" || exit $? done fusermount -u "$workdir/2" shift done