Skip to content

Commit

Permalink
allow using barcode label as tape serial (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
retokromer authored Mar 20, 2018
1 parent dfbd510 commit 810fe08
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# LTOpers Documentation

This documentation is up to date as of LTOpers version 2018-02-15.
This documentation is up to date as of LTOpers version 2018-03-17.

## LTOpers elements

Expand Down Expand Up @@ -59,7 +59,7 @@ brew upgrade

This will update Homebrew and upgrade every package you've installed using it.

By default, ltoper scripts require that tape serials are 6 character strings of numbers and capital letters. Alternate regular expressions may be provided by setting LTOPER_TAPE_SERIAL_REGEX as a global variable. For instance: `export LTOPER_TAPE_SERIAL_REGEX="^[Z1-2]{8}$" ; ./formatlto` would permit an 8 character string comprised only of capital Z, number 1, and number 2 as a tape serial.
By default, LTOpers scripts use the standard tape serials, consisting of 6 character strings of numbers and capital letters. (However, the flag `-x` allows to use the barcode label as tape serial for non-standard implementations.)

## Formatting LTO

Expand Down
19 changes: 8 additions & 11 deletions formatlto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@

SCRIPTDIR=$(dirname "${0}")
DEPENDENCIES=(mkltfs mmfunctions)
if [[ -n "${LTOPER_TAPE_SERIAL_REGEX}" ]] ; then
#allow overwriting LTO tape serial regex with a global variable
TAPE_SERIAL_REGEX="${LTOPER_TAPE_SERIAL_REGEX}"
else
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
fi
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
BLUE="$(tput setaf 4)" # Blue - For Questions
NC="$(tput sgr0)" # No Color

Expand All @@ -30,15 +25,17 @@ Dependencies: ${DEPENDENCIES[@]}
Usage: $(basename "${0}") [-f] [-c] | -h
-f force formatting
-c use compression
-x use barcode label as tape serial (caveat: this is not standard)
-h display this help
EOF
}

unset MIDDLE_OPTIONS
while getopts ":fch" opt ; do
while getopts ":fcxh" opt ; do
case "${opt}" in
f) FORCE=1 ;;
c) COMPRESS=1 ;;
x) TAPE_SERIAL_REGEX="^[A-Z0-9]{6}(L[5-8]|M8)$"
h) _usage ; exit 0 ;;
*) _report -w "Error: Bad option -${OPTARG}" ; _usage ; exit 1 ;;
esac
Expand Down Expand Up @@ -85,9 +82,9 @@ else
fi

_report -qn "Enter the tape identifier: "
read TAPE_ID
if [[ ! $(echo "${TAPE_ID}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then
_report -w "Error: The tape id must be exactly 6 capital letters and/or numbers."
read TAPE_SERIAL
if [[ ! $(echo "${TAPE_SERIAL}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then
_report -w "Error: The tape serial is not valid."
exit 1
fi
mkltfs ${MIDDLE_OPTIONS[@]} --device=${DECK} --tape-serial="${TAPE_ID}" --volume-name="${TAPE_ID}"
mkltfs ${MIDDLE_OPTIONS[@]} --device=${DECK} --tape-serial="${TAPE_SERIAL}" --volume-name="${TAPE_SERIAL}"
14 changes: 13 additions & 1 deletion ltopers.1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.TH ltopers 1 "https://github.com/amiaopensource/ltopers" "2017\-12\-11" "AMIA Open Source"
.TH ltopers 1 "https://github.com/amiaopensource/ltopers" "2018\-03\-17" "AMIA Open Source"
.SH NAME
LTOpers \- Scripts to manage LTO cartridges with LTFS
.SH SYNOPSIS
Expand All @@ -11,6 +11,9 @@ force formatting
.B \-c
use compression
.TP
.B \-x
use barcode label as tape serial (caveat: this is \fBnot\fR standard)
.TP
.B \-h
display a help message
.SS ltopers
Expand All @@ -26,6 +29,9 @@ cartridge's \fIserial
.B \-e
eject the cartridge after migration: \fIY\fR (default) or \fIN
.TP
.B \-x
use barcode label as tape serial (caveat: this is \fBnot\fR standard)
.TP
.B \-h
display a help message
.SS renameschemas \-u | \-h
Expand All @@ -45,6 +51,9 @@ cartridge's \fIserial
.B \-e
eject the cartridge after migration: \fIY\fR (default) or \fIN
.TP
.B \-x
use barcode label as tape serial (caveat: this is \fBnot\fR standard)
.TP
.B \-h
display a help message
.SS writelto \-t \fIserial\fB [\-e \fIY\fR|\fIN\fB] [\-v] | \-h
Expand All @@ -59,6 +68,9 @@ eject the cartridge after migration: \fIY\fR (default) or \fIN
.B \-v
verify the checksums of the LTO cartridge's contents
.TP
.B \-x
use barcode label as tape serial (caveat: this is \fBnot\fR standard)
.TP
.B \-h
display a help message
.SH DATABASE-RELATED COMMANDS
Expand Down
11 changes: 4 additions & 7 deletions readlto
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
SCRIPTDIR=$(dirname "${0}")
DEPENDENCIES=(gcp)
TAPE_MOUNT_POINT="/Volumes"
if [[ -n "${LTOPER_TAPE_SERIAL_REGEX}" ]] ; then
#allow overwriting LTO tape serial regex with a global variable
TAPE_SERIAL_REGEX="${LTOPER_TAPE_SERIAL_REGEX}"
else
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
fi
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
TAPE_EJECT="Y"

. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; }
Expand All @@ -30,15 +25,17 @@ Usage: $(basename "${0}") -t [-e] | -h
-t tape serial number
-e state yes (Y) or no (N) to ejecting the tape after migration, default
is yes
-x use barcode label as tape serial (caveat: this is not standard)
-h display this help
EOF
}

OPTIND=1
while getopts ":t:e:h" opt ; do
while getopts ":t:e:xh" opt ; do
case "${opt}" in
t) TAPE_SERIAL="${OPTARG}" ;;
e) TAPE_EJECT="${OPTARG}" ;;
x) TAPE_SERIAL_REGEX="^[A-Z0-9]{6}(L[5-8]|M8)$"
h) _usage ; exit 0 ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
*) echo "Bad option -${OPTARG}" ; _usage ; exit 1 ;;
Expand Down
13 changes: 5 additions & 8 deletions verifylto
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@
SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; }
TAPE_MOUNT_POINT="/Volumes"
if [[ -n "${LTOPER_TAPE_SERIAL_REGEX}" ]] ; then
#allow overwriting LTO tape serial regex with a global variable
TAPE_SERIAL_REGEX="${LTOPER_TAPE_SERIAL_REGEX}"
else
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
fi
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
_check_for_lto_index_dir
LTO_LOGS="${LTO_INDEX_DIR}"
TAPE_EJECT="Y"
Expand All @@ -34,15 +29,17 @@ Usage: $(basename "${0}") -t [-e] | -h
-t tape serial
-e state yes (Y) or no (N) to ejecting the tape after write, default
is yes
-x use barcode label as tape serial (caveat: this is not standard)
-h display this help
EOF
}

