In message <[EMAIL PROTECTED]> you wrote:
> Just a quick question here on the 1.38.3 mtx-changer script:
> 
> In the older 1.36.3 version there was a line about line 99 or so that
> you has to comment out and replace as follows to "fake" bar code
> support. Ex:
...
> What is the equivalent set of changes for the 1.38.3 mtx-chaner
> script? The on web docs still are for 1.36.3.

The code hasn't changed much. If your  ead  the  docs  carefully  the
changes should be obvious.

Please find attached a patch (against 1.38.3-22Dec05)  which  does  a
bit  more:  I  wanted  to  be able to have a direct mapping between a
"magazine name" and volume names. For  example,  when  I  insert  the
magazine labeled "X" I run the command

        /etc/bacula/set_maginfo X

and in bacula I can just do a "update  slots".  The  mapping  between
magazine  name,  slot  number  and volume name is done using a simple
text file "/etc/bacula/Magazines.conf". [There is also a small script
"get_maginfo" to display the name of the current magazine.]


========== /etc/bacula/mtx-changer ==========
--- mtx-changer.ORIG    2005-12-26 22:38:05.000000000 +0100
+++ mtx-changer 2005-12-27 21:18:04.000000000 +0100
@@ -71,6 +71,32 @@
   done
 }
 
+#
+# Map magazine ID and slot number into a more comprehensive volume name
+#
+map_slots() {
+  while read line ; do
+    if [ \! \( -r /etc/bacula/Magazines.conf -a -r /var/bacula/maginfo \) ] ; 
then
+      echo "$line"
+      return 
+    fi
+    # Return any volume information unchanged if present
+    if [ "${line##*:}" ] ; then
+      echo "$line"
+      return
+    fi
+    mag=`cat /var/bacula/maginfo`
+    slot=`echo "${line%%:*}"`
+    vol=
+    while read mg sl id ; do
+      if [ \( "$mg" = "$mag" \) -a \( "$sl" = "$slot" \) ] ; then
+        vol="$id"
+        break
+      fi
+    done </etc/bacula/Magazines.conf
+    echo "$slot:$vol"
+  done
+}
 
 if test $# -lt 2 ; then
   echo "usage: mtx-changer ctl-device command slot archive-device drive"
@@ -131,8 +157,12 @@
       make_temp_file
       ${MTX} -f $ctl status >${TMPFILE}
       rtn=$?
-      cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | awk "{print 
\$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
-      cat ${TMPFILE} | grep "^Data Transfer Element [0-9]*:Full (Storage 
Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}'
+      { grep ' *Storage Element [0-9]*:.*Full' < ${TMPFILE} | \
+               awk '{print $3 $4}' | \
+               sed 's/Full *\(:VolumeTag=\)*//'
+        grep '^Data Transfer Element [0-9]*:Full (Storage Element [0-9]' < 
${TMPFILE} | \
+               awk '{printf "%s:%s\n",$7,$10}'
+      } | map_slots
       rm -f ${TMPFILE} 2>&1 >/dev/null
 #
 # If you have a VXA PacketLoader and the above does not work, try

========== /etc/bacula/Magazines.conf ==========
--- Magazines.conf.ORIG 2005-12-27 16:05:17.000000000 +0100
+++ Magazines.conf      2005-12-27 16:04:55.000000000 +0100
@@ -0,0 +1,40 @@
+Mag.   Slot    Volume
+----   ----    ------
+A      1       I-A-1
+A      2       I-A-2
+A      3       I-A-3
+A      4       I-A-4
+A      5       I-A-5
+A      6       CLN-I-A
+Mag.   Slot    Volume
+----   ----    ------
+B      1       I-B-1
+B      2       I-B-2
+B      3       I-B-3
+B      4       I-B-4
+B      5       I-B-5
+B      6       CLN-I-B
+Mag.   Slot    Volume
+----   ----    ------
+C      1       I-C-1
+C      2       I-C-2
+C      3       I-C-3
+C      4       I-C-4
+C      5       I-C-5
+C      6       CLN-I-C
+Mag.   Slot    Volume
+----   ----    ------
+D      1       I-D-1
+D      2       I-D-2
+D      3       I-D-3
+D      4       I-D-4
+D      5       I-D-5
+D      6       CLN-I-D
+Mag.   Slot    Volume
+----   ----    ------
+E      1       I-E-1
+E      2       I-E-2
+E      3       I-E-3
+E      4       I-E-4
+E      5       I-E-5
+E      6       CLN-I-E

========== /etc/bacula/set_maginfo ==========
--- set_maginfo.ORIG    2005-12-29 14:01:29.000000000 +0100
+++ set_maginfo 2005-12-27 22:02:35.000000000 +0100
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "$1" >/var/bacula/maginfo

========== /etc/bacula/get_maginfo ==========
--- get_maginfo.ORIG    2005-12-29 14:01:29.000000000 +0100
+++ get_maginfo 2005-12-27 22:03:10.000000000 +0100
@@ -0,0 +1,2 @@
+#!/bin/sh
+echo "Loaded Magazine: \"`cat /var/bacula/maginfo`\""



