Am 04.11.2005 um 11:20 schrieb Paul Bijnens:
I'm still waiting for the "sh -vx" output of chg-disk.
The last one you sent, was a normal case, not the case of
going from the last-but-one to the last slot.

So do:

  $ cd /usr/local/amanda/etc/amanda/daily
  $ /usr/local/libexec/chg-disk -slot 7
  $ sh -vx /usr/local/libexec/chg-disk -next

sorry, forgot that .. output is attached, hope it's ok this time.

bye
stefan Herrmann
7 file:/Volumes/amanda1/daily
#! /bin/sh
#
# Amanda, The Advanced Maryland Automatic Network Disk Archiver
# Copyright (c) 1991-1999 University of Maryland at College Park
# All Rights Reserved.
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of U.M. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  U.M. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
# U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
# BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Author: Jean-Christian SIMONETTI, System and Network Engineer
#                                   Wanadoo Portails
#                                   Sophia Antipolis, France
#
#       This changer script is based on a directory structure like:
#       slot_root_dir -|
#                      |- info
#                      |- data -> slot1
#                      |- slot1
#                      |- slot2
#                      |- ...
#                      |- slotn
#       where 'slot_root_dir' is the tapedev 'file:xxx' parameter and 'n'
#       is the tapecycle parameter.
#       
#       To use this driver, just put the line 'tpchanger "chg-disk"' in your
#       amanda.conf.
#
#       Example of use:
#       --- cut here ---
#       tapedev  "file:/BACKUP2/slots/"
#       rawtapedev "file:/BACKUP2/slots/"
#       changerdev "/dev/null"
#       tpchanger "chg-disk"
#       changerfile "/usr/local/amanda/etc/changer"
#       tapetype HARD-DISK
#       define tapetype HARD-DISK {
#           length 12000 mbytes
#       }
#       --- cut here ---
#
#       The number of slot is equal to your tapecyle.
#       You must create the slots and data directory.
#


prefix=/usr/local/amanda
+ prefix=/usr/local/amanda
exec_prefix=${prefix}
+ exec_prefix=/usr/local/amanda
sbindir=${exec_prefix}/sbin
+ sbindir=/usr/local/amanda/sbin
libexecdir=${exec_prefix}/libexec
+ libexecdir=/usr/local/amanda/libexec
 
PATH=$sbindir:$libexecdir:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
+ 
PATH=/usr/local/amanda/sbin:/usr/local/amanda/libexec:/usr/bin:/bin:/usr/sbin:/sbin:/usr/ucb:/usr/local/bin
export PATH
+ export PATH

USE_VERSION_SUFFIXES="no"
+ USE_VERSION_SUFFIXES=no
if test "$USE_VERSION_SUFFIXES" = "yes"; then
    SUF="-2.4.5"
else
    SUF=
fi
+ test no = yes
+ SUF=

MYNAME=$0
+ MYNAME=/usr/local/amanda/libexec/chg-disk

TAPE=`amgetconf$SUF tapedev`
amgetconf$SUF tapedev
++ amgetconf tapedev
+ TAPE=file:/Volumes/amanda1/daily
SLOTDIR=`echo $TAPE | sed 's/^file://'`
echo $TAPE | sed 's/^file://'
++ echo file:/Volumes/amanda1/daily
++ sed 's/^file://'
+ SLOTDIR=/Volumes/amanda1/daily

CHANGERFILE=`amgetconf$SUF changerfile`
amgetconf$SUF changerfile
++ amgetconf changerfile
+ CHANGERFILE=/usr/local/amanda/etc/amanda/daily/changer
ACCESSFILE=$CHANGERFILE-access
+ ACCESSFILE=/usr/local/amanda/etc/amanda/daily/changer-access
CLEANFILE=$CHANGERFILE-clean
+ CLEANFILE=/usr/local/amanda/etc/amanda/daily/changer-clean
SLOTFILE=$CHANGERFILE-slot
+ SLOTFILE=/usr/local/amanda/etc/amanda/daily/changer-slot
[ ! -f $ACCESSFILE ] && echo 0 > $ACCESSFILE
+ '[' '!' -f /usr/local/amanda/etc/amanda/daily/changer-access ']'
[ ! -f $CLEANFILE ] && echo 0 > $CLEANFILE
+ '[' '!' -f /usr/local/amanda/etc/amanda/daily/changer-clean ']'
[ ! -f $SLOTFILE ] && echo 0 > $SLOTFILE
+ '[' '!' -f /usr/local/amanda/etc/amanda/daily/changer-slot ']'
ACCESSCOUNT=`cat $ACCESSFILE`
cat $ACCESSFILE
++ cat /usr/local/amanda/etc/amanda/daily/changer-access
+ ACCESSCOUNT=2
CLEANCOUNT=`cat $CLEANFILE`
cat $CLEANFILE
++ cat /usr/local/amanda/etc/amanda/daily/changer-clean
+ CLEANCOUNT=

FIRSTSLOT=1
+ FIRSTSLOT=1
LASTSLOT=`amgetconf$SUF tapecycle`
amgetconf$SUF tapecycle
++ amgetconf tapecycle
+ LASTSLOT=8
CURSLOT=0
+ CURSLOT=0
CLEANSLOT=$LASTSLOT
+ CLEANSLOT=8

