Initial commit
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
!/.vault
|
||||||
|
!/.vault/*
|
||||||
38
Makefile
Normal file
38
Makefile
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user