]> git.sur5r.net Git - bacula/rescue/blob - rescue/linux/usb/copy_bacula-rescue_to_key
Add new usb rescue key code
[bacula/rescue] / rescue / linux / usb / copy_bacula-rescue_to_key
1 #!/bin/sh
2 #
3
4 . ./config
5 cwd=$PWD
6
7 if [ ! `whoami` = "root" ] ; then
8   echo ""
9   echo "You need to be root to run this shell script"
10   echo ""
11   exit 1
12 fi
13 usb=`blkid |grep bs-rescue|cut -d: -f1`
14 USB_DEV=${usb%?}
15 echo "Please make sure that only one casper-rw exists on the system"
16 echo "if you have other disks labeled casper-rw, unplug them now"
17 echo ""
18 echo "and make sure your USB key is mounted"
19 echo ""
20 echo "This will install bacula-rescue on " ${USB_DEV}
21 echo ""
22 echo "Continue?? (y/n)"
23 read a
24 if [ ! "$a" = "y" ];then
25   exit 1
26 fi
27
28
29 if [  x{$USB_DEV} = x{} ];then
30   echo "You must mount your USB key before running this script"
31   exit 1
32 fi
33
34
35
36
37 dir=`df |grep ${USB_DEV}1 |awk '{print $NF}'`
38
39 umount ${USB_DEV}1 >/dev/null 2>&1
40 echo "We're about to erase the content of ${USB_DEV}1 , continue ? (y/n)"
41 read a
42 if [ ! "$a" = "y" ];then
43   exit 1
44 fi
45 echo "These are large files, so it will take some time ..."
46 echo " "
47
48 gunzip <files/rescue.gz | dd bs=1M of=${USB_DEV}1
49 if [ $? != 0 ]; then
50   echo " "
51   echo "Copy of boot setup failed. USB key creation failed!!!"
52   echo " "
53   exit 1
54 fi
55
56 dir=`df |grep ${USB_DEV}2 |awk '{print $NF}'`
57
58 if [ $dir = "/" ] ;then
59   echo "Oops we were about to scrap your system , was the USB key mounted ??, guess not...."
60   exit 1
61 fi
62
63 cd $dir
64 echo "We're about to erase the content of $dir , continue ? (y/n)"
65 read a
66   if [ ! "$a" = "y" ];then
67   exit 1
68 fi
69
70 tar -xvzf $cwd/files/rw.tar.gz 
71
72 dir=`df |grep ${USB_DEV}3 |awk '{print $NF}'`
73 if [ $dir = "/" ] ;then
74   echo "Oops we were about to scrap your system , was the USB key mounted ??, guess not...."
75   exit 1
76 fi
77 cd $cwd
78 echo "We're about to erase the content of $dir , continue ? (y/n)"
79 read a
80   if [ ! "$a" = "y" ];then
81   exit 1
82 fi
83 cp -r files/bacula-rescue $dir
84
85 #rm -r /tmp/bs-rescue
86 echo "syncing ..."
87 sync
88 sync
89 echo ""
90 echo ""
91 echo ""
92 echo ""
93 echo "Enjoy !!"