Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #given 192.168.2.8 is the server
- #I had to use sftp instead of rsync for the actual sync because of zenity
- #zenity is a easy gui app, just a progressbar
- zenity --info --text="user $USER, home $HOME"
- if [ -e $HOME/.awkdump ]
- then
- rm $HOME/.awkdump
- fi
- if [ -e $HOME/.sftpbach ]
- then
- rm $HOME/.sftpbach
- fi
- if [ "$1" = "out" ]
- then
- rsync --rsh=ssh -aizuln --exclude-from=/home/rsync.txt $HOME/ 192.168.2.8:$HOME/|awk -f /home/rsync.awk>$HOME/.awkdump
- elif [ "$1" = "in" ]
- then
- rsync --rsh=ssh -aizuln --exclude-from=/home/rsync.txt $USER@192.168.2.8:$HOME/ $HOME/|awk -f /home/rsync.awk>$HOME/.awkdump
- else
- zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
- exit
- fi
- echo "cd /home/dummy">$HOME/.sftpbach
- echo "lcd /home/dummy">>$HOME/.sftpbach
- i=0
- cat $HOME/.awkdump|while read a
- do
- if [ ! "$a" = "./" ]
- then
- if [ -e "$a" ]
- then
- if [ ${a: -1} = "/" ]
- then
- i=$(($i+1))
- else
- i=$(($i+1))
- fi
- fi
- fi
- echo $i>$HOME/num
- done
- rm $HOME/.sftpbach
- echo "cd /home/dummy">$HOME/.sftpbach
- echo "lcd /home/dummy">>$HOME/.sftpbach
- run=1
- per=`cat $HOME/num`
- rm num
- cat $HOME/.awkdump|while read a
- do
- num=$((100* $run/$per))
- if [ ! "$a" = "./" ]
- then
- if [ -e "$a" ]
- then
- if [ ${a: -1} = "/" ]
- then
- if [ "$1" = "out" ]
- then
- echo "!echo \"#mkdir $a\"">>$HOME/.sftpbach
- echo "!echo $num">>$HOME/.sftpbach
- echo "-mkdir $a">>$HOME/.sftpbach
- elif [ "$1" = "in" ]
- then
- echo "!echo \"#lmkdir $a\"">>$HOME/.sftpbach
- echo "!echo $num">>$HOME/.sftpbach
- echo "-lmkdir $a">>$HOME/.sftpbach
- else
- zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
- exit
- fi
- run=$(($run+1))
- else
- if [ "$1" = "out" ]
- then
- echo "!echo \"#put $a\"">>$HOME/.sftpbach
- echo "!echo $num">>$HOME/.sftpbach
- echo "-put $a $a">>$HOME/.sftpbach
- elif [ "$1" = "in" ]
- then
- echo "!echo \"#get $a\"">>$HOME/.sftpbach
- echo "!echo $num">>$HOME/.sftpbach
- echo "-get $a $a">>$HOME/.sftpbach
- else
- zenity --error --title="Sync" --text="`printf "Error: There is something wrong with the sync program\nPlease contact the Network Administrator"`"
- exit
- fi
- run=$(($run+1))
- fi
- fi
- fi
- done
- 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
- if [ -e $HOME/.sftpbach ]
- then
- rm $HOME/.sftpbach
- fi
- if [ -e $HOME/.awkdump ]
- then
- rm $HOME/.awkdump
- fi
- zenity --info --title="Syncronization" --text="Syncronization Complete" --timeout=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement