MOUNTCMD & UNMOUNTCMD
allow the user to specify external commands to handle devices. MOUNTCMD
and UNMOUNTCMD
definitions are placed in the brutab file or defined as environment variables. MOUNTCMD=
is used to specify a command that will be called before BRU attempts to open a device for reading or writing. The UNMOUNTCMD=
should be used to specify a command that will be called after BRU has finished reading/writing.
BRU passes four arguments to the commands specified by MOUNTCMD
and UNMOUNTCMD
. These arguments are described in the table below. In most cases, the commands specified will be shell scripts. However, BRU does not care what language is used to create these executable files as long as they are set to accept and act on the arguments listed below. Bellow you will find a reprint of the mountcmd.sh
and unmountcmd.sh
scripts supplied with BRU. This script like all other scripts supplied with BRU are to be modified by the user to fit their system.
Argument M/U Description
1 Both Device Name
2 Both Volume Number
3 Both BRU Mode
4 M Media size in Kbytes
4 U Kbytes written/read
Two example shell scripts follow – please understand that these are examples and should be used simply as templates for a functional media changing mechanism – these scripts do absolutely nothing as they appear here:
BRU’s sample mountcmd.sh script:
#!/bin/sh
###############################################################
#
# mountcmd.sh sample script for MOUNTCMD
#
# If the MOUNTCMD variable is set, this command will be called
# BEFORE BRU attempts to read or write a tape
#
# Please modify this script to suit your own needs
#
#
###############################################################
CMD=$0 # name of this command
DEV=$1 # 1st parameter is device name
VOL=$2 # 2nd parameter is expected volume number
MODE=$3 # 3rd parameter is BRU mode letter
MSIZE=$4 # 4th parameter is media size in Kbytes
case “$MODE” in
c ) :
# Replace the following lines with any commands that
# should be called before BRU attempts to WRITE to a tape
#
echo “$CMD: volume $VOL on device $DEV (mode = $MODE)”
#
# Sample command to create a file containing label info
#
echo “VOLUME $VOL LABEL” > /tmp/labelfile
RTN=$? # set return code
;;
[idtgx] ) :
#
# Replace the following lines with any commands that
# should be called before BRU attempts to READ a tape
#
echo “$CMD: volume $VOL on device $DEV (mode = $MODE)”
RTN=$? # set return code
;;
esac
exit $RTN # return 0 if successful
BRU’s sample unmountcmd.sh script:
#!/bin/sh
###############################################################
#
# unmountcmd.sh sample script for UNMOUNTCMD
#
# If the UNMOUNTCMD variable is set, this command will be
# called AFTER BRU is done reading/writing a tape.
#
# The UNMOUNTCMD will not be called unless the MOUNTCMD was
# specified. It is NOT possible to call the UNMOUNTCMD only.
# In most cases, the UNMOUNTCMD is not needed, as all the tape
# handling, jukebox commands, etc. can be done by the
# MOUNTCMD.
#
# Please modify this script to suit your own needs.
#
###############################################################
CMD=$0 # name of this command
DEV=$1 # 1st parameter is device name
VOL=$2 # 2nd parameter is volume number
MODE=$3 # 3rd parameter is BRU mode letter
IOSIZE=$4 # 4th parameter is Kbytes written/read
case “$MODE” in
c ) :
#
# Replace the following lines with any commands
# that should be called after BRU is done WRITING a tape
#
echo “$CMD: volume $VOL on device $DEV (mode = $MODE)”
RTN=$? # set return code
;;
[idtgx] ) :
#
# Replace the following lines with any commands |
# that should be called after BRU is done READING a tape
#
echo “$CMD: volume $VOL on device $DEV (mode = $MODE)”
RTN=$? # set return code
;;
esac
exit $RTN # return 0 if successful