OPTIND=1
while getopts ":t:e:h" opt ; do
while getopts ":t:e:xh" opt ; do
case "${opt}" in
t) TAPE_SERIAL="${OPTARG}" ;;
e) TAPE_EJECT="${OPTARG}" ;;
x) TAPE_SERIAL_REGEX="^[A-Z0-9]{6}(L[5-8]|M8)$"
h) _usage ; exit 0 ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
*) echo "Bad option -${OPTARG}" ; _usage ; exit 1 ;;
Expand All @@ -55,7 +52,7 @@ if [[ "${PREMIS_DB}" = "Y" ]] ; then
_report_to_db
fi
if [[ ! $(echo "${TAPE_SERIAL}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then
echo "${TAPE_SERIAL} is not valid. The tape id must be exactly 6 capital letters and/or numbers."
echo "${TAPE_SERIAL} is not valid."
exit 1
fi

Expand Down
13 changes: 5 additions & 8 deletions writelto
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ SCRIPTDIR=$(dirname "${0}")
. "${SCRIPTDIR}/mmfunctions" || { echo "Missing '${SCRIPTDIR}/mmfunctions'. Exiting." ; exit 1 ; }
DEPENDENCIES=(gcp mmfunctions)
TAPE_MOUNT_POINT="/Volumes"
if [[ -n "${LTOPER_TAPE_SERIAL_REGEX}" ]] ; then
#allow overwriting LTO tape serial regex with a global variable
TAPE_SERIAL_REGEX="${LTOPER_TAPE_SERIAL_REGEX}"
else
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
fi
TAPE_SERIAL_REGEX="^[A-Z0-9]{6}$"
unset HIDDEN_FILES
TAPE_EJECT="Y"
_check_for_lto_index_dir
Expand Down Expand Up @@ -45,16 +40,18 @@ Usage: $(basename "${0}") -t [-e] [-v] | -h
-v reads back and creates checksums for the contents of a tape, and
writes checksums to a file named with the tape name and date,
located in the LTO logs directory
-x use barcode label as tape serial (caveat: this is not standard)
-h display this help
EOF
}

OPTIND=1
while getopts ":t:e:vh" opt ; do
while getopts ":t:e:vxh" opt ; do
case "${opt}" in
t) TAPE_SERIAL="${OPTARG}" ;;
e) TAPE_EJECT="${OPTARG}" ;;
v) VERIFY="Y" ;;
x) TAPE_SERIAL_REGEX="^[A-Z0-9]{6}(L[5-8]|M8)$"
h) _usage ; exit 0 ;;
:) echo "Option -${OPTARG} requires an argument" ; exit 1 ;;
*) echo "Bad option -${OPTARG}" ; _usage ; exit 1 ;;
Expand All @@ -64,7 +61,7 @@ shift "$((OPTIND-1))"

SOURCE_DIR="${1}"
if [[ ! $(echo "${TAPE_SERIAL}" | grep -E "${TAPE_SERIAL_REGEX}") ]] ; then
_report -w "Tape serial ${TAPE_SERIAL} is not valid. The tape id must be exactly 6 capital letters and/or numbers."
_report -w "Tape serial ${TAPE_SERIAL} is not valid."
_report -w "Proceeding with non-standard Tape Serial"
fi
# Check for colons in filenames of source directory.
Expand Down

0 comments on commit 810fe08

Please sign in to comment.