libisoburn/releng/manual_devices_ts

133 lines
3.1 KiB
Plaintext
Raw Normal View History

2011-07-13 17:31:39 +00:00
#!/bin/bash
# Copyright 2011 George Danchev <danchev@spnet.net>
# Copyright 2011 Thomas Schmitt <scdbackup@gmx.net>
# Licensed under GNU GPL version 2
# set -e
# Include common bits
if test -e inc/releng_getopts.inc
then
. inc/releng_getopts.inc
else
echo >&2
echo "File not found: inc/releng_getopts.inc" >&2
echo "Are we in the ./releng directory of a libisoburn SVN checkout ?" >&2
2011-07-13 17:43:19 +00:00
echo "(Please execute the tests from that ./releng directory.)" >&2
2011-07-13 17:31:39 +00:00
echo >&2
exit 2
fi
2011-07-13 19:05:06 +00:00
# Interpret private options
dev=
next_is=
echo >&2
echo "args= ""$@" >&2
echo >&2
for i in "$@"
do
if test "$next_is" = "dev"
then
dev="$i"
next_is=""
elif test "$i" = "--outdev" -o "$i" = "--dev"
then
next_is="dev"
fi
done
2011-07-13 17:31:39 +00:00
# Insist in having a xorriso
2011-07-13 19:05:06 +00:00
if [ ! -x "$RELENG_XORRISO" ]; then
2011-07-13 17:31:39 +00:00
print_help
printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
exit 31
fi
#
get_speeds() {
2011-07-13 19:05:06 +00:00
echo -e "\n${SELF}: Running: ${RELENG_XORRISO} -report_about WARNING -outdev ${1} -toc -list_formats -list_profiles out -list_speeds"
"$RELENG_XORRISO" -report_about WARNING -outdev "$1" \
-print '---toc :' -toc \
-print '---list_formats :' -list_formats \
-print '---list_profiles :' -list_profiles out \
-print '---list_speeds :' -list_speeds
2011-07-13 17:31:39 +00:00
}
cat_var() {
# $1 = variable to put out with line feeds
cat <<+
$1
+
}
get_devices() {
2011-07-13 19:05:06 +00:00
# $1 = if not empty: device lines from xorriso -devices
# $2 = if not empty: suppress dialog and use $2 as input
2011-07-13 17:31:39 +00:00
if test -n "$1"
then
DEVICES="$1"
else
DEVICES=$("$RELENG_XORRISO" -devices 2>/dev/null | grep "\-dev")
fi
NUM_DEV=$(cat_var "$DEVICES" | wc -l)
case "${NUM_DEV}" in
0)
echo -e "\n${SELF}: No drives found."
exit 1
;;
1)
echo -e "\n${SELF}: 1 drive found:\n"
;;
*)
echo -e "\n${SELF}: ${NUM_DEV} drives found:\n"
;;
esac
echo =================================================================
echo "$DEVICES"
echo =================================================================
2011-07-13 19:05:06 +00:00
2011-07-13 17:31:39 +00:00
OUTDEV=$( cat_var "$DEVICES" | head -1 | \
sed -e "s/[0-9] *-dev '\//\//" -e "s/'.*$//" )
2011-07-13 19:05:06 +00:00
if test -n "$2"
then
x="$2"
else
echo >&2
echo "WARNING: The following tests might pull in the drive tray." >&2
echo " Best is if you now put in a suitable media and" >&2
echo " load it manually, so nobody gets surprised. :))" >&2
echo >&2
echo "Which drive to examine ? (Empty input = ${OUTDEV})" >&2
read x
fi
2011-07-13 17:31:39 +00:00
if test -n "$x"
then
OUTDEV="$x"
fi
get_speeds "$OUTDEV"
}
# main
"$RELENG_XORRISO" -version
echo -e "\n${SELF}: Running: $RELENG_XORRISO -devices..."
2011-07-13 19:05:06 +00:00
devices=$("$RELENG_XORRISO" -report_about WARNING -devices | grep "\-dev")
2011-07-13 17:31:39 +00:00
RET="$?"
case ${RET} in
0)
2011-07-13 19:05:06 +00:00
get_devices "$devices" "$dev"
2011-07-13 17:31:39 +00:00
;;
*)
boldify
echo -ne "\n${SELF}: ${RELENG_XORRISO} -devices returned ${RET}."
unboldify
echo -e "\n${SELF}: Already mounted?"
df -kh
esac
exit 0