#!/bin/bash # $HeadURL$ $LastChangedRevision$ # Modules . $(miniade) || { echo "${0##*/}: ERROR: miniade failed (hint: run 'miniade' to see error)" >&2; exit 1; } . <(rdw2-config --format=shell) || { echo "${0##*/}: INTERNAL ERROR: failed to run rdw2-config" >&2; exit 3; } # Configurable stuff # Other globals main() { local MY_ARGS local DEVS DEV # Defaults for options # Process options miniade_process_options MY_ARGS "$@" && set -- "${MY_ARGS[@]}" # Process arguments # (not implemented yet) # Sanity checks and derivations DEVS=( $(lsscsi | sed -rn 's@.*tape.*(/dev/[^ ]*) *@\1@p') ) # No tape drives is not an error and doesn't even warrant a warning! [ ${#DEVS[*]} != 0 ] || exit 0 # Guts miniade_internal "not implemented" [ -w / ] || miniade_error "you are not root; you will not be able to lock tapes in order to inspect them" # See https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s09.html#purpose42 # for information about how to lock a tape drive. for DEV in "${DEVS[@]}"; do miniade_debug 10 "main: $DEV: checking ..." miniade_lock $DEV || { miniade_warning "$DEV: probably in use; skipping ..."; continue; } tape_in_device $DEV || { miniade_warning "$DEV: no tape inserted; skipping ..."; continue; } # Note position # Rewind # Read first file with maximum read size (so don't read the *whole* of enormous file). # Restore position # Is it a label? # Report the label and the device. miniade_unlock $DEV done } main "$@"