Skip to content

Instantly share code, notes, and snippets.

@blankdots
Last active May 28, 2018 11:13
Show Gist options
  • Save blankdots/bb4714b95899fd4e8e100d5961420183 to your computer and use it in GitHub Desktop.
Save blankdots/bb4714b95899fd4e8e100d5961420183 to your computer and use it in GitHub Desktop.
makefile
.PHONY: upload submit user
DOCKER_PATH=/home/stenegru/Software/test/LocalEGA/deployments/docker
GPG_EXEC=/usr/bin/gpg2
# GPG_EXEC=gpg
SSH_KEY_PUB=~/.ssh/dummy.key.pub
SSH_KEY_PRIV=~/.ssh/dummy.key
INSTANCE_PORT=$(shell awk -F= '/DOCKER_PORT_inbox/ {print $$2}' $(DOCKER_PATH)/bootstrap/settings/swe1)
GPG_HOME=$(DOCKER_PATH)/private/swe1/gpg
PGP_PUB=$(DOCKER_PATH)/private/swe1/pgp/ega.pub
PGP_EMAIL=$(shell awk -F= '/PGP_EMAIL/ {print $$2}' $(DOCKER_PATH)/bootstrap/settings/swe1)
CEGA_USERS=$(DOCKER_PATH)/private/cega/users
CEGA_MQ_CONNECTION=$(shell awk -F= '/^CEGA_CONNECTION/ {print $$2}' $(DOCKER_PATH)/private/swe1/mq.env)
##############################
USER=ega-box-999
#USER=toto
FILE=HG00458.unmapped.ILLUMINA.bwa.CHS.low_coverage.20130415.bam
all: user upload submit
# org:
# @cp ~/Desktop/HG00458.unmapped.ILLUMINA.bwa.CHS.low_coverage.20130415.bam .
$(FILE).gpg: $(FILE)
@mkdir -p dir $(GPG_HOME)
$(GPG_EXEC) --homedir $(GPG_HOME) --import $(PGP_PUB)
$(GPG_EXEC) --homedir $(GPG_HOME) -r $(PGP_EMAIL) -e -o $@ $<
upload: $(FILE).gpg $(FILE).gpg.md5 $(FILE).md5
cd $(<D) && sftp -P $(INSTANCE_PORT) -i $(SSH_KEY_PRIV) $(USER)@localhost <<< $$"mput $(^F)"
$(FILE).gpg.md5: $(FILE).gpg
printf '%s' $(shell md5sum $< | cut -d' ' -f1) > $@
$(FILE).md5: $(FILE)
printf '%s' $(shell md5sum $< | cut -d' ' -f1) > $@
submit: $(FILE).gpg $(FILE).gpg.md5 $(FILE).md5
@echo publish.py --connection amqp://[redacted]@$(lastword $(subst @, ,$(CEGA_MQ_CONNECTION))) $(USER) dir/$(FILE).gpg --unenc ... --enc ...
@python $(DOCKER_PATH)/../../extras/publish.py --connection $(subst cega-mq,localhost,$(CEGA_MQ_CONNECTION)) $(USER) $(FILE).gpg --unenc $(shell cat $(FILE).md5) --enc $(shell cat $(FILE).gpg.md5) EGAF$(shell cat $(FILE).md5)
user: $(CEGA_USERS)/swe1/$(USER).yml
$(CEGA_USERS)/swe1/$(USER).yml: $(CEGA_USERS)/$(USER).yml
-cd $(CEGA_USERS)/swe1 && ln -s ../$(USER).yml .
$(CEGA_USERS)/$(USER).yml:
@echo --- > $@
@echo "pubkey: $(shell cat $(SSH_KEY_PUB))" >> $@
clean:
-unlink $(CEGA_USERS)/swe1/$(USER).yml
rm -rf $(FILE).gpg $(FILE).gpg.md5 $(FILE).md5 $(CEGA_USERS)/$(USER).yml $(GPG_HOME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment