Advertisement
Guest User

Untitled

a guest
Jan 26th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.46 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. filepath=$1
  4. echo $file
  5.  
  6. #local hash
  7. hash_before=$(md5sum $file)
  8.  
  9. # upload to remote
  10. scp -i srvkey.pem  ${file} client.lan:/srv/client/
  11.  
  12. #remote hash
  13. hash_after = ssh client.lan 'mv /srv/client/${file} /srv/client/tmp.${file}'
  14.  
  15. #compare hashes
  16. if[hash_before == hash_after]
  17.   then
  18.     #rename remote
  19.     ssh client.lan 'mv /srv/client/${file} /srv/client/tmp.${file}'
  20.     #mv local to sent
  21.     mv $file /srv/sent
  22.   else
  23.     echo "kala"
  24. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement