SSH-INIT-SYNC 2.1 KB

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