equal
deleted
inserted
replaced
|
1 #! /bin/sh |
|
2 # $Id$ |
|
3 # $URL$ |
|
4 # (c) 2008 Heiko Schlittermann <hs@schlittermann.de> |
|
5 # |
|
6 # I've no idea if it's complete. But at least it worked for me. |
|
7 # |
|
8 # Before using it, you have to prepare your DVD(-RAM): |
|
9 # to be a pseudo tape for amanda: It needs a file system and |
|
10 # a "data" directory. |
|
11 # |
|
12 # 1) create a file system |
|
13 # e.g. mkudffs --vid=<LABEL> --media-type=dvdram --utf8 <DEVICE> |
|
14 # 2) mount <DEVICE> <MOUNTPOINT> |
|
15 # 3) mkdir <MOUNTPOINT>/data |
|
16 # 4) umount |
|
17 # |
|
18 # ## amanda.conf: |
|
19 # changerdev=<your dvd-ram> |
|
20 # tapedev=file:<mountpoint> |
|
21 # |
|
22 # ## sudoers.conf |
|
23 # backup ALL = (root) NOPASSWD: /bin/mount, /bin/umount, /usr/bin/eject |
|
24 # |
|
25 # ## and the above mentioned commands |
|
26 # |
|
27 # for more reference see http://wiki.zmanda.com/index.php/Changers |
|
28 |
|
29 |
|
30 dev=`amgetconf changerdev` |
|
31 tapedev=`amgetconf tapedev` |
|
32 mnt=${tapedev#*:} |
|
33 |
|
34 _mount() { sudo mount "$@"; } |
|
35 _umount() { sudo umount "$@"; } |
|
36 _eject() { sudo eject "$@"; } |
|
37 |
|
38 |
|
39 slot() { |
|
40 _umount -l $dev 2>/dev/null |
|
41 _mount $dev $mnt |
|
42 if test -d $mnt/data; then |
|
43 echo "$1 file:$mnt" |
|
44 exit 0 |
|
45 fi |
|
46 echo "$1 slot $1 is empty (no amanda dvd)" |
|
47 exit 1 |
|
48 } |
|
49 |
|
50 info() { |
|
51 echo "0 1 0 0 0" |
|
52 exit 0 |
|
53 } |
|
54 |
|
55 eject() { |
|
56 _umount $mnt 2>/dev/null |
|
57 _eject $dev |
|
58 echo "0 file:$mnt" |
|
59 exit 0 |
|
60 } |
|
61 |
|
62 oink() { |
|
63 echo "$1 not searchable" |
|
64 exit 2 |
|
65 } |
|
66 |
|
67 |
|
68 o="$1"; shift |
|
69 case "$o" in |
|
70 -slot) slot "$@";; |
|
71 -info) info "$@";; |
|
72 -eject) eject "$@";; |
|
73 -reset) slot "1";; |
|
74 -search) oink "$@";; |
|
75 -label) oink "$@";; |
|
76 *) echo "$o $@" >/dev/tty |
|
77 exit 2 |
|
78 ;; |
|
79 esac |