]> git.sur5r.net Git - bacula/bacula/blob - regress/scripts/prepare-fake-autochanger.in
Make out of freespace non-fatal for removable devices -- i.e. behaves like tape
[bacula/bacula] / regress / scripts / prepare-fake-autochanger.in
1 #!/bin/sh
2 #
3 # Copyright (C) 2000-2017 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
5 #
6 # This script will prepare a big dummy autochanger 
7 #
8
9 . scripts/functions
10
11 adir=@working_dir@/ach
12 rm -rf $adir
13
14 mkdir $adir 2> /dev/null
15
16 # work with $1 slots by default
17 nb_slot=${1:-80}
18
19 # create the autochanger configuration file
20 cat > $adir/conf <<EOF
21 maxdrive=8
22 maxslot=$nb_slot
23 dbgfile=$adir/log
24
25 #case $2 in
26 #list|slots)
27 #   sleep 2
28 #   ;;
29 #*)
30 #   sleep 5
31 #   ;;
32 #esac
33 EOF
34
35 # turn on ach debug
36 touch $adir/log
37
38 # the standard script is looking for a real sg device
39 sed -i 's/test -c /test -f/g' $bin/storage-ctl  2> /dev/null
40 sed -i 's/test -c /test -f/g' $bin/storage2-ctl 2> /dev/null
41
42 # create generic device for bsg_persist
43 for i in `seq 0 8`; do
44     touch $adir/sg$i c
45 done
46
47 nb_vol=`expr $nb_slot - 5`
48 # create $nb_vol volumes
49 for i in `seq 1 $nb_vol`; do
50    echo $i:vol$i >> $adir/barcodes
51    cp /dev/null $adir/slot$i
52 done
53
54 # make a cleaning tape
55 cln_slot=`expr $nb_vol + 1`
56 echo $cln_slot:CLN01 >> $adir/barcodes
57 cp /dev/null $adir/slot$cnl_slot
58
59 # keep other empty
60 next_empty=`expr $cnl_slot + 1`
61 for i in `seq $next_empty $nb_slot`; do
62    echo $i:  >> $adir/barcodes
63 done