While we are at it: on another box where  we  have  a  drive  with  a
barcode  reader I got sick of the cryptic barcode ID's. The following
patch can be used to use text file "/etc/bacula/Barcodes.conf" to map
a barcode ID of "AIH917" into the corresponding volume name "K-C-4".

========== /etc/bacula/mtx-changer ==========
--- mtx-changer.ORIG    2005-12-27 00:30:33.000000000 +0100
+++ mtx-changer 2005-12-27 21:07:13.000000000 +0100
@@ -71,6 +71,26 @@
   done
 }
 
+#
+# Map barcode label into a more comprehensive volume name
+#
+# Input: "2:" or "4:ABC123" ==> Output: "2:" resp. "4:K-H-4"
+#
+# Slot: ${line%%:*}, Barcode: ${line##*:}
+#
+map_barcode() {
+  while read line ; do
+    if [ \! -r /etc/bacula/Barcodes.conf ] ; then
+      echo "$line"
+      return 
+    fi
+    if [ -z "${line##*:}" ] ; then
+      echo "$line"
+      return
+    fi
+    echo "${line%%:*}:`grep "^${line##*:}" /etc/bacula/Barcodes.conf | sed -e 
"s/${line##*:}[   ][      ]*//"`"
+  done
+}
 
 if test $# -lt 2 ; then
   echo "usage: mtx-changer ctl-device command slot archive-device drive"
@@ -131,8 +151,12 @@
       make_temp_file
       ${MTX} -f $ctl status >${TMPFILE}
       rtn=$?
-      cat ${TMPFILE} | grep " *Storage Element [0-9]*:.*Full" | awk "{print 
\$3 \$4}" | sed "s/Full *\(:VolumeTag=\)*//"
-      cat ${TMPFILE} | grep "^Data Transfer Element [0-9]*:Full (Storage 
Element [0-9]" | awk '{printf "%s:%s\n",$7,$10}'
+      { grep ' *Storage Element [0-9]*:.*Full' <${TMPFILE} | \
+               awk '{print $3 $4}' | \
+               sed 's/Full *\(:VolumeTag=\)*//'
+        grep '^Data Transfer Element [0-9]*:Full (Storage Element [0-9]' 
<${TMPFILE} | \
+               awk '{printf "%s:%s\n",$7,$10}'
+      } | map_barcode
       rm -f ${TMPFILE} 2>&1 >/dev/null
 #
 # If you have a VXA PacketLoader and the above does not work, try

========== /etc/bacula/Barcodes.conf ==========
--- Barcodes.conf.ORIG  2005-12-27 16:05:08.000000000 +0100
+++ Barcodes.conf       2005-12-29 10:36:03.000000000 +0100
@@ -0,0 +1,66 @@
+Barcode        VolumeID
+=======        ========
+AIH900 K-A-1
+AIH901 K-A-2
+AIH902 K-A-3
+AIH903 K-A-4
+AIH904 K-A-5
+AIH905 K-A-6
+AIH906 K-A-7
+CLN500 K-A-CLN
+------ -----
+AIH907 K-B-1
+AIH908 K-B-2
+AIH909 K-B-3
+AIH910 K-B-4
+AIH911 K-B-5
+AIH912 K-B-6
+AIH913 K-B-7
+CLN501 K-B-CLN
+------ -----
+AIH914 K-C-1
+AIH915 K-C-2
+AIH916 K-C-3
+AIH917 K-C-4
+AIH918 K-C-5
+AIH919 K-C-6
+AIH920 K-C-7
+CLN502 K-C-CLN
+------ -----
+AIH921 K-D-1
+AIH922 K-D-2
+AIH923 K-D-3
+AIH924 K-D-4
+AIH925 K-D-5
+AIH926 K-D-6
+AIH927 K-D-7
+CLN503 K-D-CLN
+------ -----
+AIH928 K-E-1
+AIH929 K-E-2
+AIH930 K-E-3
+AIH931 K-E-4
+AIH932 K-E-5
+AIH933 K-E-6
+AIH934 K-E-7
+CLN504 K-E-CLN
+------ -----
+AIH935 K-F-1
+AIH936 K-F-2
+AIH937 K-F-3
+AIH938 K-F-4
+AIH939 K-F-5
+AIH940 K-F-6
+AIH941 K-F-7
+CLN505 K-F-CLN
+------ -----
+AIH942 K-G-1
+AIH943 K-G-2
+AIH944 K-G-3
+AIH945 K-G-4
+AIH946 K-G-5
+AIH947 K-G-6
+AIH948 K-G-7
+CLN506 K-G-CLN
+------ -----
+AIH949 K-H-1

[Note: both patches are mutually exclusive.]


Hope this helps.

Best regards,

Wolfgang Denk

-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [EMAIL PROTECTED]
"Those who will be able to conquer software will be able  to  conquer
the world."                 - Tadahiro Sekimoto, president, NEC Corp.


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to