INIT-sync 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env bash
  2. #
  3. # Initialise or Upload changes from inside repository
  4. # using GIN CLI
  5. # Works with submodules and repo made by tonic v1 (not copying submodules content).
  6. # needs git config to be set
  7. # needs SSH access to GIN
  8. # future dvt using datalad will allow use of non-GIN repositories
  9. # logic: template has a specific file to label it needs initialisation.
  10. # if this file is present, code 1 is done: template_initialisation
  11. # if it is absent but submodules are empty, code 2 is done: submodule_initialisation
  12. # if none of the above code 3 is done: synchronisation
  13. # Set folder where script will be executed
  14. loc=$(dirname $0)
  15. projectdir=$(git -C ${loc} rev-parse --show-toplevel)
  16. pushd ${loc} > /dev/null
  17. ## set gin server and remote
  18. sh .scripts/setginserver
  19. #login if needed
  20. if ! gin info; then
  21. echo "set gin login"
  22. gin login
  23. else
  24. echo "gin logged"
  25. fi
  26. ## code 1
  27. if test -f "00repo_needs_initialisation00.txt" ;
  28. then
  29. echo "running project repository initiation (first run)"
  30. sh .scripts/template_init.command
  31. fi
  32. ## code 2
  33. if grep -q 06_dissemination ".gitmodules";
  34. then
  35. if (test -f "06_dissemination/README_DISSEMINATION.md") ;
  36. then
  37. echo "submodules are initialised"
  38. else
  39. echo "initialising submodules"
  40. gin git submodule update --init --recursive
  41. gin git submodule foreach gin init
  42. fi
  43. else
  44. echo "not a tonic repo, please initialise submodules manually if there are any"
  45. fi
  46. ## code 3
  47. usage() {
  48. echo "$0 <sync-option>"
  49. echo
  50. echo "<sync-option> The sync option defines what to do with the content of large files."
  51. echo " It should be one of the following values:"
  52. echo " download - Download all large file content from the server"
  53. echo " keep - Keep all large file content but do not download missing large files"
  54. echo " remove - Do not download large files and remove existing local large file content"
  55. exit 1
  56. }
  57. # Set the variable for synchronisation option, see above
  58. syncopt="remove"
  59. echo "start synchronisation in "$syncopt" mode, close window to cancel. change mode by changing the code in a text application"
  60. sh .scripts/GIN-SYNC