14 if [ ! `whoami` = "root" ] ; then
16 echo "You need to be root to run this script ..."
23 if [ -f ./nozen ]; then
27 if [ -f ./differenthostname ]; then
28 rm ./differenthostname
31 Xdialog --title " Welcome" --msgbox "Welcome to the bacula usb rescue" 10 30|| { echo "";echo "";echo "";echo "";echo "you don't seem to have an X server running, defaulting to console mode" ; echo "nozen" >> nozen ; }
37 if [ -f ./nozen ]; then
44 $DIALOG --title " Welcome" --msgbox "Welcome to the bacula usb rescue" 10 30
46 $DIALOG --radiolist "Do you want to:" 10 40 3 \
47 1 "Collect info for a client" off \
48 2 "Restore a client" off 2>ans
52 wannado=`cat ans|cut -d'"' -f2 |cut -d'"' -f1`
54 #usbdev=`mount -l |grep xubuntu9 |cut -d" " -f3`
55 root=`df |grep rootfs|awk '{print $6}'`
57 if [ x{$wannado} = x{$two} ] ; then
58 if [ ! x{$root} = "x{/}" ]; then
59 $DIALOG --msgbox "Please boot on the usb key to restore a client" 30 80
62 . ./restore/restoredebut
67 if [ x{$wannado} = x{$one} ] ; then
68 if [ x{$root} = x{$bar} ]; then
69 $DIALOG --msgbox "Please boot on your system (not on the usb key) \n to gather client info" 20 60
72 if [ -f unmounted ];then
76 mount -l |awk '{print $1}'|grep /dev/ >mounted
77 blkid |awk '{print $1}'|grep -v /dev/md |while read line;do
79 grep $line mounted >/dev/null 2>&1
82 echo $line >> unmounted
85 echo "Mounted disks are: Unmounted disks are:">mntinfo
87 unmounted=`cat unmounted|wc -l`
89 mounted=`cat mounted|wc -l`
90 if [ $mounted -gt $unmounted ];then
96 if [ $mounted -eq $unmounted ];then
101 for i in $(seq 1 $lines) ;do
102 a=`cat mounted| awk "NR==$i"`
103 b=`cat unmounted| awk "NR==$i"`
104 long1=`echo $a|wc -c`
105 long2=`echo $b|wc -c`
106 if [ $long2 -lt 11 ];then
107 if [ $long1 -lt 11 ];then
108 echo "$a $b">>mntinfo
110 echo "$a $b">>mntinfo
113 echo "$a $b">>mntinfo
116 mounted=`cat mntinfo`
123 $DIALOG --title " Warning " --yesno "Only mounted disks will get picked up, \n Please mount all the disks you want to be able \n to restore before running this script \n \n \n $mounted \n \n \n Note that raid devices will show up as unmounted \n \n Do you want to continue ?" 600 600
129 while [ $goodanswer -gt 600 ]; do
131 if [ -f ../clients/$host/diskinfo/df.bsi ] ; then
134 $DIALOG --radiolist "Please note that the informations are stored by hostname ,\n we seem to already have gattered information for that hostname. Do you want to :" 20 80 3 \
135 1 "continue , moving previous data to .bak (erasing old .bak if any) ?" off \
136 2 "choose a name for this backup (you will have to remember it for restoring) ? " off 2>ans
140 changename=`cat ans|cut -d'"' -f2 |cut -d'"' -f1`
144 $DIALOG --radiolist "Please note that the informations are stored by hostname ,\n The hostname for this machine is $host \n Do you want to :" 20 80 3 \
145 1 "Use the hostname as a reference for this client ?" off \
146 2 "choose a name for this backup (you will have to remember it for restoring) ? " off 2>ans
150 changename=`cat ans|cut -d'"' -f2 |cut -d'"' -f1`
154 if [ $changename = $one ] ;then
164 if [ $changename = $two ] ;then
169 $DIALOG --inputbox "Please enter a name under which you want to save this client" 30 80 2>ans
174 newhostname=`cat ans|cut -d'"' -f2 |cut -d'"' -f1`
176 if [ -f ./differenthostname ]; then
177 rm ./differenthostname
180 echo $newhostname >> differenthostname
184 if [ $changename -ne $two ] ; then
189 if [ -f ../clients/$newhostname/diskinfo/df.bsi ] ; then
190 if [ ${doit} -gt 0 ] ; then
200 if [ x{$wannado} = x{$two} ] ; then
202 if [ ! x{$usbdev} = x{$bar} ]; then
206 $DIALOG --msgbox "Please boot on the usb key to restore a client" 30 30