--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/chg-dvd Tue Mar 18 23:31:28 2008 +0000
@@ -0,0 +1,79 @@
+#! /bin/sh
+# $Id$
+# $URL$
+# (c) 2008 Heiko Schlittermann <hs@schlittermann.de>
+#
+# I've no idea if it's complete. But at least it worked for me.
+#
+# Before using it, you have to prepare your DVD(-RAM):
+# to be a pseudo tape for amanda: It needs a file system and
+# a "data" directory.
+#
+# 1) create a file system
+# e.g. mkudffs --vid=<LABEL> --media-type=dvdram --utf8 <DEVICE>
+# 2) mount <DEVICE> <MOUNTPOINT>
+# 3) mkdir <MOUNTPOINT>/data
+# 4) umount
+#
+# ## amanda.conf:
+# changerdev=<your dvd-ram>
+# tapedev=file:<mountpoint>
+#
+# ## sudoers.conf
+# backup ALL = (root) NOPASSWD: /bin/mount, /bin/umount, /usr/bin/eject
+#
+# ## and the above mentioned commands
+#
+# for more reference see http://wiki.zmanda.com/index.php/Changers
+
+
+dev=`amgetconf changerdev`
+tapedev=`amgetconf tapedev`
+mnt=${tapedev#*:}
+
+_mount() { sudo mount "$@"; }
+_umount() { sudo umount "$@"; }
+_eject() { sudo eject "$@"; }
+
+
+slot() {
+ _umount -l $dev 2>/dev/null
+ _mount $dev $mnt
+ if test -d $mnt/data; then
+ echo "$1 file:$mnt"
+ exit 0
+ fi
+ echo "$1 slot $1 is empty (no amanda dvd)"
+ exit 1
+}
+
+info() {
+ echo "0 1 0 0 0"
+ exit 0
+}
+
+eject() {
+ _umount $mnt 2>/dev/null
+ _eject $dev
+ echo "0 file:$mnt"
+ exit 0
+}
+
+oink() {
+ echo "$1 not searchable"
+ exit 2
+}
+
+
+o="$1"; shift
+case "$o" in
+ -slot) slot "$@";;
+ -info) info "$@";;
+ -eject) eject "$@";;
+ -reset) slot "1";;
+ -search) oink "$@";;
+ -label) oink "$@";;
+ *) echo "$o $@" >/dev/tty
+ exit 2
+ ;;
+esac