Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-16 Thread Jason Hollinden

This is my latest update to chg-zd-mtx, and most likely my last, barring
any bugs in this one.  It incorporates all bugfixes posted to me in the last
week (thank you).

Changes:

- moved 'all' user set variables to a separate config file called
  'changerfile'.conf.  By this, I mean if you have this in amanda.conf

changerfile "/etc/amanda/DailySet1/something"
  then your config file will be /etc/amanda/DailySet1/something.conf.  I
  have included mine ADIC.conf as an example of _all_ the variables that 
  are to be set in it.  Set up in amanda.conf has not changed.

- added a new internal variable:
$drivenum - returns the /dev/nst# number.  Whould work with
other device names also.

The above 2 changes gives this chg-zd-mtx the ability to work on
multiple drives at the same time, instead of having multiple copies of
it for each Amanda config.

Bugs:

I don't believe it is a bug with this script, but rather amtape.  Some
times when running 'amtape update', it will cycle through the tapelist
multiple times.  I had this happen a few times before the above changes
also, but maybe only once or twice (I don't run update that often, since
30 DLT's take for ever.)  However, if someone sees what's causing it, I
appreciate it.

--
   Jason Hollinden

   SMG Systems Admin

 chgzdmtx.tar.gz


Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-13 Thread Jason Hollinden

Ok, I've changed over to the new version that was suggested, and I have 
also incorporated the suggestions of several people who's name escape 
me (sorry).  This now has the 'mt offline' variable of the newest
chg-zd-mtx, and tests whether your drives provides an 'offline', or an
'ONLINE' when changing from offline to online.  It is also in
chg-zd-mtx.sh.in form, so it can be linked in with the configure step.

I would appreciate it if some people can test this, both with a large
barcode reader, and also some more standard 10 slot drives.  I want to
be sure that I didn't break a working script just to add my parts.

Thanks...

--
   Jason Hollinden

   SMG Systems Admin


#!/bin/sh 
#
# Exit Status:
# 0 Alles Ok
# 1 Illegal Request
# 2 Fatal Error
#
# Contributed by Eric DOUTRELEAU [EMAIL PROTECTED]
# This is supposed to work with Zubkoff/Dandelion version of mtx
#
# Modified by Joe Rhett [EMAIL PROTECTED]
# to work with MTX 1.2.9 by Eric Lee Green http://mtx.sourceforge.net
#
# Modified by Jason Hollinden [EMAIL PROTECTED] on 13-Feb-2001
# to work with MTX 1.2.10, 9 slots, and added barcode support.
# NOTE:  Only tested the 2 additions with an ADIC Scalar 100.
# All my additions have a ' Comment' close by.

##

# You may need to customize these things
MT=@MT@
MTF=@MT_FILE_FLAG@
MTX=@MTX@
firstslot=1
lastslot=7  # Don't forget to leave out the cleaning tape.
cleanslot=8 # Which slot contains your cleaning tape?

OFFLINE_BEFORE_UNLOAD=0 # Does your tape driver require a 
# 'mt offline' before mtx unload?

# Do you want to clean the drive after a certain number of accesses?
# NOTE - This is unreliable, since 'accesses' aren't 'uses', and we
#have no reliable way to count this. A single amcheck could 
#generate as many accesses as slots you have, plus 1.
# ALSO NOTE - many modern tape loaders handle this automatically.

AUTOCLEAN=0 # Set to '1' or greater to enable
autocleancount=99

havereader=0 If you have a barcode reader, set to 1.

offlinestatus=0  Set to 0 if 'mt status' gives an 
 "offline" when drive is offline.
 Set to 1 or greater if 'mt status' 
 doesn't give and offline, rather an
 "ONLINE" when drive is online.

 Check the 'readyError' section if mt acts differently for you
 as stated below.
 See the 'readstatus' section below if using a different drive than 0.

##

# No user-level customized required beyond this point.

# Paths
prefix=@prefix@
exec_prefix=@exec_prefix@
sbindir=@sbindir@
libexecdir=@libexecdir@

# try to hit all the possibilities here
PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
export PATH

email=`amgetconf$SUF mailto`
mailer=@MAILER@

if [ -d "@AMANDA_DBGDIR@" ]; then
DBGFILE=@AMANDA_DBGDIR@/changer.debug
else
DBGFILE=/dev/null
fi

USE_VERSION_SUFFIXES="@USE_VERSION_SUFFIXES@"
if test "$USE_VERSION_SUFFIXES" = "yes"; then
SUF="-@VERSION@"
else
SUF=
fi

myname=$0
tape=`amgetconf$SUF tapedev`
TAPE=`amgetconf$SUF changerdev`; export TAPE # for mtx command
if [ "$tape" = "/dev/null" -o "$TAPE" = "/dev/null" ]; then
echo "Both tapedev and changerdev must be specified in config file";
exit 2;
fi

changerfile=`amgetconf$SUF changerfile`

cleanfile=$changerfile-clean
accessfile=$changerfile-access
slotfile=$changerfile-slot
labelfile=$changerfile-barcodes
[ ! -f $cleanfile ]  echo 0  $cleanfile
[ ! -f $accessfile ]  echo 0  $accessfile
[ ! -f $slotfile ]  echo 0  $slotfile
[ ! -f $labelfile ]  echo 0  $labelfile
cleancount=`cat $cleanfile`
accesscount=`cat $accessfile`

# Routines start here

 If using a different drive than /dev/nst0 (or whatever your OS
 calls the 0'th drive) change the 'Data Transfer Element 0' (there
 are 6 below, and 1 in searchtape().) to 'Data Transfer Element #' 
 where # = /dev/nst# (or whatever for your OS).

readstatus() {
if [ $havereader -eq 1 ]; then
tmpslot=`$MTX status | grep "Data Transfer Element 0"`
usedslot=`echo $tmpslot |
sed -n 's/Data Transfer Element 0:Empty/-1/p;s/Data Transfer 
Element 0:Full (Storage Element \([1-9][0-9]*\) Loaded)\(.*\)/\1/p'`
barcode=`echo $tmpslot |
sed -n 's/Data Transfer Element 0:Empty/-1/p;s/Data Transfer 
Element 0:Full (Storage Element \(.\) Loaded):VolumeTag = \(.*\)/\2/p'`
else
usedslot=`$MTX status |

Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-13 Thread Jean-Louis Martineau

Hello Jason,

This patch is required.

Jean-Louis
-- 
Jean-Louis Martineau email: [EMAIL PROTECTED] 
Departement IRO, Universite de Montreal
C.P. 6128, Succ. CENTRE-VILLETel: (514) 343-6111 ext. 3529
Montreal, Canada, H3C 3J7Fax: (514) 343-5834


--- chg-zd-mtx.sh.in.orig   Tue Feb 13 19:44:04 2001
+++ chg-zd-mtx.sh.inTue Feb 13 19:44:37 2001
@@ -64,9 +64,6 @@
 PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
 export PATH
 
-email=`amgetconf$SUF mailto`
-mailer=@MAILER@
-
 if [ -d "@AMANDA_DBGDIR@" ]; then
DBGFILE=@AMANDA_DBGDIR@/changer.debug
 else
@@ -79,6 +76,9 @@
 else
SUF=
 fi
+
+email=`amgetconf$SUF mailto`
+mailer=@MAILER@
 
 myname=$0
 tape=`amgetconf$SUF tapedev`



Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-11 Thread Jason Hollinden

I didn't since there wasn't anything in the changelog for 2.4.2p1 that said 
it was updated, and since it errored out for me in the same fashion as the one
I used, I assumed it hadn't changed.  My bad for assuming, I guess.

I will migrate mine to the newer version this coming week.  By the way, what was the 
First of which?


On Sun, 11 Feb 2001, Joe Rhett wrote:

 Second of which, why don't you match this patch relative to the latest
 version of chg-zd-mtx, which fixes lots of the error handling. Your script
 retains 90% of the bugs of the original version.
 
 An updated version of the .sh.in file is at
   http://www.noc.isite.net/?Projects
 
 On Fri, Feb 09, 2001 at 11:38:45AM -0500, Jason Hollinden wrote:
  Note: This has only been tested on an ADIC Scalar 100.  If you find
  something broken, or not clearly commented, tell me.  Also, this is my
  1st public showing of any code, so please, be gentle... ;)
  
  The attached file is a replacement for chg-zd-mtx.  I have added support
  for barcode readers, and also for libraries between 1-999 slots (I
  would so love to hear from someone that has a honking big library like
  that say it works).  All amanda utils can work with this for barcode
  database lookups (amcheck can load the appropriate tape all by itself,
  etc.)
  
  The main thing to do it be sure to update the barcode database after any
  new tapes are added, or removed from cycle.  To do this, make a backup
  of the old barcodes file, then run 'amtape conf update'.  This will
  cycle through all your tape slots, and put them in your barcodes file
  like this:
  
  tape amlabel barcode
  
  Be sure to modify the top part of the script to fit your needs, and also 
  check out the comments on what 'mt status' should return for your tape
  device.
  
  
  Some changes to come:
  
  - make it completely independent of what slot the tapes are in, since
certain loaders may unload to the wrong slot depending on circumstances.
  
  - Better error handling, which right now is crappy to say the least.
  
  - Anything brought ot my attention by you peoples
  
  Enjoy...
  
  --
 Jason Hollinden
  
 SMG Systems Admin
 
  #!/bin/sh
  #
  # Exit Status:
  # 0 Alles Ok
  # 1 Illegal Request
  # 2 Fatal Error
  #
  # Contributed by Eric DOUTRELEAU [EMAIL PROTECTED]
  # This is supposed to work with Zubkoff/Dandelion version of mtx
  #
  # Modified by Joe Rhett [EMAIL PROTECTED]
  # to work with MTX 1.2.9 by Eric Lee Green http://mtx.sourceforge.net
  #
  # Modified by Jason Hollinden [EMAIL PROTECTED] on 6-Feb-2001
  # to work with MTX 1.2.10, up to 999 slots, and added barcode support.
  # NOTE:  Only tested the 2 additions with an ADIC Scalar 100.
  # All my additions have a ' Comment' close by.
  
  # You may need to customize these things
  MT=/bin/mt
  MTF=-f
  MTX=/sbin/mtx
  DD=/bin/dd
  firstslot=2
  lastslot=9
   Clean function just loads the tape, and may not necessarily eject it.
   If not, just issue an eject afterwards.
  cleanslot=31
  accessbeforeclean=119
  
   If you have a barcode reader, set to 1.  Otherwise set to 0.
  havereader=1
  
   Email of who should get severe library errors, and mailer to use.
   All other errors are in the $DBGFILE.
  [EMAIL PROTECTED]
  mailer=/bin/mail
  
   Check the 'readyError' section if mt acts differently for you 
   as stated below.
   See the 'readstatus' section below if using a different drive than 0.
  
  ## No (hopefully) user-level customized required beyond this point.
  
  
  # try to hit all the possibilities here
  prefix=/opt/amanda
  exec_prefix=${prefix}
  sbindir=${exec_prefix}/sbin
  libexecdir=${exec_prefix}/libexec
   
  PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
  export PATH
   
  if [ -d "/tmp/amanda" ]; then
  DBGFILE=/tmp/amanda/changer.debug
  else
  DBGFILE=/dev/null
  fi
   
  USE_VERSION_SUFFIXES="no"
  if test "$USE_VERSION_SUFFIXES" = "yes"; then
  SUF="-2.4.2b2"
  else
  SUF=
  fi
  
  myname=$0
  tape=`amgetconf$SUF tapedev`
  TAPE=`amgetconf$SUF changerdev`; export TAPE # for mtx command
  if [ "$tape" = "/dev/null" -o "$TAPE" = "/dev/null" ]; then
  echo "Both tapedev and changerdev must be specified in config file";
  exit 2;
  fi
  
  changerfile=`amgetconf$SUF changerfile`
  
  cleanfile=$changerfile-clean
  accessfile=$changerfile-access
  slotfile=$changerfile-slot
  labelfile=$changerfile-barcodes
  [ ! -f $cleanfile ]  echo 0  $cleanfile
  [ ! -f $accessfile ]  echo 0  $accessfile
  [ ! -f $slotfile ]  echo 0  $slotfile
  [ ! -f $labelfile ]  echo 0  $labelfile
  cleancount=`cat $cleanfile`
  accesscount=`cat $accessfile`
  
  # Routines start here
   If using a different drive than /dev/nst0 (or whatever your OS 
   calls the 0'th drive) change the 'Data Transfer Element 0' (there 
   are 5 below) to 'Data Transfer Element #' where # = 

Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-11 Thread Joe Rhett

 I didn't since there wasn't anything in the changelog for 2.4.2p1 that said 
 it was updated, and since it errored out for me in the same fashion as the one
 I used, I assumed it hadn't changed.  My bad for assuming, I guess.
 
No, easy to miss since I didn't get it done in time for p1. Everyone loves
to post hacks, and few people are testing code submitted, so patches aren't
integrated into the release until multiple people can confirm they work.

...which is why I'm hoping you'll use this.

 I will migrate mine to the newer version this coming week.  By the way, what was the 
First of which?
 
huh? First of what?

 On Sun, 11 Feb 2001, Joe Rhett wrote:
 
  Second of which, why don't you match this patch relative to the latest
  version of chg-zd-mtx, which fixes lots of the error handling. Your script
  retains 90% of the bugs of the original version.
  
  An updated version of the .sh.in file is at
  http://www.noc.isite.net/?Projects
  
  On Fri, Feb 09, 2001 at 11:38:45AM -0500, Jason Hollinden wrote:
   Note: This has only been tested on an ADIC Scalar 100.  If you find
   something broken, or not clearly commented, tell me.  Also, this is my
   1st public showing of any code, so please, be gentle... ;)
   
   The attached file is a replacement for chg-zd-mtx.  I have added support
   for barcode readers, and also for libraries between 1-999 slots (I
   would so love to hear from someone that has a honking big library like
   that say it works).  All amanda utils can work with this for barcode
   database lookups (amcheck can load the appropriate tape all by itself,
   etc.)
   
   The main thing to do it be sure to update the barcode database after any
   new tapes are added, or removed from cycle.  To do this, make a backup
   of the old barcodes file, then run 'amtape conf update'.  This will
   cycle through all your tape slots, and put them in your barcodes file
   like this:
   
   tape amlabel barcode
   
   Be sure to modify the top part of the script to fit your needs, and also 
   check out the comments on what 'mt status' should return for your tape
   device.
   
   
   Some changes to come:
   
   - make it completely independent of what slot the tapes are in, since
 certain loaders may unload to the wrong slot depending on circumstances.
   
   - Better error handling, which right now is crappy to say the least.
   
   - Anything brought ot my attention by you peoples
   
   Enjoy...
   
   --
  Jason Hollinden
   
  SMG Systems Admin
  
   #!/bin/sh
   #
   # Exit Status:
   # 0 Alles Ok
   # 1 Illegal Request
   # 2 Fatal Error
   #
   # Contributed by Eric DOUTRELEAU [EMAIL PROTECTED]
   # This is supposed to work with Zubkoff/Dandelion version of mtx
   #
   # Modified by Joe Rhett [EMAIL PROTECTED]
   # to work with MTX 1.2.9 by Eric Lee Green http://mtx.sourceforge.net
   #
   # Modified by Jason Hollinden [EMAIL PROTECTED] on 6-Feb-2001
   # to work with MTX 1.2.10, up to 999 slots, and added barcode support.
   # NOTE:  Only tested the 2 additions with an ADIC Scalar 100.
   # All my additions have a ' Comment' close by.
   
   # You may need to customize these things
   MT=/bin/mt
   MTF=-f
   MTX=/sbin/mtx
   DD=/bin/dd
   firstslot=2
   lastslot=9
    Clean function just loads the tape, and may not necessarily eject it.
    If not, just issue an eject afterwards.
   cleanslot=31
   accessbeforeclean=119
   
    If you have a barcode reader, set to 1.  Otherwise set to 0.
   havereader=1
   
    Email of who should get severe library errors, and mailer to use.
    All other errors are in the $DBGFILE.
   [EMAIL PROTECTED]
   mailer=/bin/mail
   
    Check the 'readyError' section if mt acts differently for you 
    as stated below.
    See the 'readstatus' section below if using a different drive than 0.
   
   ## No (hopefully) user-level customized required beyond this point.
   
   
   # try to hit all the possibilities here
   prefix=/opt/amanda
   exec_prefix=${prefix}
   sbindir=${exec_prefix}/sbin
   libexecdir=${exec_prefix}/libexec

   PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
   export PATH

   if [ -d "/tmp/amanda" ]; then
   DBGFILE=/tmp/amanda/changer.debug
   else
   DBGFILE=/dev/null
   fi

   USE_VERSION_SUFFIXES="no"
   if test "$USE_VERSION_SUFFIXES" = "yes"; then
   SUF="-2.4.2b2"
   else
   SUF=
   fi
   
   myname=$0
   tape=`amgetconf$SUF tapedev`
   TAPE=`amgetconf$SUF changerdev`; export TAPE # for mtx command
   if [ "$tape" = "/dev/null" -o "$TAPE" = "/dev/null" ]; then
   echo "Both tapedev and changerdev must be specified in config file";
   exit 2;
   fi
   
   changerfile=`amgetconf$SUF changerfile`
   
   cleanfile=$changerfile-clean
   accessfile=$changerfile-access
   slotfile=$changerfile-slot
   labelfile=$changerfile-barcodes
   [ ! -f $cleanfile ]  echo 0  $cleanfile

Re: Submitting a chg-zd-mtx, with barcode support, and 9 slot support

2001-02-10 Thread Jean-Louis Martineau

Hello Jason,

On Fri, Feb 09, 2001 at 11:38:45AM -0500, Jason Hollinden wrote:
 
 The attached file is a replacement for chg-zd-mtx.

chg-zd-mtx is a generated file, could you provide a patch
for chg-zd-mtx.sh.in

 #!/bin/sh
 
  Email of who should get severe library errors, and mailer to use.
  All other errors are in the $DBGFILE.
 [EMAIL PROTECTED]
  email=`amgetconf$SUF mailto`
  #move it after the initialization of SUF
 mailer=/bin/mail
  mailer=@MAILER@
  #That can only be done in chg-zd-mtx.sh.in

Jean-Louis
-- 
Jean-Louis Martineau email: [EMAIL PROTECTED] 
Departement IRO, Universite de Montreal
C.P. 6128, Succ. CENTRE-VILLETel: (514) 343-6111 ext. 3529
Montreal, Canada, H3C 3J7Fax: (514) 343-5834