sync.sh 848 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. # @Author: Bachir Soussi Chiadmi <bach>
  3. # @Date: 26-03-2017
  4. # @Email: bachir@figureslibres.io
  5. # @Last modified by: bach
  6. # @Last modified time: 21-04-2017
  7. # @License: GPL-V3
  8. echo "Sync books"
  9. # activate credential cache
  10. git config --global credential.helper cache
  11. git config --global credential.helper 'cache --timeout=7200'
  12. folder='book-src'
  13. host='https://figureslibres.io/gogs/bachir'
  14. # echo "$host"
  15. repos[0]='TDSM-oeuvres'
  16. repos[1]='TDSM-notices'
  17. repos[2]='TDSM-commissaires'
  18. repos[3]='TDSM-english'
  19. # echo $repos
  20. for repo in "${repos[@]}"
  21. do
  22. echo ${repo}
  23. if [ -d $folder/$repo.git ];
  24. then
  25. # if repos exists, pull
  26. echo "Pull $repo"
  27. git -C $folder/$repo.git pull origin master
  28. else
  29. # if repos does not exists, clone
  30. echo "clone $repo"
  31. git clone $host/$repo.git $folder/$repo.git
  32. fi
  33. done