commit f41b0258c618727d589b3a596b089efc8c011e48 Author: Gustavo Cordova Date: Thu Dec 17 15:56:58 2020 -0800 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f12c4d --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +* +!/.vault +!/.vault/* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..500ff3e --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +.PHONY: help init open close + +PASSFILE := $(CURDIR)/.passfile +PASSFILE_OPT := $(shell [ -f $(PASSFILE) ] && echo "-passfile $(PASSFILE)" || echo "") +VAULT := $(CURDIR)/.vault +VIEW := $(CURDIR)/vault + +CACHED := $(shell [ -f $(PASSFILE) ] && echo " [cached]" || echo "") +ISINIT := $(shell [ -d $(VAULT) ] && echo " [initialized]" || echo "") +ISOPEN := $(shell [ -d $(VIEW) ] && echo " [vault is open]" || echo "") + +help: ## Display this message + @echo "Usage:$(CACHED)$(ISINIT)$(ISOPEN)" >&2 + @sed -nE "s|^(.+):\\s+##\\s+(.+)\\s*$$|\\tmake \\1\\t- \\2|p" \ + $(lastword $(MAKEFILE_LIST)) >&2 + +init: ## Initialize the vault + @if [ -d $(VAULT) ]; then \ + echo "Vault has already been initialized" >&2; \ + echo "Remove $(VAULT) to re-initialize" >&2; \ + else \ + mkdir -m700 $(VAULT); \ + gocryptfs -init -aessiv $(PASSFILE_OPT) $(VAULT); \ + fi + +open: ## Open the vault + @if [ -d $(VAULT) ] && [ ! -d $(VIEW) ]; then \ + mkdir -m700 $(VIEW); \ + gocryptfs -quiet $(PASSFILE_OPT) $(VAULT) $(VIEW); \ + fi + @echo "Vault is open" >&2 + +close: ## Close the vault + @if [ -d $(VAULT) ] && [ -d $(VIEW) ]; then \ + fusermount -u $(VIEW); \ + rmdir $(VIEW); \ + fi + @echo "Vault is closed" >&2 diff --git a/README.md b/README.md new file mode 100644 index 0000000..c594fdf --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Vault