diff --git a/bridgehead b/bridgehead index 395504a..a0ea5e8 100755 --- a/bridgehead +++ b/bridgehead @@ -176,6 +176,14 @@ case "$ACTION" in ;; postRun | postUpdate) ;; + send-file) + loadVars + log "WARNING" "Your are about to send a file to another bridgehead in your network!" + read -p "Please name the bridgehead you want to send the file to (proxy-id): " RECEIVER_PROXY_ID + read -p "Please type the path to the file you want to upload: " FILE_TO_SEND_PATH + read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 + curl -X POST -F "data=@$FILE_TO_SEND_PATH" -u ":${BEAM_FILE_API_KEY}" http://localhost:8085/send/$RECEIVER_PROXY_ID + ;; *) printUsage exit 1 diff --git a/dhki/vars b/dhki/vars index d043dd2..13b924e 100644 --- a/dhki/vars +++ b/dhki/vars @@ -25,4 +25,5 @@ do source $module done -transfairSetup \ No newline at end of file +transfairSetup +beamFileSetup diff --git a/modules/beam-file-compose.yml b/modules/beam-file-compose.yml new file mode 100644 index 0000000..084805b --- /dev/null +++ b/modules/beam-file-compose.yml @@ -0,0 +1,32 @@ +# NOTE: Current implementation is restricted to a bridgehead only being able to either upload or download data +services: + beam-file-sender: + image: samply/beam-file:${BEAM_FILE_TAG} + container_name: bridgehead-beam-file-sender + environment: + - BEAM_ID=beamfile.${PROXY_ID} + - BEAM_SECRET=${BEAM_FILE_SECRET} + - BEAM_URL=http://beam-proxy:8081 + - BIND_ADDR=0.0.0.0:8085 + - API_KEY=${BEAM_FILE_API_KEY} + # Only uncomment if your are sure what to do + # ports: + # - 8085:8085 + profiles: ["beam-file-sender"] + + beam-file-receiver: + image: samply/beam-file:${BEAM_FILE_TAG} + container_name: bridgehead-beam-file-receiver + environment: + - BEAM_ID=beamfile.${PROXY_ID} + - BEAM_SECRET=${BEAM_FILE_SECRET} + - BEAM_URL=http://beam-proxy:8081 + - API_KEY=${BEAM_FILE_API_KEY} + command: ["receive", "save", "--outdir /data"] + volumes: + - /var/cache/bridgehead/beam-file/:/data + profiles: ["beam-file-receiver"] + + beam-proxy: + environment: + APP_beamfile_KEY: ${BEAM_FILE_SECRET} diff --git a/modules/beam-file-setup.sh b/modules/beam-file-setup.sh new file mode 100644 index 0000000..4b259a4 --- /dev/null +++ b/modules/beam-file-setup.sh @@ -0,0 +1,18 @@ +#!/bin/bash -e + +function beamFileSetup() { + if [ -n "ENABLE_BEAM_FILE_SENDER" ]; then + echo "Starting beam file in sender mode" + OVERRIDE+=" -f ./modules/beam-file-compose.yml --profile beam-file-sender" + BEAM_FILE_SECRET="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" + # NOTE: We could make this persistent across restarts + BEAM_FILE_API_KEY="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" + log INFO "Beam File in Sender Mode available uses ApiKey ${BEAM_FILE_API_KEY}" + elif [ -n "ENABLE_BEAM_FILE_RECEIVER" ]; then + echo "Starting beam file in receiver mode" + OVERRIDE+=" -f ./modules/beam-file-compose.yml --profile beam-file-receiver" + BEAM_FILE_SECRET="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" + BEAM_FILE_API_KEY="$(cat /proc/sys/kernel/random/uuid | sed 's/[-]//g' | head -c 20)" + log INFO "Beam File in Receiver Mode available uses ApiKey ${BEAM_FILE_API_KEY}" + fi +} diff --git a/versions/test b/versions/test index 7d66e03..e182063 100644 --- a/versions/test +++ b/versions/test @@ -1,3 +1,4 @@ FOCUS_TAG=develop BEAM_TAG=develop -BLAZE_TAG=main \ No newline at end of file +BLAZE_TAG=main +BEAM_FILE_TAG=task-based-files