]>
Commit | Line | Data |
---|---|---|
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 | ||
22 | PATH_TO_GET_DUMPDATA_TO_CDRECORD=/root/tools/get-dumpdata-to-cdrecord | |
23 | PATH_TO_XTERM=/usr/X11R6/bin/xterm | |
24 | ||
25 | FIFO_NAME=/tmp/get-dumpdata-to-cdrecord.fifo | |
26 | ||
27 | BURN_HOST=kiki | |
28 | ||
29 | DEFAULT_CD_CAPACITY=650 | |
30 | DEFAULT_FS=/ | |
31 | ||
32 | #--- End of customizing ------------------------------------------- | |
33 | ||
34 | USER_EXIT=$0 | |
35 | ||
36 | Usage(){ | |
37 | echo >&2 "Usage: `basename $0` [ -c <CD_capacity> ] [files to dump ...]" | |
38 | exit 1 | |
39 | } | |
40 | ||
41 | if [ `id -u` != 0 ]; then | |
42 | echo "$0: ERROR: root priviledges are required ..." | |
43 | exit 1 | |
44 | fi | |
45 | ||
46 | # Check whether first argument is a named pipe | |
47 | if [ -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 | |
59 | fi | |
60 | ||
61 | CD_CAPACITY=$DEFAULT_CD_CAPACITY | |
62 | FS=$DEFAULT_FS | |
63 | ||
64 | # We will reach this code only when not called internally | |
65 | while 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 | |
77 | done | |
78 | ||
79 | shift `expr $OPTIND - 1` | |
80 | ||
81 | if [ -n "$*" ]; then FS="$*"; fi | |
82 | ||
83 | DumpLevel=0 # level 0 dump | |
84 | Label=`date -I` # Take today's date as label, e.g. 2002-05-02 | |
85 | ||
86 | eval Capacity=$(($CD_CAPACITY*1024)) | |
87 | ||
88 | # Remove the fifo on the server and make a new one | |
89 | rm -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 | |
94 | sleep 2 | |
95 | ||
96 | # Run dump | |
97 | dump -z -B$Capacity -F $USER_EXIT -$DumpLevel -L $Label -f $FIFO_NAME $FS | |
98 |