LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 967|回复: 5

gh*st for linux(g4l)源代码

[复制链接]
发表于 2005-7-14 22:50:52 | 显示全部楼层 |阅读模式
Gh*st For Linux
这个*应该是o.
用dialog整的.
我看了一下.马上传上来了.
我觉得他的主要方面就是支持网络ghost比较爽,当然没有测试过
有条件的朋友可以帮忙测试一下
版主给我加精啦

  1. #!/bin/sh

  2. : ${DIALOG=dialog}
  3. : ${DIALOG_OK=0}
  4. : ${DIALOG_CANCEL=1}
  5. : ${DIALOG_ESC=255}

  6. # global vars
  7. author="Frank Stephen"
  8. version="v0.14"
  9. year="2004"
  10. website="http://freshmeat.net/projects/g4l"

  11. # path to images on ftp server
  12. ftppath=img

  13. # window title
  14. backtitle="g4l $version, $author $year"


  15. # parse info about devices to tempfiles
  16. netdevices=`cat /proc/net/dev |grep eth |sed -e 's/://g' |awk '{print $1}'`
  17. partitions=`cat /proc/partitions |grep .d |awk '{print $4}'`

  18. # write systeminfo file
  19. echo "Drive/Partition sizes: " >> /tmp/sysinfo
  20. cat /proc/partitions |grep .d | awk '{print $4,$3}' |sort >>/tmp/sysinfo
  21. echo >> /tmp/sysinfo
  22. echo "Drive models: " >> /tmp/sysinfo
  23. for h in $partitions
  24. do
  25. length=`echo $h |wc -c`
  26. if [ $length -lt 5 ]; then
  27. echo $h >> /tmp/sysinfo
  28. cat /proc/ide/$h/model >> /tmp/sysinfo 2>/dev/null
  29. fi
  30. done

  31. # write menulists
  32. partlist=""
  33. netlist=""

  34. for i in $partitions
  35. do partlist="$partlist `echo $i detected...OK off`"
  36. done

  37. for j in $netdevices
  38. do netlist="$netlist `echo $j detected...OK off`"
  39. done


  40. function createTemp ()
  41. {
  42.         export tempfile${1}="/tmp/test${1}$$"
  43. }

  44. #
  45. # create tempfiles for menu structure
  46. #

  47. #main menu
  48. createTemp main

  49. #raw mode menu
  50. createTemp rawmenu


  51. # net menu
  52. createTemp netmenu

  53. # net config
  54. createTemp device

  55. # net device
  56. createTemp ip

  57. # net ftp
  58. createTemp ftp

  59. # net filename
  60. createTemp netname

  61. # net zip
  62. createTemp netzip

  63. # netbackup menu
  64. createTemp netback

  65. # netrestore menu
  66. createTemp netrest




  67. # local menu
  68. createTemp localmenu

  69. # local drive
  70. createTemp localdrive

  71. # local filename
  72. createTemp localname


  73. # local split
  74. createTemp localsplit

  75. # local zip
  76. createTemp localzip

  77. # local backup menu
  78. createTemp localback

  79. # local restore menu
  80. createTemp localrest



  81. # clone menu
  82. createTemp clonemenu

  83. # clone source
  84. createTemp clonesource

  85. # clone target
  86. createTemp clonetarget


  87. # file mode menu
  88. createTemp filemenu

  89. # file mode eth device
  90. createTemp fileip

  91. # file mode ip address
  92. createTemp filedevice


  93. # file mode partition
  94. createTemp filepart


  95. # util menu
  96. createTemp utilmenu

  97. # util hdparm
  98. createTemp hdparm

  99. # util zero
  100. createTemp utilzero

  101. # util dd_rescue
  102. createTemp ddres

  103. # util dd_rescue source
  104. createTemp ddressource

  105. # util dd_rescue target
  106. createTemp ddrestarget


  107. $DIALOG --backtitle "$backtitle" \
  108.         --title "INFORMATION" --clear \
  109.                 --yesno "g4l - Gh*st for Linux \n \
  110.                 $author $year \n\n \
  111.                 g4l comes with ABSOLUTELY NO WARRANTY ! \n \
  112.                 This is free Software, and you are welcome \n \
  113.                 to redistribute it freely. Read the online Help\n \
  114.                 for more info on this delicate topic. \n\n \
  115.                 USE AT OWN RISK! \n\n \
  116.                 Also, g4l has NOTHING to do with the famous\n \
  117.                 "Norton GHOST" (c) and (tm) by Symantec!\n \
  118.                 visit [url]www.symantec.com[/url] to get their product.\n\n \
  119.                 Accept these conditions? YES to proceed, NO to quit. " 20 60

  120. case $? in
  121. $DIALOG_OK)

  122.         while [ "$retvalmain" != "1" ]
  123.         do

  124.                 retvalrawmenu=0
  125.                 retvalfilemenu=0
  126.                 retvalnetmenu=0
  127.                 retvalclonemenu=0
  128.                 retvallocalmenu=0
  129.                 retvalutilmenu=0

  130.                 $DIALOG --backtitle "$backtitle" \
  131.                                 --title "MAIN MENU" \
  132.                                 --menu "Choose your desired mode:"  0 0 0 \
  133.                                         "RAW Mode"  "ANY filesystem, every bit, local+ftp" \
  134.                                         "File Mode"  "Some filesystems only, only files, local+special server" \
  135.                                         "Utilities"  "System info and tools" \
  136.                                         "Show Help"  "Show IMPORTANT help" 2> $tempfilemain
  137.                 retvalmain=$?

  138.                 choicemain=`cat $tempfilemain`

  139.                 case $retvalmain in
  140.                 $DIALOG_OK)
  141.                         case $choicemain in
  142.                         "RAW Mode")
  143.                                 while [ "$retvalrawmenu" != "1" ]
  144.                                 do
  145.                                 $DIALOG --backtitle "$backtitle" \
  146.                                                 --title "RAW MODE" \
  147.                                                 --menu "Choose one of the following options: \n\n" 0 0 0\
  148.                                                         "Network use"  "Backup/Restore to/from network" \
  149.                                                         "Local use"  "Backup/Restore to/from local drive" \
  150.                                                         "Click'n'Clone"  "Directly clone a drive" \
  151.                                                         "Show Help"  "Show IMPORTANT helpfile" 2> $tempfilerawmenu

  152.                                 retvalrawmenu=$?

  153.                                 choicerawmenu=`cat $tempfilerawmenu`

  154.                                 case $retvalrawmenu in
  155.                                 $DIALOG_OK)
  156.                                         case $choicerawmenu in
  157.                                         "Network use")
  158.                                                 retvalnetmenu=0

  159.                                                 while [ "$retvalnetmenu" != "1" ]
  160.                                                 do
  161.                                                         $DIALOG --clear --backtitle "$backtitle" \
  162.                                                                         --title "NETWORK USE" \
  163.                                                                         --menu "Choose one of the following options: \n\n" 0 0 0 \
  164.                                                                                 "Pick device"  "Select ethernet device" \
  165.                                                                                 "Config device"  "Set IP address" \
  166.                                                                                 "Config FTP"  "Set IP for FTP server" \
  167.                                                                                 "Config filename"  "Set filename on FTP" \
  168.                                                                                 "Toggle compression"  "Select compression types" \
  169.                                                                                 "Backup"  "Backup drive/partition to FTP server" \
  170.                                                                                 "Restore"  "Restore drive/partition from FTP server" 2> $tempfilenetmenu

  171.                                                         retvalnetmenu=$?

  172.                                                         choicenetmenu=`cat $tempfilenetmenu`

  173.                                                         case $retvalnetmenu in
  174.                                                         $DIALOG_OK)

  175.                                                                 case $choicenetmenu in
  176.                                                                 "Pick device")

  177.                                                                         $DIALOG --backtitle "$backtitle" \
  178.                                                                                         --title "PICK DEVICE" \
  179.                                                                                         --radiolist "Choose network device \n\
  180.                                                                                                                 Select from:" 0 0 0 \
  181.                                                                                                                 $netlist 2> $tempfiledevice
  182.                                                                         retvaldevice=$?

  183.                                                                         choicedevice=`cat $tempfiledevice`

  184.                                                                         case $retvaldevice in
  185.                                                                         $DIALOG_OK)

  186.                                                                                 device=$choicedevice
  187.                                                                         ;;

  188.                                                                         $DIALOG_CANCEL)
  189.                                                                         ;;

  190.                                                                         $DIALOG_ESC)
  191.                                                                         ;;
  192.                                                                         esac
  193.                                                                         ;;

  194.                                                         "Config device")
  195.                                                                         $DIALOG --backtitle "$backtitle" \
  196.                                                                                         --title "Set Network" --clear \
  197.                                                                                         --inputbox "Set IP Address to match your subnet. \
  198.                                                                                                 \nExample: 192.168.0.5 \
  199.                                                                                                 \n\nEnter IP Address:" 0 0 2> $tempfileip

  200.                                                                         retvalip=$?
  201.                                                                         case $retvalip in
  202.                                                                         $DIALOG_OK)

  203.                                                                                 ipaddress=`cat $tempfileip`
  204.                                                                                 /sbin/ifconfig $device $ipaddress up
  205.                                                                         ;;

  206.                                                                         $DIALOG_CANCEL)
  207.                                                                         ;;

  208.                                                                         $DIALOG_ESC)
  209.                                                                                 if test -s $tempfileip ; then
  210.                                                                                         ipaddress=`cat $tempfileip`
  211.                                                                                         /sbin/ifconfig $device $ipaddress up
  212.                                                                                 fi
  213.                                                                                 ;;
  214.                                                                         esac
  215.                                                                         ;;


  216.                                                         "Config FTP")
  217.                                                                 $DIALOG --backtitle "$backtitle" \
  218.                                                                                 --title "CONFIG FTP" --clear \
  219.                                                                                 --inputbox "Enter IP Address of FTP Server. \
  220.                                                                                                 \nFTP server musst allow anonymous write access! \
  221.                                                                                                 \nExample: 192.168.0.1 \
  222.                                                                                                 \n\nFTP IP:" 0 0 2> $tempfileftp

  223.                                                                 retvalftp=$?
  224.                                                                 case $retvalftp in
  225.                                                                 $DIALOG_OK)

  226.                                                                         server=`cat $tempfileftp`
  227.                                                                 ;;

  228.                                                                 $DIALOG_CANCEL)
  229.                                                                 ;;

  230.                                                                 $DIALOG_ESC)
  231.                                                                         if test -s $tempfileftp ; then
  232.                                                                                 server=`cat $tempfileftp`
  233.                                                                         fi
  234.                                                                 ;;
  235.                                                                 esac
  236.                                                                 ;;


  237.                                                         "Config filename")
  238.                                                                 $DIALOG --backtitle "$backtitle" \
  239.                                                                                 --title "CONFIG FILENAME" --clear \
  240.                                                                                 --inputbox "Enter filename of the stored image. \
  241.                                                                                         \nExample: hda_workstation2.img \
  242.                                                                                         \n\nFilename:" 0 0 2> $tempfilenetname

  243.                                                                 retvalnetname=$?
  244.                                                                 case $retvalnetname in
  245.                                                                 $DIALOG_OK)

  246.                                                                         netimagename=`cat $tempfilenetname`
  247.                                                                 ;;
  248.                                                                 $DIALOG_CANCEL)
  249.                                                                 ;;

  250.                                                                 $DIALOG_ESC)
  251.                                                                         if test -s $tempfilenetname ; then
  252.                                                                                 netimagename=`cat $tempfilenetname`
  253.                                                                         fi
  254.                                                                 ;;
  255.                                                                 esac
  256.                                                                 ;;

  257.                                                         "Toggle compression")
  258.                                                                 $DIALOG --backtitle "$backtitle" \
  259.                                                                                 --title "TOGGLE COMPRESSION" \
  260.                                                                                 --radiolist "Choose wether to use compression or not. \
  261.                                                                                         \nBe careful, compression requires much CPU power!" 0 0 0 \
  262.                                                                                         "None" "No compression." ON \
  263.                                                                                         "GZip" "GZip compression." off \
  264.                                                                                         "BZip2" "BZip2 compression." off 2> $tempfilenetzip

  265.                                                                 retvalnetzip=$?

  266.                                                                 choicenetzip=`cat $tempfilenetzip`
  267.                                                                 case $retvalnetzip in
  268.                                                                 $DIALOG_OK)

  269.                                                                         netzip=`cat $tempfilenetzip`
  270.                                                                 ;;

  271.                                                                 $DIALOG_CANCEL)
  272.                                                                 ;;

  273.                                                                 $DIALOG_ESC)
  274.                                                                         if test -s $tempfilenetzip ; then
  275.                                                                                 netzip=`cat $tempfilenetzip`
  276.                                                                         fi
  277.                                                                 ;;

  278.                                                                 esac
  279.                                                                 ;;

  280.                                                         "Backup")
  281.                                                                 if [ "$ipaddress" = "" ] ; then

  282.                                                                         $DIALOG --backtitle "$backtitle" \
  283.                                                                                         --title "ERROR" --clear \
  284.                                                                                         --msgbox "No Networtk IP Address for eth0 set! \n
  285.                                                                                                         ->Back to Main Menu." 0 0
  286.                                                                         continue
  287.                                                                 fi



  288.                                                                 if [ "$server" = "" ] ; then

  289.                                                                         $DIALOG --backtitle "$backtitle" \
  290.                                                                                 --title "ERROR" --clear \
  291.                                                                                 --msgbox "No FTP IP Address set! \n
  292.                                                                                                 ->Back to Main Menu." 0 0
  293.                                                                         continue
  294.                                                                 fi

  295.                                                                 if [ "$netimagename" = "" ] ; then

  296.                                                                         $DIALOG --backtitle "$backtitle" \
  297.                                                                                 --title "WARNING" --clear \
  298.                                                                                 --msgbox "No filename for image set, using default \n
  299.                                                                                                 Filename: image.img.gz" 0 0
  300.                                                                         netimagename=image.img.gz
  301.                                                                 fi



  302.                                                                 if [ "$netzip" = "" ] ; then

  303.                                                                         $DIALOG --backtitle "$backtitle" \
  304.                                                                                 --title "WARNING" --clear \
  305.                                                                                 --msgbox "Compression not defined, using default \n
  306.                                                                                                 Compression: None" 0 0
  307.                                                                         netzip=None
  308.                                                                 fi


  309.                                                                 $DIALOG --backtitle "$backtitle" \
  310.                                                                                 --title "BACKUP" \
  311.                                                                                 --radiolist "Choose Drive or Partition to backup\n\
  312.                                                                                                 Select from:" 0 0 0 \
  313.                                                                                                 $partlist 2> $tempfilenetback

  314.                                                                 retvalnetback=$?

  315.                                                                 choicenetback=`cat $tempfilenetback`

  316.                                                                 case $retvalnetback in
  317.                                                                 $DIALOG_OK)

  318.                                                                         disk=/dev/$choicenetback

  319.                                                                         $DIALOG --backtitle "$backtitle" \
  320.                                                                                         --title "ABOUT TO BACKUP" --clear \
  321.                                                                                         --yesno "Collected information: \
  322.                                                                                                         \nLocal IP Address: $ipaddress \
  323.                                                                                                         \nFTP IP Address: $server \
  324.                                                                                                         \nTarget imagename: $netimagename \
  325.                                                                                                         \nFTP path: $ftppath \
  326.                                                                                                         \nCompression: $netzip \
  327.                                                                                                         \nSource Drive: $disk \
  328.                                                                                                         \n\nAre you sure?" 0 0
  329.                                                                         case $? in
  330.                                                                         $DIALOG_OK)

  331.                                                                                 readsize=`cat /proc/partitions |grep -w $choicenetback |awk '{print $3}'`
  332.                                                                                 pcnt=0

  333.                                                                                 if [ "$netzip" = "None" ] ; then
  334.                                                                                         (dd if=$disk 2>/dev/null | jetcat-mod -p $readsize 2>/tmp/netback.out |ncftpput -c -d /tmp/out $server "/$ftppath/$netimagename") &

  335.                                                                                         (
  336.                                                                                         while test "$pcnt" != "100"
  337.                                                                                         do
  338.                                                                                                 pcnt=`tail -n1 /tmp/netback.out`
  339.                                                                                                 echo "XXX"
  340.                                                                                                 echo $pcnt
  341.                                                                                                 echo "\n"
  342.                                                                                                 echo "g4l is backing up your harddrive.\n"
  343.                                                                                                 echo "Every single bit of the drive is copied, so:\n\n"
  344.                                                                                                 echo "Please stand by, this might take some time!\n"
  345.                                                                                                 echo "XXX"
  346.                                                                                                 sleep 3
  347.                                                                                         done
  348.                                                                                         ) | $DIALOG --backtitle "$backtitle" \
  349.                                                                                                                 --title "Working..." \
  350.                                                                                                                 --gauge "One moment..." 18 60
  351.                                                                                         rm /tmp/netback.out
  352.                                                                                         touch /tmp/netback.out

  353.                                                                                 fi


  354.                                                                                 if [ "$netzip" = "GZip" ] ; then

  355.                                                                                         (dd if=$disk 2>/dev/null | jetcat-mod -p $readsize 2>/tmp/netback.out |gzip -c - | ncftpput -c -d /tmp/out $server "/$ftppath/$netimagename") &


  356.                                                                                         (
  357.                                                                                         while test "$pcnt" != "100"
  358.                                                                                         do
  359.                                                                                                 pcnt=`tail -n1 /tmp/netback.out`
  360.                                                                                                 echo "XXX"
  361.                                                                                                 echo $pcnt
  362.                                                                                                 echo "\n"
  363.                                                                                                 echo "g4l is backing up your harddrive.\n"
  364.                                                                                                 echo "Every single bit of the drive is copied, so:\n\n"
  365.                                                                                                 echo "Please stand by, this might take some time!\n"
  366.                                                                                                 echo "XXX"
  367.                                                                                                 sleep 3
  368.                                                                                         done
  369.                                                                                         ) | $DIALOG --backtitle "$backtitle" \
  370.                                                                                                                         --title "Working..." \
  371.                                                                                                         --gauge "One moment..." 18 60
  372.                                                                                         rm /tmp/netback.out
  373.                                                                                         touch /tmp/netback.out




  374.                                                                                 fi

  375.                                                                                 if [ "$netzip" = "BZip2" ] ; then

  376.                                                                                         (dd if=$disk 2>/dev/null | jetcat-mod -p $readsize 2>/tmp/netback.out |bzip2 | ncftpput -c -d /tmp/out $server "/$ftppath/$netimagename") &


  377.                                                                                         (
  378.                                                                                         while test "$pcnt" != "100"
  379.                                                                                         do
  380.                                                                                                 pcnt=`tail -n1 /tmp/netback.out`
  381.                                                                                                 echo "XXX"
  382.                                                                                                 echo $pcnt
  383.                                                                                                 echo "\n"
  384.                                                                                                 echo "g4l is backing up your harddrive.\n"
  385.                                                                                                 echo "Every single bit of the drive is copied, so:\n\n"
  386.                                                                                                 echo "Please stand by, this might take some time!\n"
  387.                                                                                                 echo "XXX"
  388.                                                                                                 sleep 3
  389.                                                                                         done
  390.                                                                                         ) | $DIALOG --backtitle "$backtitle" \
  391.                                                                                                                         --title "Working..." \
  392.                                                                                                         --gauge "One moment..." 18 60
  393.                                                                                         rm /tmp/netback.out
  394.                                                                                         touch /tmp/netback.out




  395.                                                                                 fi



  396.                                                                         ;;

  397.                                                                         $DIALOG_CANCEL)
  398.                                                                         ;;

  399.                                                                         $DIALOG_ESC)
  400.                                                                         ;;
  401.                                                                         esac
  402.                                                                         ;;

  403.                                                                 $DIALOG_CANCEL)
  404.                                                                 ;;

  405.                                                                 $DIALOG_ESC)
  406.                                                                 ;;

  407.                                                                 esac
  408.                                                                 ;;



  409.                                                         "Restore")
  410.                                                                 if [ "$ipaddress" = "" ] ; then

  411.                                                                         $DIALOG --backtitle "$backtitle" \
  412.                                                                                         --title "ERROR" --clear \
  413.                                                                                         --msgbox "No Networtk IP Address for eth0 set! \n
  414.                                                                                                         ->Back to Main Menu." 0 0
  415.                                                                         continue
  416.                                                                 fi

  417.                                                                 if [ "$server" = "" ] ; then

  418.                                                                         $DIALOG --backtitle "$backtitle" \
  419.                                                                                         --title "ERROR" --clear \
  420.                                                                                         --msgbox "No FTP IP Address set! \n
  421.                                                                                                         ->Back to Main Menu." 0 0
  422.                                                                         continue
  423.                                                                 fi

  424.                                                                 if [ "$netimagename" = "" ] ; then

  425.                                                                         $DIALOG --backtitle "$backtitle" \
  426.                                                                                         --title "WARNING" --clear \
  427.                                                                                         --msgbox "No filename for image set, using default \n
  428.                                                                                                         Filename: image.img.gz" 0 0
  429.                                                                         netimagename=image.img.gz
  430.                                                                 fi

  431.                                                                 if [ "$netzip" = "" ] ; then

  432.                                                                         $DIALOG --backtitle "$backtitle" \
  433.                                                                                         --title "WARNING" --clear \
  434.                                                                                         --msgbox "Compression not defined, using default \n
  435.                                                                                                         Compression: None" 0 0
  436.                                                                         netzip=None
  437.                                                                 fi

  438.                                                                 $DIALOG --backtitle "$backtitle" \
  439.                                                                                 --title "RESTORE" \
  440.                                                                                 --radiolist "Choose drive or partition to restore the image to \
  441.                                                                                                         \n\nSelect from:" 0 0 0 \
  442.                                                                                                         $partlist 2> $tempfilenetrest

  443.                                                                 retvalnetrest=$?

  444.                                                                 choicenetrest=`cat $tempfilenetrest`
  445.                                                                 case $retvalnetrest in
  446.                                                                 $DIALOG_OK)

  447.                                                                                 rest=/dev/$choicenetrest

  448.                                                                                 $DIALOG --backtitle "$backtitle" \
  449.                                                                                                 --title "About to restore disk" --clear \
  450.                                                                                                 --yesno "Collected information: \
  451.                                                                                                                 \nLocal IP Address: $ipaddress \
  452.                                                                                                                 \nFTP IP Address: $server \
  453.                                                                                                                 \nSource imagename: $netimagename \
  454.                                                                                                                 \nFTP path: $ftppath \
  455.                                                                                                                 \nCompression: $netzip \
  456.                                                                                                                 \nTarget disk: $rest \n\n \
  457.                                                                                                                 \n\nAre you sure?" 0 0
  458.                                                                                 case $? in
  459.                                                                                 $DIALOG_OK)

  460.                                                                                         writesize=`cat /proc/partitions |grep -w $choicenetrest |awk '{print $3}'`
  461.                                                                                         pcnt=0


  462.                                                                                         if [ "$netzip" = "None" ] ; then
  463.                                                                                                 (ncftpget -c -V -d /tmp/out $server "/$ftppath/$netimagename" | jetcat-mod -p $writesize 2>/tmp/netrest.out | dd of=$rest 2>/dev/null) &


  464.                                                                                                 (
  465.                                                                                                 while test "$pcnt" != "100"
  466.                                                                                                 do
  467.                                                                                                         pcnt=`tail -n1 /tmp/netrest.out`
  468.                                                                                                         echo "XXX"
  469.                                                                                                         echo $pcnt
  470.                                                                                                         echo "\n"
  471.                                                                                                         echo "g4l is restoring your harddrive.\n"
  472.                                                                                                         echo "\n"
  473.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  474.                                                                                                         echo "backups from small drives to large drives.\n\n"
  475.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  476.                                                                                                         echo "Please stand by, this might take some time!\n"
  477.                                                                                                         echo "XXX"
  478.                                                                                                         sleep 3
  479.                                                                                                 done
  480.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  481.                                                                                                                         --title "Working..." \
  482.                                                                                                                         --gauge "One moment..." 18 60
  483.                                                                                                 rm /tmp/netrest.out
  484.                                                                                                 touch /tmp/netrest.out

  485.                                                                                         fi

  486.                                                                                         if [ "$netzip" = "GZip" ] ; then

  487.                                                                                                 (ncftpget -c -V -d /tmp/out $server "/$ftppath/$netimagename" | gunzip -c -| jetcat-mod -p $writesize 2>/tmp/netrest.out |dd of=$rest 2>/dev/null) &

  488.                                                                                                 (
  489.                                                                                                 while test "$pcnt" != "100"
  490.                                                                                                 do
  491.                                                                                                         pcnt=`tail -n1 /tmp/netrest.out`
  492.                                                                                                         echo "XXX"
  493.                                                                                                         echo $pcnt
  494.                                                                                                         echo "\n"
  495.                                                                                                         echo "g4l is restoring your harddrive.\n"
  496.                                                                                                         echo "\n"
  497.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  498.                                                                                                         echo "backups from small drives to large drives.\n\n"
  499.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  500.                                                                                                         echo "Please stand by, this might take some time!\n"
  501.                                                                                                         echo "XXX"
  502.                                                                                                         sleep 3
  503.                                                                                                 done
  504.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  505.                                                                                                                         --title "Working..." \
  506.                                                                                                                         --gauge "One moment..." 18 60
  507.                                                                                                 rm /tmp/netrest.out
  508.                                                                                                 touch /tmp/netrest.out

  509.                                                                                         fi

  510.                                                                                         if [ "$netzip" = "BZip2" ] ; then

  511.                                                                                                 (ncftpget -c -V -d /tmp/out $server "/$ftppath/$netimagename" | bzcat | jetcat-mod -p $writesize 2>/tmp/netrest.out |dd of=$rest 2>/dev/null) &

  512.                                                                                                 (
  513.                                                                                                 while test "$pcnt" != "100"
  514.                                                                                                 do
  515.                                                                                                         pcnt=`tail -n1 /tmp/netrest.out`
  516.                                                                                                         echo "XXX"
  517.                                                                                                         echo $pcnt
  518.                                                                                                         echo "\n"
  519.                                                                                                         echo "g4l is restoring your harddrive.\n"
  520.                                                                                                         echo "\n"
  521.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  522.                                                                                                         echo "backups from small drives to large drives.\n\n"
  523.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  524.                                                                                                         echo "Please stand by, this might take some time!\n"
  525.                                                                                                         echo "XXX"
  526.                                                                                                         sleep 3
  527.                                                                                                 done
  528.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  529.                                                                                                                         --title "Working..." \
  530.                                                                                                                         --gauge "One moment..." 18 60
  531.                                                                                                 rm /tmp/netrest.out
  532.                                                                                                 touch /tmp/netrest.out
  533.                                                                                         fi
  534.                                                                                         rm /tmp/out
  535.                                                                                         touch /tmp/out
  536.                                                                                 ;;

  537.                                                                                 $DIALOG_CANCEL)
  538.                                                                                 ;;

  539.                                                                                 $DIALOG_ESC)
  540.                                                                                 ;;

  541.                                                                                 esac
  542.                                                                                 ;;

  543.                                                                         $DIALOG_CANCEL)
  544.                                                                         ;;

  545.                                                                         $DIALOG_ESC)
  546.                                                                         ;;

  547.                                                                         esac
  548.                                                                         ;;
  549.                                                                 esac
  550.                                                                 ;;
  551.                                                         $DIALOG_CANCEL)
  552.                                                         ;;

  553.                                                         $DIALOG_ESC)
  554.                                                         ;;
  555.                                                         esac


  556.                                                 done
  557.                                         ;;

  558.                                 "Local use")

  559.                                         retvallocalmenu=0
  560.                                        
  561.                                         while [ "$retvallocalmenu" != "1" ]
  562.                                         do
  563.                                                 $DIALOG --clear --backtitle "$backtitle" \
  564.                                                                 --title "LOCAL USE" \
  565.                                                                 --menu "Choose one of the following options: \n\n" 0 0 0 \
  566.                                                                                 "Pick drive"  "Select target/source drive" \
  567.                                                                                 "Config filename"  "Set filename" \
  568.                                                                                 "Toggle split"  "Activate file splitting" \
  569.                                                                                 "Toggle compression"  "Select compression types" \
  570.                                                                                 "Backup"  "Backup drive/partition to local drive" \
  571.                                                                                 "Restore"  "Restore drive/partition from local drive" 2> $tempfilelocalmenu

  572.                                                 retvallocalmenu=$?

  573.                                                 choicelocalmenu=`cat $tempfilelocalmenu`

  574.                                                 case $retvallocalmenu in
  575.                                                 $DIALOG_OK)

  576.                                                         case $choicelocalmenu in

  577.                                                         "Pick drive")

  578.                                                                 $DIALOG --backtitle "$backtitle" \
  579.                                                                                 --title "PICK DRIVE" \
  580.                                                                                 --radiolist "Choose drive to write to/read from.\
  581.                                                                                                 \nSupported FS are:\n\
  582.                                                                                                 ext2 - Linux\n\
  583.                                                                                                 ext3 - Linux\n\
  584.                                                                                                 reiserfs - Linux\n\
  585.                                                                                                 fat32 - Windows95/98/NT/2k/XP\n\
  586.                                                                                                 ntfs - Windows NT/2k/XP\
  587.                                                                                                 \n\nSelect partition (example: /dev/hda1):" 0 0 0 \
  588.                                                                                                 $partlist 2> $tempfilelocaldrive


  589.                                                                 retvallocaldrive=$?

  590.                                                                 choicelocaldrive=`cat $tempfilelocaldrive`
  591.                                                                 case $retvallocaldrive in
  592.                                                                 $DIALOG_OK)

  593.                                                                         localdrive=$choicelocaldrive
  594.                                                                         mount /dev/$localdrive /mnt/local >/tmp/mount 2>&1
  595.                                                                         retvalmount=$?
  596.                                                                         if [ $retvalmount != 0 ] ; then
  597.                                                                                 $DIALOG --backtitle "$backtitle" \
  598.                                                                                                 --title "ERROR" \
  599.                                                                                                 --textbox /tmp/mount 0 0
  600.                                                                                 localdrive=""
  601.                                                                                 umount /mnt/local
  602.                                                                         fi

  603.                                                                 ;;

  604.                                                                 $DIALOG_CANCEL)
  605.                                                                 ;;

  606.                                                                 $DIALOG_ESC)
  607.                                                                 ;;

  608.                                                                 esac
  609.                                                                 ;;

  610.                                                         "Config filename")
  611.                                                                 $DIALOG --backtitle "$backtitle" \
  612.                                                                                 --title "CONFIG FILENAME" --clear \
  613.                                                                                 --inputbox "Enter filename of the stored image. \
  614.                                                                                                 \nExample: hda_workstation2.img \
  615.                                                                                                 \n\nFilename:" 0 0 2> $tempfilelocalname

  616.                                                                 retvallocalname=$?
  617.                                                                 case $retvallocalname in
  618.                                                                 $DIALOG_OK)

  619.                                                                         localimagename=`cat $tempfilelocalname`
  620.                                                                 ;;

  621.                                                                 $DIALOG_CANCEL)
  622.                                                                 ;;

  623.                                                                 $DIALOG_ESC)

  624.                                                                         if test -s $tempfilelocalname ; then
  625.                                                                                 localimagename=`cat $tempfilelocalname`
  626.                                                                         fi
  627.                                                                 ;;
  628.                                                                 esac
  629.                                                                 ;;

  630.                                                         "Toggle split")
  631.                                                                 $DIALOG --backtitle "$backtitle" \
  632.                                                                                 --title "TOGGLE SPLIT" \
  633.                                                                                 --radiolist "Choose if the imagefile should be split. \
  634.                                                                                                         \nIf the FS limits filesize to 2GB, enable splitting!" 0 0 0 \
  635.                                                                                                         "Off" "Splitting off." ON \
  636.                                                                                                         "On" "Splitting on." off  2> $tempfilelocalsplit

  637.                                                                 retvallocalsplit=$?

  638.                                                                 choicelocalsplit=`cat $tempfilelocalsplit`
  639.                                                                 case $retvallocalsplit in
  640.                                                                 $DIALOG_OK)

  641.                                                                         localsplit=`cat $tempfilelocalsplit`
  642.                                                                 ;;

  643.                                                                 $DIALOG_CANCEL)
  644.                                                                 ;;

  645.                                                                 $DIALOG_ESC)

  646.                                                                         if test -s $tempfilelocalsplit ; then
  647.                                                                                 localsplit=`cat $tempfilelocalsplit`
  648.                                                                         fi
  649.                                                                 ;;
  650.                                                                 esac
  651.                                                                 ;;


  652.                                                         "Toggle compression")

  653.                                                                 $DIALOG --backtitle "$backtitle" \
  654.                                                                                 --title "TOGGLE COMPRESSION" \
  655.                                                                                 --radiolist "Choose wether to use compression or not. \
  656.                                                                                                         \nBe careful, compression requires much CPU power!" 0 0 0 \
  657.                                                                                                         "None" "No compression." ON \
  658.                                                                                                         "GZip" "GZip compression." off \
  659.                                                                                                         "BZip2" "BZip2 compression." off 2> $tempfilelocalzip

  660.                                                                 retvallocalzip=$?

  661.                                                                 choicelocalzip=`cat $tempfilelocalzip`
  662.                                                                 case $retvallocalzip in
  663.                                                                 $DIALOG_OK)

  664.                                                                         localzip=`cat $tempfilelocalzip`
  665.                                                                 ;;

  666.                                                                 $DIALOG_CANCEL)
  667.                                                                 ;;

  668.                                                                 $DIALOG_ESC)
  669.                                                                         if test -s $tempfilelocalzip ; then
  670.                                                                                 localzip=`cat $tempfilelocalzip`
  671.                                                                         fi
  672.                                                                 ;;

  673.                                                                 esac
  674.                                                                 ;;


  675.                                                         "Backup")

  676.                                                                 if [ "$localdrive" = "" ] ; then

  677.                                                                         $DIALOG --backtitle "$backtitle" \
  678.                                                                                         --title "ERROR" --clear \
  679.                                                                                         --msgbox "No target drive set! \n
  680.                                                                                                         ->Back to Main Menu." 0 0
  681.                                                                         continue
  682.                                                                 fi


  683.                                                                 if [ "$localimagename" = "" ] ; then

  684.                                                                         $DIALOG --backtitle "$backtitle" \
  685.                                                                                         --title "WARNING" --clear \
  686.                                                                                         --msgbox "No filename for image set, using default \n
  687.                                                                                                         Filename: image.img.gz" 0 0
  688.                                                                         localimagename=image.img.gz
  689.                                                                 fi

  690.                                                                 if [ "$localsplit" = "" ] ; then

  691.                                                                         $DIALOG --backtitle "$backtitle" \
  692.                                                                                         --title "WARNING" --clear \
  693.                                                                                         --msgbox "Splitting not defined, using default \n
  694.                                                                                                         Splitting: Off" 0 0
  695.                                                                         localsplit=Off
  696.                                                                 fi


  697.                                                                 if [ "$localzip" = "" ] ; then

  698.                                                                         $DIALOG --backtitle "$backtitle" \
  699.                                                                                         --title "WARNING" --clear \
  700.                                                                                         --msgbox "Compression not defined, using default \n
  701.                                                                                                         Compression: None" 0 0
  702.                                                                         localzip=None
  703.                                                                 fi

  704.                                                                 $DIALOG --backtitle "$backtitle" \
  705.                                                                                 --title "BACKUP" \
  706.                                                                                 --radiolist "Choose Drive or Partition to backup\n\
  707.                                                                                                         Select from:" 0 0 0 \
  708.                                                                                                         $partlist 2> $tempfilelocalback

  709.                                                                 retvallocalback=$?

  710.                                                                 choicelocalback=`cat $tempfilelocalback`

  711.                                                                 case $retvallocalback in
  712.                                                                 $DIALOG_OK)

  713.                                                                         localback=/dev/$choicelocalback

  714.                                                                         $DIALOG --backtitle "$backtitle" \
  715.                                                                                         --title "ABOUT TO BACKUP" --clear \
  716.                                                                                         --yesno "Collected information: \
  717.                                                                                                         \nTarget drive in /mnt/local: $localdrive \
  718.                                                                                                         \nFilename for image: $localimagename \
  719.                                                                                                         \nSplitting: $localsplit \
  720.                                                                                                         \nCompression: $localzip \
  721.                                                                                                         \nSource drive: $localback \
  722.                                                                                                         \n\nAre you sure?" 0 0

  723.                                                                         case $? in
  724.                                                                         $DIALOG_OK)

  725.                                                                                 localreadsize=`cat /proc/partitions |grep -w $choicelocalback |awk '{print $3}' `
  726.                                                                                 pcnt=0

  727.                                                                                 if [ "$localzip" = "None" ] ; then

  728.                                                                                         if [ "$localsplit" = "Off" ] ; then

  729.                                                                                                 dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out | dd of=/mnt/local/$localimagename 2>/dev/null &

  730.                                                                                                 (
  731.                                                                                                 while test "$pcnt" != "100"
  732.                                                                                                 do
  733.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  734.                                                                                                         echo "XXX"
  735.                                                                                                         echo $pcnt
  736.                                                                                                         echo "\n"
  737.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  738.                                                                                                         echo "\n"
  739.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  740.                                                                                                         echo "Please stand by, this might take some time!\n"
  741.                                                                                                         echo "XXX"
  742.                                                                                                         sleep 3
  743.                                                                                                 done
  744.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  745.                                                                                                                         --title "Working..." \
  746.                                                                                                                         --gauge "One moment..." 18 60
  747.                                                                                                 rm /tmp/localback.out
  748.                                                                                                 touch /tmp/localback.out
  749.                                                                                         fi

  750.                                                                                         if [ "$localsplit" = "On" ] ; then

  751.                                                                                                 (dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out |split -b 2000m - /mnt/local/$localimagename. ) &

  752.                                                                                                 (
  753.                                                                                                 while test "$pcnt" != "100"
  754.                                                                                                 do
  755.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  756.                                                                                                         echo "XXX"
  757.                                                                                                         echo $pcnt
  758.                                                                                                         echo "\n"
  759.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  760.                                                                                                         echo "\n"
  761.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  762.                                                                                                         echo "Please stand by, this might take some time!\n"
  763.                                                                                                         echo "XXX"
  764.                                                                                                         sleep 3
  765.                                                                                                 done
  766.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  767.                                                                                                                         --title "Working..." \
  768.                                                                                                                         --gauge "One moment..." 18 60
  769.                                                                                                 rm /tmp/localback.out
  770.                                                                                                 touch /tmp/localback.out

  771.                                                                                         fi
  772.                                                                                 fi


  773.                                                                                 if [ "$localzip" = "GZip" ] ; then

  774.                                                                                         if [ "$localsplit" = "Off" ] ; then

  775.                                                                                                 (dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out |gzip -c - >/mnt/local/$localimagename) &

  776.                                                                                                 (
  777.                                                                                                 while test "$pcnt" != "100"
  778.                                                                                                 do
  779.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  780.                                                                                                         echo "XXX"
  781.                                                                                                         echo $pcnt
  782.                                                                                                         echo "\n"
  783.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  784.                                                                                                         echo "\n"
  785.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  786.                                                                                                         echo "Please stand by, this might take some time!\n"
  787.                                                                                                         echo "XXX"
  788.                                                                                                         sleep 3
  789.                                                                                                 done
  790.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  791.                                                                                                                         --title "Working..." \
  792.                                                                                                                         --gauge "One moment..." 18 60
  793.                                                                                                 rm /tmp/localback.out
  794.                                                                                                 touch /tmp/localback.out

  795.                                                                                         fi


  796.                                                                                         if [ "$localsplit" = "On" ] ; then

  797.                                                                                                 (dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out | gzip -c - | split -b 2000m - /mnt/local/$localimagename. ) &

  798.                                                                                                 (
  799.                                                                                                 while test "$pcnt" != "100"
  800.                                                                                                 do
  801.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  802.                                                                                                         echo "XXX"
  803.                                                                                                         echo $pcnt
  804.                                                                                                         echo "\n"
  805.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  806.                                                                                                         echo "\n"
  807.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  808.                                                                                                         echo "Please stand by, this might take some time!\n"
  809.                                                                                                         echo "XXX"
  810.                                                                                                         sleep 3
  811.                                                                                                 done
  812.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  813.                                                                                                                         --title "Working..." \
  814.                                                                                                                         --gauge "One moment..." 18 60
  815.                                                                                                 rm /tmp/localback.out
  816.                                                                                                 touch /tmp/localback.out

  817.                                                                                         fi

  818.                                                                                 fi


  819.                                                                                 if [ "$localzip" = "BZip2" ] ; then

  820.                                                                                         if [ "$localsplit" = "Off" ] ; then

  821.                                                                                                 (dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out | bzip2 >/mnt/local/$localimagename) &

  822.                                                                                                 (
  823.                                                                                                 while test "$pcnt" != "100"
  824.                                                                                                 do
  825.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  826.                                                                                                         echo "XXX"
  827.                                                                                                         echo $pcnt
  828.                                                                                                         echo "\n"
  829.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  830.                                                                                                         echo "\n"
  831.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  832.                                                                                                         echo "Please stand by, this might take some time!\n"
  833.                                                                                                         echo "XXX"
  834.                                                                                                         sleep 3
  835.                                                                                                 done
  836.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  837.                                                                                                                         --title "Working..." \
  838.                                                                                                                         --gauge "One moment..." 18 60
  839.                                                                                                 rm /tmp/localback.out
  840.                                                                                                 touch /tmp/localback.out
  841.                                                                                         fi

  842.                                                                                         if [ "$localsplit" = "On" ] ; then

  843.                                                                                                 (dd if=$localback 2>/dev/null |jetcat-mod -p $localreadsize 2>/tmp/localback.out | bzip2 | split -b 2000m - /mnt/local/$localimagename. ) &

  844.                                                                                                 (
  845.                                                                                                 while test "$pcnt" != "100"
  846.                                                                                                 do
  847.                                                                                                         pcnt=`tail -n1 /tmp/localback.out`
  848.                                                                                                         echo "XXX"
  849.                                                                                                         echo $pcnt
  850.                                                                                                         echo "\n"
  851.                                                                                                         echo "g4l is backing up your harddrive locally.\n"
  852.                                                                                                         echo "\n"
  853.                                                                                                         echo "Every single bit of the drive is copied, so:\n\n"
  854.                                                                                                         echo "Please stand by, this might take some time!\n"
  855.                                                                                                         echo "XXX"
  856.                                                                                                         sleep 3
  857.                                                                                                 done
  858.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  859.                                                                                                                         --title "Working..." \
  860.                                                                                                                         --gauge "One moment..." 18 60
  861.                                                                                                 rm /tmp/localback.out
  862.                                                                                                 touch /tmp/localback.out
  863.                                                                                         fi
  864.                                                                                 fi

  865.                                                                                 umount /mnt/local
  866.                                                                                 rm /tmp/out
  867.                                                                                 touch /tmp/out
  868.                                                                         ;;

  869.                                                                         $DIALOG_CANCEL)
  870.                                                                         ;;

  871.                                                                         $DIALOG_ESC)
  872.                                                                         ;;

  873.                                                                         esac
  874.                                                                         ;;
  875.                                                                 esac
  876.                                                                 ;;


  877.                                                         "Restore")

  878.                                                                 if [ "$localdrive" = "" ] ; then

  879.                                                                         $DIALOG --backtitle "$backtitle" \
  880.                                                                                         --title "ERROR" --clear \
  881.                                                                                         --msgbox "No target drive set! \n
  882.                                                                                                         ->Back to Main Menu." 0 0
  883.                                                                         continue
  884.                                                                 fi


  885.                                                                 if [ "$localimagename" = "" ] ; then

  886.                                                                         $DIALOG --backtitle "$backtitle" \
  887.                                                                                         --title "WARNING" --clear \
  888.                                                                                         --msgbox "No filename for image set, using default \n
  889.                                                                                                         Filename: image.img.gz" 0 0
  890.                                                                         localimagename=image.img.gz
  891.                                                                 fi

  892.                                                                 if [ "$localsplit" = "" ] ; then

  893.                                                                         $DIALOG --backtitle "$backtitle" \
  894.                                                                                         --title "WARNING" --clear \
  895.                                                                                         --msgbox "Splitting not defined, using default \n
  896.                                                                                                         Splitting: Off" 0 0
  897.                                                                         localsplit=Off
  898.                                                                 fi


  899.                                                                 if [ "$localzip" = "" ] ; then

  900.                                                                         $DIALOG --backtitle "$backtitle" \
  901.                                                                                         --title "WARNING" --clear \
  902.                                                                                         --msgbox "Compression not defined, using default \n
  903.                                                                                                         Compression: None" 0 0
  904.                                                                         localzip=None
  905.                                                                 fi


  906.                                                                 $DIALOG --backtitle "$backtitle" \
  907.                                                                                 --title "RESTORE" \
  908.                                                                                 --radiolist "Choose Drive or Partition to restore\n\
  909.                                                                                                         Select from:" 0 0 0 \
  910.                                                                                                         $partlist 2> $tempfilelocalrest


  911.                                                                 retvallocalrest=$?

  912.                                                                 choicelocalrest=`cat $tempfilelocalrest`
  913.                                                                 case $retvallocalrest in
  914.                                                                 $DIALOG_OK)

  915.                                                                         localrest=/dev/$choicelocalrest

  916.                                                                         $DIALOG --backtitle "$backtitle" \
  917.                                                                                         --title "ABOUT TO RESTORE" --clear \
  918.                                                                                         --yesno "Collected information: \
  919.                                                                                                         \nTarget drive in /mnt/local: $localdrive \
  920.                                                                                                         \nFilename for image: $localimagename \
  921.                                                                                                         \nSplitting: $localsplit \
  922.                                                                                                         \nCompression: $localzip \
  923.                                                                                                         \nTarget drive: $localrest \
  924.                                                                                                         \n\nAre you sure?" 0 0

  925.                                                                         case $? in
  926.                                                                         $DIALOG_OK)

  927.                                                                                 localwritesize=`cat /proc/partitions |grep -w $choicelocalrest |awk '{print $3}' `
  928.                                                                                 pcnt=0

  929.                                                                                 if [ "$localzip" = "None" ] ; then

  930.                                                                                         if [ "$localsplit" = "Off" ] ; then

  931.                                                                                                 (dd if=/mnt/local/$localimagename 2>/dev/null |jetcat-mod -p $localwritesize 2>/tmp/localrest.out |dd of=$localrest 2>/dev/null) &

  932.                                                                                                 (
  933.                                                                                                 while test "$pcnt" != "100"
  934.                                                                                                 do
  935.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  936.                                                                                                         echo "XXX"
  937.                                                                                                         echo $pcnt
  938.                                                                                                         echo "\n"
  939.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  940.                                                                                                         echo "\n"
  941.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  942.                                                                                                         echo "backups from small drives to large drives.\n\n"
  943.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  944.                                                                                                         echo "Please stand by, this might take some time!\n"
  945.                                                                                                         echo "XXX"
  946.                                                                                                         sleep 3
  947.                                                                                                 done
  948.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  949.                                                                                                                         --title "Working..." \
  950.                                                                                                                         --gauge "One moment..." 18 60
  951.                                                                                                 rm /tmp/localrest.out
  952.                                                                                                 touch /tmp/localrest.out
  953.                                                                                         fi

  954.                                                                                         if [ "$localsplit" = "On" ] ; then

  955.                                                                                                 (cat /mnt/local/$localimagename.* |jetcat-mod -p $localwritesize 2>/tmp/localrest.out |dd of=$localrest 2>/dev/null) &
  956.                                                                                                 (
  957.                                                                                                 while test "$pcnt" != "100"
  958.                                                                                                 do
  959.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  960.                                                                                                         echo "XXX"
  961.                                                                                                         echo $pcnt
  962.                                                                                                         echo "\n"
  963.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  964.                                                                                                         echo "\n"
  965.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  966.                                                                                                         echo "backups from small drives to large drives.\n\n"
  967.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  968.                                                                                                         echo "Please stand by, this might take some time!\n"
  969.                                                                                                         echo "XXX"
  970.                                                                                                         sleep 3
  971.                                                                                                 done
  972.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  973.                                                                                                                         --title "Working..." \
  974.                                                                                                                         --gauge "One moment..." 18 60
  975.                                                                                                 rm /tmp/localrest.out
  976.                                                                                                 touch /tmp/localrest.out
  977.                                                                                         fi
  978.                                                                                 fi


  979.                                                                                 if [ "$localzip" = "GZip" ] ; then

  980.                                                                                         if [ "$localsplit" = "Off" ] ; then

  981.                                                                                                 (dd if=/mnt/local/$localimagename 2>/dev/null |gunzip -c - |jetcat-mod -p $localwritesize 2>/tmp/localrest.out |dd of=$localrest 2>/dev/null) &

  982.                                                                                                 (
  983.                                                                                                 while test "$pcnt" != "100"
  984.                                                                                                 do
  985.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  986.                                                                                                         echo "XXX"
  987.                                                                                                         echo $pcnt
  988.                                                                                                         echo "\n"
  989.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  990.                                                                                                         echo "\n"
  991.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  992.                                                                                                         echo "backups from small drives to large drives.\n\n"
  993.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  994.                                                                                                         echo "Please stand by, this might take some time!\n"
  995.                                                                                                         echo "XXX"
  996.                                                                                                         sleep 3
  997.                                                                                                 done
  998.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  999.                                                                                                                         --title "Working..." \
  1000.                                                                                                                         --gauge "One moment..." 18 60
  1001.                                                                                                 rm /tmp/localrest.out
  1002.                                                                                                 touch /tmp/localrest.out

  1003.                                                                                         fi


  1004.                                                                                         if [ "$localsplit" = "On" ] ; then

  1005.                                                                                                 (cat /mnt/local/$localimagename.* |gunzip -c - |jetcat-mod -p $localwritesize 2>/tmp/localrest.out |dd of=$localrest 2>/dev/null) &
  1006.                                                                                                 (
  1007.                                                                                                 while test "$pcnt" != "100"
  1008.                                                                                                 do
  1009.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  1010.                                                                                                         echo "XXX"
  1011.                                                                                                         echo $pcnt
  1012.                                                                                                         echo "\n"
  1013.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  1014.                                                                                                         echo "\n"
  1015.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  1016.                                                                                                         echo "backups from small drives to large drives.\n\n"
  1017.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  1018.                                                                                                         echo "Please stand by, this might take some time!\n"
  1019.                                                                                                         echo "XXX"
  1020.                                                                                                         sleep 3
  1021.                                                                                                 done
  1022.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  1023.                                                                                                                         --title "Working..." \
  1024.                                                                                                                         --gauge "One moment..." 18 60
  1025.                                                                                                 rm /tmp/localrest.out
  1026.                                                                                                 touch /tmp/localrest.out
  1027.                                                                                         fi

  1028.                                                                                 fi

  1029.                                                                                 if [ "$localzip" = "BZip2" ] ; then

  1030.                                                                                         if [ "$localsplit" = "Off" ] ; then

  1031.                                                                                                 (dd if=/mnt/local/$localimagename 2>/dev/null |bzcat |jetcat-mod -p $localwritesize 2>/tmp/localrest.out |dd of=$localrest 2>/dev/null) &
  1032.                                                                                                 (
  1033.                                                                                                 while test "$pcnt" != "100"
  1034.                                                                                                 do
  1035.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  1036.                                                                                                         echo "XXX"
  1037.                                                                                                         echo $pcnt
  1038.                                                                                                         echo "\n"
  1039.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  1040.                                                                                                         echo "\n"
  1041.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  1042.                                                                                                         echo "backups from small drives to large drives.\n\n"
  1043.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  1044.                                                                                                         echo "Please stand by, this might take some time!\n"
  1045.                                                                                                         echo "XXX"
  1046.                                                                                                         sleep 3
  1047.                                                                                                 done
  1048.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  1049.                                                                                                                         --title "Working..." \
  1050.                                                                                                                         --gauge "One moment..." 18 60
  1051.                                                                                                 rm /tmp/localrest.out
  1052.                                                                                                 touch /tmp/localrest.out
  1053.                                                                                         fi

  1054.                                                                                         if [ "$localsplit" = "On" ] ; then

  1055.                                                                                                 (bzcat /mnt/local/$localimagename.* |jetcat-mod -p $localwritesize 2>/tmp/localrest.out | dd of=$localrest 2>/dev/null) &

  1056.                                                                                                 (
  1057.                                                                                                 while test "$pcnt" != "100"
  1058.                                                                                                 do
  1059.                                                                                                         pcnt=`tail -n1 /tmp/localrest.out`
  1060.                                                                                                         echo "XXX"
  1061.                                                                                                         echo $pcnt
  1062.                                                                                                         echo "\n"
  1063.                                                                                                         echo "g4l is restoring your harddrive locally.\n"
  1064.                                                                                                         echo "\n"
  1065.                                                                                                         echo "The progress bar will be inaccurate if you restore\n"
  1066.                                                                                                         echo "backups from small drives to large drives.\n\n"
  1067.                                                                                                         echo "Every single bit of the drive is written, so:\n\n"
  1068.                                                                                                         echo "Please stand by, this might take some time!\n"
  1069.                                                                                                         echo "XXX"
  1070.                                                                                                         sleep 3
  1071.                                                                                                 done
  1072.                                                                                                 ) | $DIALOG --backtitle "$backtitle" \
  1073.                                                                                                                         --title "Working..." \
  1074.                                                                                                                         --gauge "One moment..." 18 60
  1075.                                                                                                 rm /tmp/localrest.out
  1076.                                                                                                 touch /tmp/localrest.out
  1077.                                                                                         fi
  1078.                                                                                 fi

  1079.                                                                                 umount /mnt/local
  1080.                                                                                 rm /tmp/out
  1081.                                                                                 touch /tmp/out
  1082.                                                                         ;;

  1083.                                                                         $DIALOG_CANCEL)
  1084.                                                                         ;;

  1085.                                                                         $DIALOG_ESC)
  1086.                                                                         ;;

  1087.                                                                         esac
  1088.                                                                         ;;
  1089.                                                                 esac
  1090.                                                                 ;;

  1091.                                                         esac
  1092.                                                         ;;

  1093.                                                 $DIALOG_CANCEL)
  1094.                                                 ;;

  1095.                                                 $DIALOG_ESC)
  1096.                                                 ;;

  1097.                                                 esac
  1098.                                         done
  1099.                                         ;;

  1100.                                 "Click'n'Clone")

  1101.                                         while [ "$retvalclonemenu" != "1" ]
  1102.                                         do
  1103.                                                 $DIALOG --clear --backtitle "$backtitle" \
  1104.                                                                 --title "CLICK'n'CLONE" \
  1105.                                                                 --menu "Choose one of the following options: \n\n" 0 0 0 \
  1106.                                                                                 "Select source"  "Select source drive" \
  1107.                                                                                 "Select target"  "Select target drive" \
  1108.                                                                                 "Click'n'Clone"  "Clone the drive now!" 2> $tempfileclonemenu

  1109.                                                 retvalclonemenu=$?

  1110.                                                 choiceclonemenu=`cat $tempfileclonemenu`

  1111.                                                 case $retvalclonemenu in
  1112.                                                 $DIALOG_OK)

  1113.                                                         case $choiceclonemenu in
  1114.                                                         "Select source")

  1115.                                                                 $DIALOG --backtitle "$backtitle" \
  1116.                                                                                 --title "SELECT SOURCE" \
  1117.                                                                                 --radiolist "Choose source drive to clone.\n\
  1118.                                                                                                         Select from:" 0 0 0 \
  1119.                                                                                                         $partlist 2> $tempfileclonesource

  1120.                                                                 retvalclonesource=$?

  1121.                                                                 choiceclonesource=`cat $tempfileclonesource`
  1122.                                                                 case $retvalclonesource in
  1123.                                                                 $DIALOG_OK)

  1124.                                                                         clonesource=/dev/$choiceclonesource
  1125.                                                                 ;;

  1126.                                                                 $DIALOG_CANCEL)
  1127.                                                                 ;;

  1128.                                                                 $DIALOG_ESC)
  1129.                                                                 ;;

  1130.                                                                 esac
  1131.                                                                 ;;

  1132.                                                         "Select target")
  1133.                                                                 $DIALOG --backtitle "$backtitle" \
  1134.                                                                                 --title "SELECT TARGET" \
  1135.                                                                                 --radiolist "Choose target drive to clone to.\n\
  1136.                                                                                                         Attention: Select a drive with at least\n\
  1137.                                                                                                         the same capacity. Higher capacity is OK.\n\
  1138.                                                                                                         Select from:" 0 0 0 \
  1139.                                                                                                         $partlist 2> $tempfileclonetarget


  1140.                                                                 retvalclonetarget=$?

  1141.                                                                 choiceclonetarget=`cat $tempfileclonetarget`
  1142.                                                                 case $retvalclonetarget in
  1143.                                                                 $DIALOG_OK)

  1144.                                                                         clonetarget=/dev/$choiceclonetarget
  1145.                                                                 ;;

  1146.                                                                 $DIALOG_CANCEL)
  1147.                                                                 ;;

  1148.                                                                 $DIALOG_ESC)
  1149.                                                                 ;;

  1150.                                                                 esac
  1151.                                                                 ;;


  1152.                                                         "Click'n'Clone")
  1153.                                                                 if [ "$clonesource" = "" ] ; then

  1154.                                                                         $DIALOG --backtitle "$backtitle" \
  1155.                                                                                         --title "ERROR" --clear \
  1156.                                                                                         --msgbox "No source drive for cloning set! \n
  1157.                                                                                                         ->Back to Main Menu." 0 0
  1158.                                                                         continue
  1159.                                                                 fi

  1160.                                                                 if [ "$clonetarget" = "" ] ; then

  1161.                                                                         $DIALOG --backtitle "$backtitle" \
  1162.                                                                                         --title "ERROR" --clear \
  1163.                                                                                         --msgbox "No target drive for cloning set! \n
  1164.                                                                                                         ->Back to Main Menu." 0 0
  1165.                                                                         continue
  1166.                                                                 fi

  1167.                                                                 $DIALOG --backtitle "$backtitle" \
  1168.                                                                                 --title "ABOUT TO CLONE" --clear \
  1169.                                                                                 --yesno "Collected information: \
  1170.                                                                                                 \nSource drive: $clonesource \
  1171.                                                                                                 \nTarget drive: $clonetarget \
  1172.                                                                                                 \n\nAre you sure?" 0 0
  1173.                                                                 case $? in
  1174.                                                                 $DIALOG_OK)

  1175.                                                                         clonesize=`cat /proc/partitions |grep -w $choiceclonesource |awk '{print $3}' `
  1176.                                                                         pcnt=0

  1177.                                                                         dd if=$clonesource 2>/dev/null |jetcat-mod -p $clonesize 2>/tmp/clone.out |dd of=$clonetarget 2>/dev/null &

  1178.                                                                         (
  1179.                                                                         while test "$pcnt" != "100"
  1180.                                                                         do
  1181.                                                                                 pcnt=`tail -n1 /tmp/clone.out`
  1182.                                                                                 echo "XXX"
  1183.                                                                                 echo $pcnt
  1184.                                                                                 echo "\n"
  1185.                                                                                 echo "g4l is cloning your harddrive.\n"
  1186.                                                                                 echo "\n"
  1187.                                                                                 echo "Every single bit of the drive is written, so:\n\n"
  1188.                                                                                 echo "Please stand by, this might take some time!\n"
  1189.                                                                                 echo "XXX"
  1190.                                                                                 sleep 3
  1191.                                                                         done
  1192.                                                                         ) | $DIALOG --backtitle "$backtitle" \
  1193.                                                                                                 --title "Working..." \
  1194.                                                                                                 --gauge "One moment..." 18 60
  1195.                                                                         rm /tmp/clone.out
  1196.                                                                         touch /tmp/clone.out
  1197.                                                                         rm /tmp/out
  1198.                                                                         touch /tmp/out
  1199.                                                                 ;;

  1200.                                                                 $DIALOG_CANCEL)
  1201.                                                                 ;;

  1202.                                                                 $DIALOG_ESC)
  1203.                                                                 ;;
  1204.                                                                 esac
  1205.                                                                 ;;
  1206.                                                         esac
  1207.                                                         ;;

  1208.                                                 $DIALOG_CANCEL)
  1209.                                                 ;;

  1210.                                                 $DIALOG_ESC)
  1211.                                                 ;;

  1212.                                                 esac
  1213.                                         done
  1214.                                         ;;

  1215.                                         $DIALOG_CANCEL)
  1216.                                         ;;

  1217.                                         $DIALOG_ESC)
  1218.                                         ;;

  1219.                                         esac
  1220.                                         ;;
  1221.                                 $DIALOG_ESC)
  1222.                                 ;;

  1223.                                 esac

  1224.                         done
  1225.                         ;;
  1226.                         "File Mode")
  1227.                                 while [ "$retvalfilemenu" != "1" ]
  1228.                                 do
  1229.                                         $DIALOG --clear --backtitle "$backtitle" \
  1230.                                                         --title "FILE MODE" \
  1231.                                                         --menu "Choose one of the following options: \n\n" 0 0 0 \
  1232.                                                                 "Pick device"  "Select ethernet device (client/server mode only)" \
  1233.                                                                 "Config device"  "Set IP address (client/server mode only)" \
  1234.                                                                 "Select partition"  "Select partition to mount (server/local mode only)" \
  1235.                                                                 "Launch client"  "Launch 'partimage' in client/local mode" \
  1236.                                                                 "Launch server"  "Launch 'partimage' in server mode" 2> $tempfilefilemenu

  1237.                                         retvalfilemenu=$?

  1238.                                         choicefilemenu=`cat $tempfilefilemenu`

  1239.                                         case $retvalfilemenu in
  1240.                                         $DIALOG_OK)

  1241.                                                 case $choicefilemenu in
  1242.                                                 "Pick device")

  1243.                                                         $DIALOG --backtitle "$backtitle" \
  1244.                                                                         --title "PICK DEVICE" \
  1245.                                                                         --radiolist "Choose network device \n\
  1246.                                                                                                 Select from:" 0 0 0 \
  1247.                                                                                                 $netlist 2> $tempfilefiledevice
  1248.                                                         retvalfiledevice=$?

  1249.                                                         choicefiledevice=`cat $tempfilefiledevice`

  1250.                                                         case $retvalfiledevice in
  1251.                                                         $DIALOG_OK)

  1252.                                                                 filedevice=$choicefiledevice
  1253.                                                         ;;

  1254.                                                         $DIALOG_CANCEL)
  1255.                                                         ;;

  1256.                                                         $DIALOG_ESC)
  1257.                                                         ;;
  1258.                                                         esac
  1259.                                                         ;;

  1260.                                                 "Config device")
  1261.                                                         $DIALOG --backtitle "$backtitle" \
  1262.                                                                         --title "CONFIG DEVICE" --clear \
  1263.                                                                         --inputbox "Set IP Address to match your subnet. \
  1264.                                                                                 \nExample: 192.168.0.5 \
  1265.                                                                                 \n\nEnter IP Address:" 0 0 2> $tempfilefileip

  1266.                                                         retvalfileip=$?
  1267.                                                         case $retvalfileip in
  1268.                                                         $DIALOG_OK)

  1269.                                                                 fileipaddress=`cat $tempfilefileip`
  1270.                                                                 /sbin/ifconfig $filedevice $fileipaddress up
  1271.                                                         ;;

  1272.                                                         $DIALOG_CANCEL)
  1273.                                                         ;;

  1274.                                                         $DIALOG_ESC)
  1275.                                                                 if test -s $tempfilefileip ; then
  1276.                                                                         fileipaddress=`cat $tempfilefileip`
  1277.                                                                         /sbin/ifconfig $filedevice $fileipaddress up
  1278.                                                                 fi
  1279.                                                                 ;;
  1280.                                                         esac
  1281.                                                         ;;


  1282.                                                 "Select partition")
  1283.                                                         $DIALOG --backtitle "$backtitle" \
  1284.                                                                         --title "SELECT PARTITION" \
  1285.                                                                         --radiolist "Choose drive to mount.\
  1286.                                                                                                 \nThe selected drive will be mounted to /mnt/local
  1287.                                                                                                 \nand partimage may write to this directory.\n
  1288.                                                                                                 \nSupported FS are:\n\
  1289.                                                                                                 ext2 - Linux\n\
  1290.                                                                                                 ext3 - Linux\n\
  1291.                                                                                                 reiserfs - Linux\n\
  1292.                                                                                                 fat32 - Windows95/98/NT/2k/XP\n\
  1293.                                                                                                 ntfs - Windows NT/2k/XP\n\
  1294.                                                                                                 JFS and XFS\
  1295.                                                                                                 \n\nSelect partition(!) (example: /dev/hda1):" 0 0 0 \
  1296.                                                                                                 $partlist 2> $tempfilefilepart

  1297.                                                         retvalfilepart=$?

  1298.                                                         choicefilepart=`cat $tempfilefilepart`
  1299.                                                         case $retvalfilepart in
  1300.                                                         $DIALOG_OK)

  1301.                                                                 filepart=$choicefilepart
  1302.                                                                 mount /dev/$filepart /mnt/local >/tmp/filemount 2>&1
  1303.                                                                 retvalfilemount=$?

  1304.                                                                 if [ $retvalfilemount != 0 ] ; then
  1305.                                                                         $DIALOG --backtitle "$backtitle" \
  1306.                                                                                         --title "ERROR" \
  1307.                                                                                         --textbox /tmp/filemount 0 0
  1308.                                                                         filepart=""
  1309.                                                                         umount /mnt/local
  1310.                                                                 else
  1311.                                                                         $DIALOG --backtitle "$backtitle" \
  1312.                                                                                         --title "STATUS" \
  1313.                                                                                         --msgbox "Partition mounted in /mnt/local. \
  1314.                                                                                                         \nYou can now launch partimage to create or restore an image.\
  1315.                                                                                                         \nAs target file enter a filename in /mnt/local/, \
  1316.                                                                                                         \nfor example: /mnt/local/backup_hda1.img.gz \
  1317.                                                                                                         \n\n \
  1318.                                                                                                         \nYou can also launch partimage in network mode." 10 50

  1319.                                                                 fi
  1320.                                                         ;;

  1321.                                                         $DIALOG_CANCEL)
  1322.                                                         ;;

  1323.                                                         $DIALOG_ESC)
  1324.                                                         ;;

  1325.                                                         esac
  1326.                                                         ;;
  1327.                                                 "Launch client")
  1328.                                                         clear
  1329.                                                         partimage -f3
  1330.                                                         umount /mnt/local
  1331.                                                         ;;

  1332.                                                 "Launch server")
  1333.                                                         $DIALOG --backtitle "$backtitle" \
  1334.                                                                         --title "INFO" \
  1335.                                                                         --msgbox "'partimage' server will be launched now. \
  1336.                                                                                         \nAfter it started, remove the CD and use it \
  1337.                                                                                         \nto launch the 'partimage' client on another machine." 10 50

  1338.                                                         clear
  1339.                                                         partimaged
  1340.                                                         umount /mnt/local

  1341.                                                 esac
  1342.                                                 ;;
  1343.                                         esac

  1344.                                 done
  1345.                                 ;;

  1346.                         "Utilities")

  1347.                                 while [ "$retvalutilmenu" != "1" ]
  1348.                                 do
  1349.                                         $DIALOG --clear --backtitle "$backtitle" \
  1350.                                                         --title "UTILITIES" \
  1351.                                                         --menu "Choose one of the following options: \n\n" 0 0 0 \
  1352.                                                                 "System info"  "Show drives, partitions and models" \
  1353.                                                                 "hdparm"  "Set 32-bit I/O and UDMA66 (NEW hardware only!)" \
  1354.                                                                 "Zero-Tool"  "Zero-out free space on a partition" \
  1355.                                                                 "dd_rescue"  "Rescue defective drive and clone to new one" \
  1356.                                                                 "Parted"  "Launch 'parted' partition manager (EXPERT USE!)" 2> $tempfileutilmenu

  1357.                                         retvalutilmenu=$?

  1358.                                         choiceutilmenu=`cat $tempfileutilmenu`

  1359.                                         case $retvalutilmenu in
  1360.                                         $DIALOG_OK)

  1361.                                                 case $choiceutilmenu in
  1362.                                                 "System info")

  1363.                                                         $DIALOG --backtitle "$backtitle" \
  1364.                                                                         --title "SYSTEM INFO" \
  1365.                                                                         --textbox /tmp/sysinfo 20 35
  1366.                                                 ;;


  1367.                                                 "hdparm")
  1368.                                                         $DIALOG --backtitle "$backtitle" \
  1369.                                                                 --title "WARNING" --clear \
  1370.                                                                         --yesno "This option tries to enable 32-bit I/O mode \
  1371.                                                                         \nand UDMA/66 mode on your IDE Controller and drive. \
  1372.                                                                         \n \
  1373.                                                                         \nThe system might hang and require a reboot! \
  1374.                                                                         \nUse this option only on quite new computers! \
  1375.                                                                         \n \
  1376.                                                                         \nContinue at own risk?" 0 0

  1377.                                                         case $? in
  1378.                                                         $DIALOG_OK)

  1379.                                                                 $DIALOG --backtitle "$backtitle" \
  1380.                                                                                 --title "HDPARM" \
  1381.                                                                                 --radiolist "Choose drive(!) to enable.\
  1382.                                                                                                         \n\nExample: /dev/hda" 0 0 0 $partlist 2> $tempfilehdparm

  1383.                                                                 retvalhdparm=$?

  1384.                                                                 choicehdparm=`cat $tempfilehdparm`
  1385.                                                                 case $retvalhdparm in
  1386.                                                                 $DIALOG_OK)

  1387.                                                                         hdparmdrive=/dev/$choicehdparm
  1388.                                                                         hdparm -c3 -X66 $hdparmdrive >/tmp/hdparmout

  1389.                                                                         $DIALOG --backtitle "$backtitle" \
  1390.                                                                                         --title "HDPARM OUTPUT" \
  1391.                                                                                         --textbox /tmp/hdparmout 0 0


  1392.                                                                 ;;

  1393.                                                                 $DIALOG_CANCEL)
  1394.                                                                 ;;

  1395.                                                                 $DIALOG_ESC)
  1396.                                                                 ;;

  1397.                                                                 esac
  1398.                                                                 ;;

  1399.                                                         $DIALOG_CANCEL)
  1400.                                                         ;;

  1401.                                                         $DIALOG_ESC)
  1402.                                                         ;;
  1403.                                                         esac
  1404.                                                         ;;

  1405.                                                 "Zero-Tool")

  1406.                                                         $DIALOG --backtitle "$backtitle" \
  1407.                                                                         --title "ZERO-TOOL" \
  1408.                                                                         --radiolist "Choose drive to zero-out.\
  1409.                                                                                                 \nSupported FS are:\n\
  1410.                                                                                                 ext2 - Linux\n\
  1411.                                                                                                 ext3 - Linux\n\
  1412.                                                                                                 reiserfs - Linux\n\
  1413.                                                                                                 fat32 - Windows95/98/NT/2k/XP\n\
  1414.                                                                                                 ntfs - Windows NT/2k/XP\
  1415.                                                                                                 \n\nSelect partition (example: /dev/hda1):" 0 0 0 \
  1416.                                                                         $partlist 2> $tempfileutilzero

  1417.                                                         retvalutilzero=$?

  1418.                                                         choiceutilzero=`cat $tempfileutilzero`
  1419.                                                         case $retvalutilzero in
  1420.                                                         $DIALOG_OK)

  1421.                                                                 zerodrive=$choiceutilzero
  1422.                                                                 mount /dev/$zerodrive /mnt/local >/tmp/zeromount 2>&1
  1423.                                                                 retvalzeromount=$?

  1424.                                                                 if [ $retvalzeromount != 0 ] ; then
  1425.                                                                         $DIALOG --backtitle "$backtitle" \
  1426.                                                                                         --title "ERROR" \
  1427.                                                                                         --textbox /tmp/zeromount 0 0
  1428.                                                                         zerodrive=""
  1429.                                                                         umount /mnt/local

  1430.                                                                 else

  1431.                                                                         freesize=`df |grep -w $zerodrive |awk '{print $4}'`
  1432.                                                                         pcnt=0

  1433.                                                                         (dd if=/dev/zero 2>/dev/null |jetcat-mod -p $freesize 2>/tmp/zero.out |split -b 2000m - /mnt/local/zerofile. 2>/dev/null ) &

  1434.                                                                         (
  1435.                                                                         while test "$pcnt" != "100"
  1436.                                                                         do
  1437.                                                                                 pcnt=`tail -n1 /tmp/zero.out`
  1438.                                                                                 echo "XXX"
  1439.                                                                                 echo $pcnt
  1440.                                                                                 echo "\n"
  1441.                                                                                 echo "Zero-Tool is creating 2GB large files containing\n"
  1442.                                                                                 echo "only zeros. If the harddrive is full, the files will\n"
  1443.                                                                                 echo "be deleted and the drive will be unmount.\n"
  1444.                                                                                 echo "This allows a very good compression of the unused\n"
  1445.                                                                                 echo "space between your files.\n\n"
  1446.                                                                                 echo "Please stand by, this might take some time!\n"
  1447.                                                                                 echo "XXX"
  1448.                                                                                 sleep 3
  1449.                                                                         done
  1450.                                                                         ) | $DIALOG --backtitle "$backtitle" \
  1451.                                                                                                 --title "Working..." \
  1452.                                                                                                 --gauge "One moment..." 18 60
  1453.                                                                 fi

  1454.                                                                 rm /mnt/local/zerofile.*
  1455.                                                                 umount /mnt/local
  1456.                                                                 rm /tmp/zero.out
  1457.                                                                 touch /tmp/zero.out

  1458.                                                         ;;

  1459.                                                         $DIALOG_CANCEL)
  1460.                                                         ;;

  1461.                                                         $DIALOG_ESC)
  1462.                                                         ;;

  1463.                                                         esac
  1464.                                                         ;;

  1465.                                                 "dd_rescue")
  1466.                                                         while [ "$retvalddres" != "1" ]
  1467.                                                         do
  1468.                                                                 $DIALOG --clear --backtitle "$backtitle" \
  1469.                                                                                 --title "DD_RECSCUE" \
  1470.                                                                                 --menu "Choose one of the following options: \n\n" 0 0 0 \
  1471.                                                                                                 "Select source"  "Select (defective) source drive" \
  1472.                                                                                                 "Select target"  "Select (new/clean) target drive" \
  1473.                                                                                                 "Rescue"  "Rescue the drive now!" 2> $tempfileddres

  1474.                                                                 retvalddres=$?

  1475.                                                                 choiceddres=`cat $tempfileddres`

  1476.                                                                 case $retvalddres in
  1477.                                                                 $DIALOG_OK)

  1478.                                                                         case $choiceddres in
  1479.                                                                         "Select source")

  1480.                                                                                 $DIALOG --backtitle "$backtitle" \
  1481.                                                                                                 --title "SELECT SOURCE" \
  1482.                                                                                                 --radiolist "Choose (defective) source drive to clone.\n\
  1483.                                                                                                                         Select from:" 0 0 0 \
  1484.                                                                                                                         $partlist 2> $tempfileddressource

  1485.                                                                                 retvalddressource=$?

  1486.                                                                                 choiceddressource=`cat $tempfileddressource`
  1487.                                                                                 case $retvalddressource in
  1488.                                                                                 $DIALOG_OK)

  1489.                                                                                         ddressource=/dev/$choiceddressource
  1490.                                                                                 ;;

  1491.                                                                                 $DIALOG_CANCEL)
  1492.                                                                                 ;;

  1493.                                                                                 $DIALOG_ESC)
  1494.                                                                                 ;;

  1495.                                                                                 esac
  1496.                                                                                 ;;

  1497.                                                                         "Select target")
  1498.                                                                                 $DIALOG --backtitle "$backtitle" \
  1499.                                                                                                 --title "SELECT TARGET" \
  1500.                                                                                                 --radiolist "Choose (new/clean) target drive to clone to.\n\
  1501.                                                                                                                         Attention: Select a drive with at least\n\
  1502.                                                                                                                         the same capacity. Higher capacity is OK.\n\
  1503.                                                                                                                         Select from:" 0 0 0 \
  1504.                                                                                                                         $partlist 2> $tempfileddrestarget


  1505.                                                                                 retvalddrestarget=$?

  1506.                                                                                 choiceddrestarget=`cat $tempfileddrestarget`
  1507.                                                                                 case $retvalddrestarget in
  1508.                                                                                 $DIALOG_OK)

  1509.                                                                                         ddrestarget=/dev/$choiceddrestarget
  1510.                                                                                 ;;

  1511.                                                                                 $DIALOG_CANCEL)
  1512.                                                                                 ;;

  1513.                                                                                 $DIALOG_ESC)
  1514.                                                                                 ;;

  1515.                                                                                 esac
  1516.                                                                                 ;;


  1517.                                                                         "Rescue")
  1518.                                                                                 if [ "$ddressource" = "" ] ; then

  1519.                                                                                         $DIALOG --backtitle "$backtitle" \
  1520.                                                                                                         --title "ERROR" --clear \
  1521.                                                                                                         --msgbox "No source drive to rescue set! \n
  1522.                                                                                                                         ->Back to Main Menu." 0 0
  1523.                                                                                         continue
  1524.                                                                                 fi

  1525.                                                                                 if [ "$ddrestarget" = "" ] ; then

  1526.                                                                                         $DIALOG --backtitle "$backtitle" \
  1527.                                                                                                         --title "ERROR" --clear \
  1528.                                                                                                         --msgbox "No target drive for rescue set! \n
  1529.                                                                                                                         ->Back to Main Menu." 0 0
  1530.                                                                                         continue
  1531.                                                                                 fi

  1532.                                                                                 $DIALOG --backtitle "$backtitle" \
  1533.                                                                                                 --title "ABOUT TO RESCUE" --clear \
  1534.                                                                                                 --yesno "Collected information: \
  1535.                                                                                                                 \nDefective source drive: $ddressource \
  1536.                                                                                                                 \nNew/Clean target drive: $ddrestarget \
  1537.                                                                                                                 \n\
  1538.                                                                                                                 \nIt might take VERY long to rescue the drive, \
  1539.                                                                                                                 \nbut as long as you do NOT reboot, you can press \
  1540.                                                                                                                 \nCTRL-C at any time and dd_rhelp will continue \
  1541.                                                                                                                 \nfrom the same position it stopped if you re-enter \
  1542.                                                                                                                 \nthis menu. If dd_rhelp is almost done and is only \
  1543.                                                                                                                 \ntrying to read the defective sectors, it is OK to CTRL-C. \
  1544.                                                                                                                 \n\
  1545.                                                                                                                 \n\nAre you sure?" 0 0
  1546.                                                                                 case $? in
  1547.                                                                                 $DIALOG_OK)
  1548.                                                                                         clear
  1549.                                                                                         dd_rhelp $ddressource $ddrestarget
  1550.                                                                                 ;;

  1551.                                                                                 $DIALOG_CANCEL)
  1552.                                                                                 ;;

  1553.                                                                                 $DIALOG_ESC)
  1554.                                                                                 ;;
  1555.                                                                                 esac
  1556.                                                                                 ;;
  1557.                                                                         esac
  1558.                                                                         ;;

  1559.                                                                 $DIALOG_CANCEL)
  1560.                                                                 ;;

  1561.                                                                 $DIALOG_ESC)
  1562.                                                                 ;;

  1563.                                                                 esac
  1564.                                                         done
  1565.                                                 ;;

  1566.                                                 "Parted")

  1567.                                                         clear
  1568.                                                         parted
  1569.                                                 ;;

  1570.                                                 esac
  1571.                                                 ;;


  1572.                                         $DIALOG_CANCEL)
  1573.                                         ;;

  1574.                                         $DIALOG_ESC)
  1575.                                         ;;

  1576.                                         esac
  1577.                                 done
  1578.                                 ;;


  1579.                         "Show Help")
  1580.                                 $DIALOG --clear --backtitle "$backtitle" \
  1581.                                                 --title "HELP" \
  1582.                                                 --textbox ./help 20 70
  1583.                         ;;

  1584.                         esac
  1585.                         ;;

  1586.                         $DIALOG_CANCEL)
  1587.                                 echo "Thanks for using g4l. visit $website"
  1588.                                 rm /tmp/*
  1589.                                 touch /tmp/out
  1590.                                 touch /tmp/zeroout
  1591.                         ;;

  1592.                         $DIALOG_ESC)
  1593.                                 echo "ESC pressed."
  1594.                         ;;


  1595.                 esac

  1596.         done
  1597.         ;;
  1598. $DIALOG_CANCEL)
  1599.         exit 0
  1600. ;;

  1601. $DIALOG_ESC)
  1602.         exit 0
  1603. ;;

  1604. esac

复制代码
 楼主| 发表于 2005-7-14 23:07:38 | 显示全部楼层
附件放不上来.
不知道把DIALOG=dialog改成DIALOG=xdialog会不会爽一点?
回复 支持 反对

使用道具 举报

发表于 2005-7-14 23:47:44 | 显示全部楼层
好东西。。先预留一份下来。
回复 支持 反对

使用道具 举报

发表于 2005-7-15 09:22:08 | 显示全部楼层
好东东,现保存~ 慢慢看
回复 支持 反对

使用道具 举报

发表于 2005-7-15 10:18:10 | 显示全部楼层
虽然不知道GHOST是什么东东,好像是WIN下用来恢复操作系统的吧?LINUX也能用它来恢复?

大家都说好,那顺应民意,加精了.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-7-15 11:22:47 | 显示全部楼层
我想应该是学习他的脚本.和网络文件操作
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表