Browse Source

Merge branch 'add-gitmessage' of gin4RRI/gin-scripts into master

julien colomb 3 years ago
parent
commit
de96933086

+ 12 - 12
README.md

@@ -2,18 +2,6 @@
 
 Scripts for working with GIN server using the GIN client.
 
-# TONIC development
-After working on bash script to create new repositories and submodules, for example with: 
-
-```
-sh create_researchrepo organisation projectname projectteam 
-projectteam is optional
-
-example:
-sh create_researchrepo gin4rri testproject testproject 
-```
-We are working on TONIC, an application that will expand GIN functionalities to create research organisation and research repositories from templates. The documentation is visible in [tonic-PLAN](tonic-PLAN.md)
-
 
 # Bash script for Linux and macOS
 
@@ -43,3 +31,15 @@ _**Note**: This script has not been fully tested yet_
 # Old scripts
 
 The [old](./old) directory contains old upload scripts that were written while testing different use cases.  They shouldn't be used in their current state, but they may be useful for the future.
+
+# deprecated: TONIC development
+After working on bash script to create new repositories and submodules, for example with: 
+
+```
+sh create_researchrepo organisation projectname projectteam 
+projectteam is optional
+
+example:
+sh create_researchrepo gin4rri testproject testproject 
+```
+We are working on TONIC, an application that will expand GIN functionalities to create research organisation and research repositories from templates. The documentation is visible in [tonic-PLAN](tonic-PLAN.md)

+ 11 - 0
initiation_scripts/SFB1315-portal-initialisation.bat

@@ -0,0 +1,11 @@
+
+:: this script set gin to work with SFB1315 data portal GIN-Tonic instance.
+
+:: add server, named hu
+gin add-server --web https://gindata.biologie.hu-berlin.de:443 --git git@gindata.biologie.hu-berlin.de:10022 hu
+
+:: chose hu server for this computer
+gin use-server hu
+
+:: login to the data portal
+gin login

+ 11 - 0
initiation_scripts/SFB1315-portal-initialisation.command

@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+# this script set gin to work with SFB1315 data portal GIN-Tonic instance.
+
+# add server, named hu
+gin add-server --web https://gindata.biologie.hu-berlin.de:443 --git git@gindata.biologie.hu-berlin.de:10022 hu
+
+# chose hu server for this computer
+gin use-server hu
+
+# login to the data portal
+gin login

+ 81 - 12
sync

@@ -4,16 +4,58 @@
 # Works with submodules.
 # Assumes gin init was performed or the repository was downloaded via gin get
 
-if (( $# > 0 )); then
-    echo "This script takes no arguments"
+
+usage() {
+    echo "$0 <sync-option>"
+    echo
+    echo "<sync-option>     The sync option defines what to do with the content of large files."
+    echo "                  It should be one of the following values:"
+    echo "                     download - Download all large file content from the server"
+    echo "                     keep     - Keep all large file content but do not download missing large files"
+    echo "                     remove   - Do not download large files and remove existing local large file content"
     exit 1
+}
+
+
+
+syncopt="remove"
+
+echo "Optionally enter a commit message, and hit return: "  
+read commitmessage 
+
+if [[ "$commitmessage" == "" ]]; then
+        echo "using date as commit message"
+	commitmessage="commit on $(date +%Y-%m-%d)"    
 fi
 
+
+
+
+checkargs() {
+    case "$1" in
+        download)
+            echo "Downloading and keep all large file content"
+            ;;
+        keep)
+            echo "Keeping existing local large file content, do not downlad extra files"
+            ;;
+        remove)
+            echo "Removing all local large file content"
+            ;;
+        *)
+            usage
+            ;;
+    esac
+}
+
+checkargs "${syncopt}"
+
 checkerror() {
     err=$1
     msg=$2
     if [[ ${err} != 0 ]]; then
-        echo "${msg}" >> ./log/gin.log
+        echo "${msg}" >> ./.log/gin.log
+	echo "${err}" >> ./.log/gin.log
         echo "${msg}"
         echo "Press [Enter] to close this window"
         read -r
@@ -21,22 +63,49 @@ checkerror() {
     fi
 }
 
-mkdir -p ./log
-echo "$(date -Iseconds): Sync script executed" >> ./log/gin.log
+loc=$(dirname $0)
+projectdir=$(git -C ${loc} rev-parse --show-toplevel)
+
+pushd ${loc} > /dev/null
+
+mkdir -p ./.log
+echo "$(date +'%Y-%m-%dT%H:%M:%S'): Sync script executed" >> ./.log/gin.log
+
+echo "intialise submodules"
+git submodule foreach gin init
 
 echo "Synchronising submodules"
+git submodule foreach gin commit . -m "$commitmessage"
+checkerror $? "Error occurred during 'gin commit'"
 git submodule foreach gin sync
 checkerror $? "Error occurred during 'gin sync'"
-git submodule foreach gin commit .
-checkerror $? "Error occurred during 'gin commit'"
+
 git submodule foreach gin upload
 checkerror $? "Error occurred during 'gin upload'"
+## remove uploaded (annexed) content
+if [[ "$syncopt" == "remove" ]]; then
+        git submodule foreach gin remove-content 
+        checkerror $? "Error occurred during 'gin remove-content'"
+    fi
+# get annexed content 
+if [[ "${syncopt}" == "download" ]]; then
+        git submodule foreach gin get-content .
+        checkerror $? "Error occurred during 'gin get-content .'"
+    fi    
+
 
 echo "Synchronising main repository"
+
+gin commit . -m "$commitmessage"
 gin sync
-gin commit .
 gin upload
-
-# Uncomment the two lines below to download all large files
-# gin get-content .
-# checkerror $? "Error occurred during 'gin get-content'"
+# remove uploaded (annexed) content
+if [[ "$syncopt" == "remove" ]]; then
+        gin remove-content 
+        checkerror $? "Error occurred during 'gin remove-content' in main repo"
+    fi
+# get annexed content 
+if [[ "${syncopt}" == "download" ]]; then
+        gin get-content .
+        checkerror $? "Error occurred during 'gin get-content . in main repo'"
+    fi