#!/bin/bash
# Pt-storage/src/compat-scripts/rdisk-batch-mount
# 
#  Copyright: ©2011, Güralp Systems Ltd.
#  Author: Laurence Withers <lwithers@guralp.com>
#  License: GPLv3
#
# This is an extremely simple compatibility wrapper for rdisk-batch-mount. It
# will strip any non-option arguments, add --bg-mount, and execute Pt-storage.
# This works because rdisk-batch-mount has only --help, --version and --socket,
# all of which map onto identical Pt-storage commands, and UUID has now become
# irrelevant.
#
# Note this script will fail if arguments have spaces in them, which should not
# be an issue since that would be nonsensical.
#

ARGS="--bg-mount"

# add arguments we were called with, stripping any non-option arguments
while [ -n "$1" ]
do
	MY_ARG="$1"
	shift

	if [ "${MY_ARG}" = "-s" -o "${MY_ARG}" = "--socket" ]
	then
		ARGS="${ARGS} ${MY_ARG} $1"
		shift
	elif [ "${MY_ARG:0:1}" = "-" ]
	then
		ARGS="${ARGS} ${MY_ARG}"
	fi
done

exec Pt-storage ${ARGS}
