-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (35 loc) · 1.29 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
WORKDIR := $(shell pwd)
all: disconnect connect
start:
open /Applications/xbar.app
stop:
killall xbar
restart: stop start
connect: disconnect
./connect-vpn
disconnect:
@echo "signal SIGTERM" | nc -U socket || true
install: xkbswitch-macosx /Applications/xbar.app /opt/homebrew/sbin/openvpn
sed s:__workdir__:$(WORKDIR):g xbar-vpn-plugin > ~/Library/Application\ Support/xbar/plugins/openvpn.5s.sh
chmod a+x ~/Library/Application\ Support/xbar/plugins/openvpn.5s.sh
@test -e socket || touch socket
@sudo grep $(USER) /etc/sudoers | grep openvpn > /dev/null 2>&1 || make update_sudoers
/opt/homebrew/sbin/openvpn:
brew install openvpn
xkbswitch-macosx:
git clone https://github.com/xiehuc/xkbswitch-macosx
make -C xkbswitch-macosx
/Applications/xbar.app:
brew install --cask xbar
update_sudoers:
@echo "$(USER) ALL = (ALL) NOPASSWD: /opt/homebrew/sbin/openvpn" | sudo tee -a /etc/sudoers
check-runned:
@echo "state all" | nc -U socket | grep CONNECTING
check-connected: check_errors
@echo "state all" | nc -U socket | grep CONNECTED
check-password-need:
@echo "" | nc -U socket | grep -o PASSWORD
state:
@echo "state all" | nc -U socket | grep "[0-9]*,[A-Z]*" | tail -1 | cut -d, -f2
check_errors:
[ `tail -4 openvpn.log| grep "write UDP: Can't assign" | wc -l` -eq 4 ] && make connect || true