-
Notifications
You must be signed in to change notification settings - Fork 0
/
ovpn
executable file
·51 lines (38 loc) · 927 Bytes
/
ovpn
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
#!/usr/bin/env python3
"""
Script uses openvpn, and default configuration file at /etc/openvpn/client/aneeshneelam.me.conf
"""
import argparse
import sys
from subprocess import call
def setup_argparser():
parser = argparse.ArgumentParser()
parser.add_argument("command", help="Command: connect | disconnect")
return parser
def connect():
status = call([
'openvpn',
'--config',
'/etc/openvpn/client/aneeshneelam.me.conf',
'--daemon',
])
sys.exit(status)
def disconnect():
status = call([
'killall',
'-SIGINT',
'openvpn',
])
sys.exit(status)
def main():
parser = setup_argparser()
args = parser.parse_args()
if args.command == 'connect':
connect()
elif args.command == 'disconnect':
disconnect()
else:
parser.print_help()
sys.exit(1)
if __name__ == '__main__':
main()