]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/floppy/make_rescue_disk
3ea2688d31dbb929e3ff6d1e88238b4e6b1b523b
[bacula/rescue] / rescue / linux / floppy / make_rescue_disk
1 #!/bin/sh
2 #
3 # Script to make a Bacula "rescue" disk
4 #
5 export LANG=C
6 device=/mnt/floppy
7 dev=/dev/fd0
8
9 # Print Usage message
10 usage () {
11    cat <<END_OF_DATA
12 Usage: make_rescue_disk
13   -h, --help             print this message
14   --make-static-bacula   make static File daemon and add to diskette
15   --copy-static-bacula   copy static File daemon to diskette
16   --copy-etc-files       copy files in etc list to diskette
17 END_OF_DATA
18 }
19
20 # defaults
21 make_bacula=no
22 copy_bacula=no
23 copy_etc=no
24
25 #
26 # Process command line options
27 #
28 for option in "$@" ; do
29    case "$option" in
30    -h | --help)
31       usage
32       exit 0
33       ;;
34    --make-static-bacula)
35       make_bacula=yes
36       copy_bacula=yes
37       ;;
38    --copy-static-bacula)
39       copy_bacula=yes
40       ;;
41    --copy-etc-files)
42       copy_etc=yes
43       ;;
44    *)
45       echo "Unknown option specified: $option"
46       usage
47       exit 1
48       ;;
49    esac
50 done
51
52 echo ""
53 echo "Place a blank diskette in your floppy drive."
54 echo "It will be formatted and all data will be lost."
55 echo ""
56 echo -n "Press return when ready: "
57 read a
58 umount $device 2>&1 >/dev/null
59 if [ $? = 0 ] ; then
60    mounted=1
61 else
62    mounted=0
63 fi
64 mke2fs $dev
65 mount $dev $device 2>&1 >/dev/null
66
67 if [ x$make_bacula = "xyes" ] ; then
68    ./make_static_bacula
69 fi
70
71 if [ x$copy_bacula = "xyes" -a ! -e bacula-fd ] ; then
72    echo " "
73    echo "bacula-fd not found. If you want Bacula on this"                 
74    echo "rescue disk please run \"make_static_bacula\" first."
75    echo "Continuing anyway ..."
76    echo " "
77    exit 1
78    have_bacula=no
79 else
80   echo "Stripping and compressing Bacula"
81   strip bacula-fd
82   gzip bacula-fd
83   have_bacula=yes
84 fi
85
86 echo "Copying files to $device" 
87 cp -a . $device
88
89 if [ x$copy_etc = "xyes" ] ; then
90    echo "Tarring /etc files to $device"
91    tar --create --gzip --file $device/etc.gz --files-from backup.etc.list
92 fi
93
94 if [ x$have_bacula = "xyes" ] ; then
95    rm -f bacula-fd.gz bacula-fd.conf
96 fi
97 sync
98 if [ $mounted = 0 ] ; then
99    umount $device
100 fi