Advertisement
Guest User

acovrig

a guest
Jun 16th, 2010
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.61 KB | None | 0 0
  1. #!/bin/bash
  2. #given 192.168.2.8 is the server
  3. #I had to use sftp instead of rsync for the actual sync because of zenity
  4. #zenity is a easy gui app, just a progressbar
  5. zenity --info --text="user $USER, home $HOME"
  6. if [ -e $HOME/.awkdump ]
  7. then
  8. rm $HOME/.awkdump
  9. fi
  10. if [ -e $HOME/.sftpbach ]
  11. then
  12. rm $HOME/.sftpbach
  13. fi
  14. if [ "$1" = "out" ]
  15. then
  16. rsync --rsh=ssh -aizuln --exclude-from=/home/rsync.txt $HOME/ 192.168.2.8:$HOME/|awk -f /home/rsync.awk>$HOME/.awkdump
  17. elif [ "$1" = "in" ]
  18. then
  19. rsync --rsh=ssh -aizuln --exclude-from=/home/rsync.txt $USER@192.168.2.8:$HOME/ $HOME/|awk -f /home/rsync.awk>$HOME/.awkdump
  20. else
  21. zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
  22. exit
  23. fi
  24. echo "cd /home/dummy">$HOME/.sftpbach
  25. echo "lcd /home/dummy">>$HOME/.sftpbach
  26. i=0
  27. cat $HOME/.awkdump|while read a
  28. do
  29. if [ ! "$a" = "./" ]
  30. then
  31. if [ -e "$a" ]
  32. then
  33. if [ ${a: -1} = "/" ]
  34. then
  35. i=$(($i+1))
  36. else
  37. i=$(($i+1))
  38. fi
  39. fi
  40. fi
  41. echo $i>$HOME/num
  42. done
  43. rm $HOME/.sftpbach
  44. echo "cd /home/dummy">$HOME/.sftpbach
  45. echo "lcd /home/dummy">>$HOME/.sftpbach
  46. run=1
  47. per=`cat $HOME/num`
  48. rm num
  49. cat $HOME/.awkdump|while read a
  50. do
  51. num=$((100* $run/$per))
  52. if [ ! "$a" = "./" ]
  53. then
  54. if [ -e "$a" ]
  55. then
  56. if [ ${a: -1} = "/" ]
  57. then
  58. if [ "$1" = "out" ]
  59. then
  60. echo "!echo \"#mkdir $a\"">>$HOME/.sftpbach
  61. echo "!echo $num">>$HOME/.sftpbach
  62. echo "-mkdir $a">>$HOME/.sftpbach
  63. elif [ "$1" = "in" ]
  64. then
  65. echo "!echo \"#lmkdir $a\"">>$HOME/.sftpbach
  66. echo "!echo $num">>$HOME/.sftpbach
  67. echo "-lmkdir $a">>$HOME/.sftpbach
  68. else
  69. zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
  70. exit
  71. fi
  72. run=$(($run+1))
  73. else
  74. if [ "$1" = "out" ]
  75. then
  76. echo "!echo \"#put $a\"">>$HOME/.sftpbach
  77. echo "!echo $num">>$HOME/.sftpbach
  78. echo "-put $a $a">>$HOME/.sftpbach
  79. elif [ "$1" = "in" ]
  80. then
  81. echo "!echo \"#get $a\"">>$HOME/.sftpbach
  82. echo "!echo $num">>$HOME/.sftpbach
  83. echo "-get $a $a">>$HOME/.sftpbach
  84. else
  85. zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
  86. exit
  87. fi
  88. run=$(($run+1))
  89. fi
  90. fi
  91. fi
  92. done
  93. sftp -oIdentifyFile=$HOME/.ssh/id_rsa.pub -b $HOME/.sftpbach -C $USER@192.168.2.8|zenity --progress --title="Synchronizing $USER" --text="Preparing, please waint" --auto-close
  94. if [ -e $HOME/.sftpbach ]
  95. then
  96. rm $HOME/.sftpbach
  97. fi
  98. if [ -e $HOME/.awkdump ]
  99. then
  100. rm $HOME/.awkdump
  101. fi
  102. zenity --info --title="Syncronization" --text="Syncronization Complete" --timeout=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement