forked from kryptco/kr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
61 lines (52 loc) · 2.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
GOBUILDFLAGS += -ldflags -s
OS ?= $(shell ./install/os.sh)
all:
-mkdir -p bin
cd kr; go build $(GOBUILDFLAGS) -o ../bin/kr
cd krd/main; go build $(GOBUILDFLAGS) -o ../../bin/krd
cd pkcs11shim; make; cp target/release/kr-pkcs11.so ../bin/
cd krssh; go build $(GOBUILDFLAGS) -o ../bin/krssh
cd krgpg; go build $(GOBUILDFLAGS) -o ../bin/krgpg
clean:
rm -rf bin/
check:
go test $(GOBUILDFLAGS) github.com/kryptco/kr github.com/kryptco/kr/krd github.com/kryptco/kr/krdclient github.com/kryptco/kr/kr github.com/kryptco/kr/krssh github.com/kryptco/kr/krgpg
cd pkcs11shim; cargo test
vet:
go vet github.com/kryptco/kr github.com/kryptco/kr/krd github.com/kryptco/kr/krdclient github.com/kryptco/kr/kr github.com/kryptco/kr/krssh github.com/kryptco/kr/krgpg
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PREFIX ?= /usr
SUDO = sudo
endif
ifeq ($(UNAME_S),Darwin)
PREFIX ?= /usr/local
endif
SRCBIN = $(PWD)/bin
DSTBIN = $(PREFIX)/bin
DSTLIB = $(PREFIX)/lib
install: all
$(SUDO) ln -sf $(SRCBIN)/kr $(DSTBIN)/kr
$(SUDO) ln -sf $(SRCBIN)/krd $(DSTBIN)/krd
$(SUDO) ln -sf $(SRCBIN)/krssh $(DSTBIN)/krssh
$(SUDO) ln -sf $(SRCBIN)/krgpg $(DSTBIN)/krgpg
$(SUDO) ln -sf $(SRCBIN)/kr-pkcs11.so $(DSTLIB)/kr-pkcs11.so
mkdir -m 700 -p ~/.ssh
touch ~/.ssh/config
chmod 0600 ~/.ssh/config
perl -0777 -ne '/# Added by Kryptonite\nHost \*\n\tPKCS11Provider $(subst /,\/,$(PREFIX))\/lib\/kr-pkcs11.so\n\tProxyCommand $(subst /,\/,$(PREFIX))\/bin\/krssh %h %p\n\tIdentityFile ~\/.ssh\/id_kryptonite\n\tIdentityFile ~\/.ssh\/id_ed25519\n\tIdentityFile ~\/.ssh\/id_rsa\n\tIdentityFile ~\/.ssh\/id_ecdsa\n\tIdentityFile ~\/.ssh\/id_dsa/ || exit(1)' ~/.ssh/config || printf '\n# Added by Kryptonite\nHost *\n\tPKCS11Provider $(PREFIX)/lib/kr-pkcs11.so\n\tProxyCommand $(PREFIX)/bin/krssh %%h %%p\n\tIdentityFile ~/.ssh/id_kryptonite\n\tIdentityFile ~/.ssh/id_ed25519\n\tIdentityFile ~/.ssh/id_rsa\n\tIdentityFile ~/.ssh/id_ecdsa\n\tIdentityFile ~/.ssh/id_dsa' >> ~/.ssh/config
start:
ifeq ($(UNAME_S),Darwin)
mkdir -p ~/Library/LaunchAgents
cp share/co.krypt.krd.plist ~/Library/LaunchAgents/co.krypt.krd.plist
endif
kr restart
uninstall:
pkill krd
$(SUDO) rm -f $(DSTBIN)/kr
$(SUDO) rm -f $(DSTBIN)/krd
$(SUDO) rm -f $(DSTBIN)/krssh
$(SUDO) rm -f $(DSTBIN)/krgpg
$(SUDO) rm -f $(DSTLIB)/kr-pkcs11.so
perl -0777 -p -i.kr.bak -e 's/\s*# Added by Kryptonite\nHost \*\n\tPKCS11Provider $(subst /,\/,$(PREFIX))\/lib\/kr-pkcs11.so\n\tProxyCommand $(subst /,\/,$(PREFIX))\/bin\/krssh %h %p\n\tIdentityFile ~\/.ssh\/id_kryptonite\n\tIdentityFile ~\/.ssh\/id_ed25519\n\tIdentityFile ~\/.ssh\/id_rsa\n\tIdentityFile ~\/.ssh\/id_ecdsa\n\tIdentityFile ~\/.ssh\/id_dsa//g' ~/.ssh/config
kr uninstall