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