From ba96bc4cc03671cba7d5517824d2d4fc4af96e85 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Wed, 13 Jul 2011 17:31:39 +0000 Subject: [PATCH] Proposal for test ./manual_devices --- libisoburn/trunk/releng/manual_devices_ts | 102 ++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100755 libisoburn/trunk/releng/manual_devices_ts diff --git a/libisoburn/trunk/releng/manual_devices_ts b/libisoburn/trunk/releng/manual_devices_ts new file mode 100755 index 00000000..7f7a9947 --- /dev/null +++ b/libisoburn/trunk/releng/manual_devices_ts @@ -0,0 +1,102 @@ +#!/bin/bash + +# Copyright 2011 George Danchev +# Copyright 2011 Thomas Schmitt +# 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 + echo >&2 + exit 2 +fi + +# Insist in having a xorriso +if [ ! -x $RELENG_XORRISO ]; then + print_help + printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n" + exit 31 +fi + +# +get_speeds() { + echo -e "\n${SELF}: Running: ${RELENG_XORRISO} -outdev ${1} -list_speeds" + ${RELENG_XORRISO} -outdev ${1} -list_speeds +} + +cat_var() { +# $1 = variable to put out with line feeds +cat <<+ +$1 ++ +} + +get_devices() { + # $1 = + + 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 ================================================================= + + OUTDEV=$( cat_var "$DEVICES" | head -1 | \ + sed -e "s/[0-9] *-dev '\//\//" -e "s/'.*$//" ) + + 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 load it" >&2 + echo " manually, so nobody gets surprised. :))" >&2 + echo >&2 + echo "Which drive to examine ? (Empty input = ${OUTDEV})" >&2 + read x + if test -n "$x" + then + OUTDEV="$x" + fi + + get_speeds "$OUTDEV" +} + +# main +"$RELENG_XORRISO" -version +echo -e "\n${SELF}: Running: $RELENG_XORRISO -devices..." +devices=$("$RELENG_XORRISO" -devices 2>/dev/null | grep "\-dev") +RET="$?" +case ${RET} in + 0) + get_devices "$devices" + ;; + *) + boldify + echo -ne "\n${SELF}: ${RELENG_XORRISO} -devices returned ${RET}." + unboldify + echo -e "\n${SELF}: Already mounted?" + df -kh +esac + +exit 0