Guest User

Untitled

a guest
Jul 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #/bin/bash
  2. Remote='domain:/var/www/htdocs/'
  3. Local='/Users/user/programming/websites/server-domain/'
  4.  
  5. function are_you_sure {
  6. read -p "Run this command (y/n)?"
  7. if [ "$REPLY" != "y" ]; then
  8. echo "Aborting."
  9. exit 1
  10. fi
  11. }
  12.  
  13. if [ "$#" = "2" ]; then
  14. if [ "$2" = "--no-check" ]; then
  15. echo "Skip run"
  16. DryRun=0
  17. else
  18. DryRun=1
  19. fi
  20. else
  21. DryRun=1
  22. fi
  23.  
  24. case "$1" in
  25. push)
  26. echo " Pushing files to remote server"
  27. if [ "$DryRun" = "1" ]; then
  28. echo "Executing dry run"
  29. rsync -azvn -e "ssh" --delete $Local $Remote
  30. are_you_sure
  31. fi
  32. rsync -azv -e "ssh" --delete $Local $Remote
  33. ;;
  34. pull)
  35. echo " Pulling files to remote server"
  36. if [ "$DryRun" = "1" ]; then
  37. echo "Executing dry run"
  38. rsync -azvn -e "ssh" --delete $Remote $Local
  39. are_you_sure
  40. fi
  41. rsync -azv -e "ssh" --delete $Remote $Local
  42. ;;
  43. *)
  44. echo "Commands: push, pull with --no-check as an option."
  45. ;;
  46. esac
Add Comment
Please, Sign In to add comment