daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest May 26th, 2018 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # this script works in both MacOS and Linux
  2. .PHONY: upload submit user
  3. SHELL := /bin/bash
  4.  
  5. DOCKER_PATH=$(shell pwd)
  6.  
  7. #GPG_EXEC=/usr/local/gnupg-2.2/bin/gpg2
  8. GPG_EXEC=/usr/bin/gpg2
  9. SSH_KEY_PUB=~/.ssh/dummy.key.pub
  10. SSH_KEY_PRIV=~/.ssh/dummy.key
  11.  
  12. INSTANCE=fin
  13. INSTANCE_PORT=$(shell awk -F= '/DOCKER_PORT_inbox/ {print $$2}' $(DOCKER_PATH)/bootstrap/settings)
  14. GPG_HOME=$(DOCKER_PATH)/images/keyserver/gpg
  15. PGP_PUB=$(DOCKER_PATH)/images/keyserver/pgp/ega.pub
  16. PGP_EMAIL=$(shell awk -F= '/PGP_EMAIL/ {print $$2 }' $(DOCKER_PATH)/bootstrap/settings | tr -d ' ' )
  17. CEGA_USERS=$(DOCKER_PATH)/images/cega/users
  18. CEGA_MQ_PASSWORD=$(shell awk -F= '/CEGA_MQ_PASSWORD/ {print $$2}' $(DOCKER_PATH)/compose/.trace | tr -d ' ')
  19. CEGA_MQ_CONNECTION=amqp://cega_$(INSTANCE):$(CEGA_MQ_PASSWORD)@localhost:5672/$(INSTANCE)
  20. OSNAME=$(shell uname -s)
  21. # generate a RANDOM # change with whatever
  22. STABLE_ID=1245
  23.  
  24. ##############################
  25.  
  26. USER=mysuer
  27. #the user used for file encryption and file uploading
  28. USER0=john
  29. SSH_KEY_PRIV0=$(DOCKER_PATH)/images/cega/users/john.sec
  30.  
  31. all: user upload submit
  32.  
  33. dir/file.gpg: org
  34.     @mkdir -p dir $(GPG_HOME)
  35.     $(GPG_EXEC) --homedir $(GPG_HOME) --import $(PGP_PUB)
  36.     $(GPG_EXEC) --homedir $(GPG_HOME) --cipher-algo AES256 --compress-algo 0 -r $(PGP_EMAIL) -e -o $@ $<
  37.  
  38. upload: user dir/file.gpg dir/file.gpg.md5 dir/file.md5
  39.     sftp -P $(INSTANCE_PORT) -i $(SSH_KEY_PRIV0) $(USER0)@localhost <<< $$'put -r dir'
  40.  
  41. dir/file.gpg.md5: dir/file.gpg
  42. ifeq ($(OSNAME),Linux)
  43.     printf '%s' $(shell md5sum $< | cut -d' ' -f1) > $@
  44. else
  45.     printf '%s' $(shell md5 -q $< ) > $@
  46. endif
  47.  
  48. dir/file.md5: org
  49. ifeq ($(OSNAME),Linux)
  50.     printf '%s' $(shell md5sum $< | cut -d' ' -f1) > $@
  51. else
  52.     printf '%s' $(shell md5 -q $< ) > $@
  53. endif
  54.  
  55. submit: org dir/file.gpg dir/file.gpg.md5 dir/file.md5
  56.     @echo publish.py --connection $(CEGA_MQ_CONNECTION) $(USER0) dir/file.gpg $(STABLE_ID) --unenc ... --enc ...
  57.     @python $(DOCKER_PATH)/../../../extras/publish.py --connection $(subst cega-mq,localhost,$(CEGA_MQ_CONNECTION)) $(USER0) dir/file.gpg $(STABLE_ID) --unenc $(shell cat dir/file.md5) --enc $(shell cat dir/file.gpg.md5)
  58.  
  59. user: $(CEGA_USERS)/fin/$(USER).yml
  60.  
  61. $(CEGA_USERS)/fin/$(USER).yml: $(CEGA_USERS)/$(USER).yml
  62.     -cd $(CEGA_USERS)/fin && ln -s ../$(USER).yml .
  63.  
  64. $(CEGA_USERS)/$(USER).yml:
  65.     @echo --- > $@
  66.     @echo "pubkey: $(shell cat $(SSH_KEY_PUB))" >> $@
  67.  
  68. clean:
  69.     -unlink $(CEGA_USERS)/fin/$(USER).yml
  70.     rm -rf dir $(GPG_HOME) $(CEGA_USERS)/$(USER).yml
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top