Local-Network-SyncR2.sh 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/bash
  2. ###########################################################################################
  3. ##
  4. ## This script utilizes git to sync eclipse workspaces
  5. ##
  6. ## TO DO:
  7. ##
  8. ## - eliminate need for the 2 different workspace directories
  9. ## - let usage occur when incorrect parameter is passed
  10. ##
  11. ##
  12. ##
  13. ##
  14. ##
  15. ##
  16. ##
  17. ###########################################################################################
  18. [[ $# -eq 0 ]] && { # execute this if no parameters are passed
  19. echo "Usage: $0 [ options ]"
  20. echo
  21. echo "options: "
  22. echo "-s, --sync sync client to host"
  23. echo "-p, --pull retrieve data from host"
  24. echo "-nd, --new-destination retrieve data to temporary destination"
  25. exit 0;
  26. }
  27. # The snippet below executes when either -s or --sync are entered
  28. # it first copies everything from the client to the repository
  29. # git then adds, commits, and finally pushes changes to repository
  30. if [[ $1 == "-s" || $1 == "--sync" ]]; then
  31. echo "Syncing..."
  32. #\cp -fR $EWORKSPACE/* $ESYNCREPO
  33. cd $ESYNCREPO
  34. git add * # add everything potentially added to the repo
  35. git commit -a # create a commit so the host can house the data.
  36. git push # then finally, push the data ( requires login )
  37. if [[ $? -eq 0 ]]; then
  38. echo "Successfully Synced."
  39. else
  40. echo "There was an error while syncing."
  41. fi
  42. fi
  43. # The following snippet executes when -u or --update is entered
  44. # changes to repository, git pulls the repository, then copies over to
  45. # the client's workspace.
  46. if [[ $1 == "-u" || $1 == "--update" ]]; then
  47. echo "Updating..."
  48. cd $ESYNCREPO
  49. git pull # Pull everything from the host
  50. #\cp -fR $ESYNCREPO/* $EWORKSPACE
  51. if [[ $? -eq 0 ]]; then
  52. echo "Successfully Updated."
  53. else
  54. echo "There was an error while updating."
  55. fi
  56. fi