load() {
  WHICHSLOT=$1;
  ln -s $SLOTDIR/slot$WHICHSLOT $SLOTDIR/data
  echo $WHICHSLOT > $SLOTFILE
}

unload() {
  rm -f $SLOTDIR/data
  echo "0" > $SLOTFILE
}

readstatus() {
  CURSLOT=`cat $SLOTFILE`
}

loadslot() {
  WHICHSLOT=$1

  case $WHICHSLOT in
    [0-9]*) TYPE="digit";;
    *) TYPE="string";;
  esac

  readstatus
  NEWSLOT=0
  if [ $WHICHSLOT = "current" ]; then
    if [ $CURSLOT -le 0 ]; then
      load $FIRSTSLOT
      echo "$FIRSTSLOT $TAPE"
      exit 0
    else
      echo "$CURSLOT $TAPE"
      exit 0
    fi
  elif [ $WHICHSLOT = "next" -o $WHICHSLOT = "advance" ]; then
    NEWSLOT=`expr $CURSLOT + 1`
    [ $NEWSLOT -gt $LASTSLOT ] && NEWSLOT=$FIRSTSLOT
  elif [ $WHICHSLOT = "prev" ]; then
      NEWSLOT=`expr $CURSLOT - 1`
      [ $NEWSLOT -lt $FIRSTSLOT ] && NEWSLOT=$LASTSLOT
  elif [ $WHICHSLOT = "first" ]; then
      NEWSLOT=$FIRSTSLOT
  elif [ $WHICHSLOT = "last" ]; then
      NEWSLOT=$LASTSLOT
  elif [ $TYPE = "digit" ]; then
    if [ $WHICHSLOT -ge $FIRSTSLOT -a $WHICHSLOT -le $LASTSLOT ]; then
      NEWSLOT=$WHICHSLOT
    else
      echo "0 illegal request"
      exit 1
    fi
  elif [ $WHICHSLOT = "clean" ]; then
    NEWSLOT=$CLEANSLOT
  else
    echo "0 illegal request"
    exit 1
  fi
  if [ $NEWSLOT = $CURSLOT ]; then
    echo "$CURSLOT $TAPE"
    exit 0
  fi
  if [ $NEWSLOT = $CLEANSLOT ]; then
    expr $CLEANCOUNT + 1 > $CLEANFILE
    echo 0 > $ACCESSFILE
  else
    expr $ACCESSCOUNT + 1 > $ACCESSFILE
    if [ $ACCESSCOUNT -gt $LASTSLOT ]; then
      $MYNAME -slot clean >/dev/null
    fi
  fi

  readstatus
  if [ $CURSLOT -ne 0 ]; then
    unload
  fi

  if [ $WHICHSLOT = "advance" ]; then
    echo "$NEWSLOT /dev/null"
    exit 0
  fi
  load $NEWSLOT
  echo "$NEWSLOT $TAPE"
  exit 0
}

info() {
  readstatus
  echo "$CURSLOT $LASTSLOT $FIRSTSLOT"
  exit 0
}

reset() {
  readstatus
  [ $CURSLOT -gt 0 ] && unload
  load $FIRSTSLOT
  echo "$FIRSTSLOT $tape"
  exit 0
}

eject() {
  readstatus
  if [ $CURSLOT -le 0 ]; then
    echo "0 Drive was not loaded"
    exit 1
  else
    unload
    echo $CURSLOT
    exit 0
  fi
}


while [ $# -ge 1 ];do
  case $1 in
    -slot)
           shift
           loadslot $*
           ;;
    -clean)
           shift
           loadslot clean
           ;;
    -current)
           shift
           loadslot current
           ;;
    -next)
           shift
           loadslot next
           ;;
    -advance)
           shift
           loadslot advance
           ;;
    -prev)
           shift
           loadslot prev
           ;;
    -first)
           shift
           loadslot first
           ;;
    -last)
           shift
           loadslot last
           ;;
    -info)
           shift
           info
           ;;
    -reset)
            shift
            reset
            ;;
    -eject)
            shift
            eject
            ;;
    *)
       echo "Unknown option $1"
       exit 2
       ;;
  esac
done
+ '[' 1 -ge 1 ']'
+ shift
+ loadslot next
+ WHICHSLOT=next
+ TYPE=string
+ readstatus
cat $SLOTFILE
++ cat /usr/local/amanda/etc/amanda/daily/changer-slot
+ CURSLOT=7
+ NEWSLOT=0
+ '[' next = current ']'
+ '[' next = next -o next = advance ']'
expr $CURSLOT + 1
++ expr 7 + 1
+ NEWSLOT=8
+ '[' 8 -gt 8 ']'
+ '[' 8 = 7 ']'
+ '[' 8 = 8 ']'
+ expr + 1
expr: syntax error
+ echo 0
+ readstatus
cat $SLOTFILE
++ cat /usr/local/amanda/etc/amanda/daily/changer-slot
+ CURSLOT=7
+ '[' 7 -ne 0 ']'
+ unload
+ rm -f /Volumes/amanda1/daily/data
+ echo 0
+ '[' next = advance ']'
+ load 8
+ WHICHSLOT=8
+ ln -s /Volumes/amanda1/daily/slot8 /Volumes/amanda1/daily/data
+ echo 8
+ echo '8 file:/Volumes/amanda1/daily'
8 file:/Volumes/amanda1/daily
+ exit 0

Reply via email to