1+ barracuda_file = barracudavpn_5.1.4_amd64.deb
2+ key_directory = ~/.keys
3+ key_path = $(key_directory ) /barracuda-vpn-key_rsa
4+ user_file_encrypted = vpn.user
5+ pwd_file_encrypted = vpn.pwd
6+ zhell_path = ~/.zshrc
7+
8+ .PHONY : install # = Install the barracuda-vpn
9+ install :
10+ sudo dpkg -i $(barracuda_file )
11+
12+ .PHONY : credentials # = Create key and encrypted files for credentials using the key
13+ credentials :
14+ @ if [ " $( user) " = " " ] || [ " $( pwd) " = " " ]; then \
15+ echo "Missing parameters! Use 'make test user=value pwd=value'"; \
16+ exit 1; \
17+ fi
18+ mkdir -p $(key_directory)
19+ openssl genrsa -out $(key_path) 2048
20+ echo "$(user)" | openssl rsautl -inkey $(key_path) -encrypt > $(user_file_encrypted)
21+ echo "$(pwd)" | openssl rsautl -inkey $(key_path) -encrypt > $(pwd_file_encrypted)
22+ sudo chown root:root $(key_path)
23+ sudo chmod 600 $(key_path)
24+
25+ .PHONY : test # = Connect to the vpn and close the connection
26+ test :
27+ ./vpn-open $(key_path )
28+ ./vpn-close
29+
30+ .PHONY : clean # = Remove the encrypted files for credentials and the key
31+ clean :
32+ sudo rm $(user_file_encrypted ) || true
33+ sudo rm $(pwd_file_encrypted ) || true
34+ sudo rm $(key_path ) || true
35+ rmdir --ignore-fail-on-non-empty $(key_directory )
36+
37+ .PHONY : configuration # = Create alias vpn and add this directory to PATH in the shell
38+ configuration :
39+ echo " " >> $(zhell_path )
40+ echo " " >> $(zhell_path )
41+ echo " # Used to automate barracuda-vpn" >> $(zhell_path )
42+ echo " alias vpn=\" vpn-open $( key_path) \" " >> $(zhell_path )
43+ echo " export PATH=\44PATH:$( PWD) " >> $(zhell_path )
44+
45+ .PHONY : help # = Generate list of targets with descriptions
46+ help :
47+ @grep ' ^.PHONY: .* #' Makefile | sed ' s/\.PHONY: \(.*\) # \(.*\)/\1 \2/' | expand -t20
0 commit comments