SSH-INIT-SYNC 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. ## code 1
  18. if test -f "00repo_needs_initialisation00.txt" ;
  19. then
  20. echo "running project repository initiation (first run)"
  21. sh scripts/template_init.command
  22. fi
  23. ## code 2
  24. if (test -f "03_data/001_data/README_data.md") ;
  25. then
  26. echo "submodules are initialised"
  27. else
  28. echo "initialising submodules"
  29. git submodule update --init --recursive
  30. git submodule foreach gin init
  31. fi
  32. ## code 3
  33. usage() {
  34. echo "$0 <sync-option>"
  35. echo
  36. echo "<sync-option> The sync option defines what to do with the content of large files."
  37. echo " It should be one of the following values:"
  38. echo " download - Download all large file content from the server"
  39. echo " keep - Keep all large file content but do not download missing large files"
  40. echo " remove - Do not download large files and remove existing local large file content"
  41. exit 1
  42. }
  43. # Set the variable for synchronisation option, see above
  44. syncopt="remove"
  45. echo "start synchronisation in "$syncopt" mode, close window to cancel. change mode by changing the code in a text application"
  46. sh scripts/GIN-SYNC