]> git.wh0rd.org - dump.git/blame - examples/dump_on_remote_cd/dump-to-remote-cd
prepare for release 0.4b39
[dump.git] / examples / dump_on_remote_cd / dump-to-remote-cd
CommitLineData
5fb6554e
SP
1#!/bin/bash
2#ident "@(#) dump-to-remote-cd Time-stamp: <02/05/06 15:12:29 bav> "
3#******************************************************************
4# dump-to-remote-cd
5#******************************************************************
6# Gerd Bavendiek bav@epost.de 02-05-02
7#
8# Script used to dump to a remote box with a CD-Burner. There is a
9# companion script called get-dumpdata-to-cdrecord.
10#
11# Usage: dump-to-remote-cd [ -c <CD_capacity> ] [files to dump ...]
12#
13# If called without arguments, it will dump / assuming 650 MB Media on
14# host kiki (see DEFAULT_ below).
15#
16# You must be able to do an rsh as root to BURN_HOST and vice versa,
17# see get-dumpdata-to-cdrecord. You may use ssh instead.
18#------------------------------------------------------------------
19
20#--- Customize to fit your needs ----------------------------------
21
22PATH_TO_GET_DUMPDATA_TO_CDRECORD=/root/tools/get-dumpdata-to-cdrecord
23PATH_TO_XTERM=/usr/X11R6/bin/xterm
24
25FIFO_NAME=/tmp/get-dumpdata-to-cdrecord.fifo
26
27BURN_HOST=kiki
28
29DEFAULT_CD_CAPACITY=650
30DEFAULT_FS=/
31
32#--- End of customizing -------------------------------------------
33
34USER_EXIT=$0
35
36Usage(){
37echo >&2 "Usage: `basename $0` [ -c <CD_capacity> ] [files to dump ...]"
38 exit 1
39}
40
41if [ `id -u` != 0 ]; then
42 echo "$0: ERROR: root priviledges are required ..."
43 exit 1
44fi
45
46# Check whether first argument is a named pipe
47if [ -p "$1" ]; then
48 # We are called internally either from ourselves or from dump
49 FIFO_NAME=$1
50 num=$[$2+1]
51 tput bel;sleep 1; tput bel
52 echo "Insert next CD (number $num) ..."
53 read -p "CD number $num ready ? " Ans
54 DUMP_HOST=`uname -n`
55 rsh $BURN_HOST \
56 $PATH_TO_XTERM -hold -T "Dump_CD_number_$num" -cr red -fn 6x10 -e \
57 $PATH_TO_GET_DUMPDATA_TO_CDRECORD -d $DUMP_HOST -f $FIFO_NAME &
58 exit 0
59fi
60
61CD_CAPACITY=$DEFAULT_CD_CAPACITY
62FS=$DEFAULT_FS
63
64# We will reach this code only when not called internally
65while getopts "b:c:h" c; do
66 case $c in
67 c) # Media Capacity
68 CD_CAPACITY=$OPTARG
69 ;;
70 h) # help those who ask for help
71 Usage
72 ;;
73 '?') # any other switch
74 Usage
75 ;;
76 esac
77done
78
79shift `expr $OPTIND - 1`
80
81if [ -n "$*" ]; then FS="$*"; fi
82
83DumpLevel=0 # level 0 dump
84Label=`date -I` # Take today's date as label, e.g. 2002-05-02
85
86eval Capacity=$(($CD_CAPACITY*1024))
87
88# Remove the fifo on the server and make a new one
89rm -f $FIFO_NAME; mkfifo $FIFO_NAME
90
91# Call user exit for the very first time, all further calls will be
92# done via dump
93$USER_EXIT $FIFO_NAME 0
94sleep 2
95
96# Run dump
97dump -z -B$Capacity -F $USER_EXIT -$DumpLevel -L $Label -f $FIFO_NAME $FS
98