6 if (len(sys.argv) < 4):
7 print "Usage: %s <type> ... " % (sys.argv[0])
8 print " type: openconnect"
9 print " <name> <host> <domain> <cookie> [servercert]"
10 print " type: openvpn"
11 print " <name> <host> <domain> [<cafile> <certfile> <keyfile>]"
13 print " <name> <host> <domain> <user> <password>"
15 print " <name> <host> <domain> <user> <password>"
18 bus = dbus.SystemBus()
20 manager = dbus.Interface(bus.get_object("net.connman", "/"),
21 "net.connman.Manager")
23 print "Attempting to connect service %s" % (sys.argv[3])
25 if sys.argv[1] == "openconnect":
26 if (len(sys.argv) > 6):
27 path = manager.ConnectProvider(({ "Type": "openconnect",
30 "VPN.Domain": sys.argv[4],
31 "OpenConnect.Cookie": sys.argv[5],
32 "OpenConnect.ServerCert": sys.argv[6]}))
34 path = manager.ConnectProvider(({ "Type": "openconnect",
37 "VPN.Domain": sys.argv[4],
38 "OpenConnect.Cookie": sys.argv[5]}))
39 elif sys.argv[1] == "openvpn":
40 if (len(sys.argv) < 6):
41 path = manager.ConnectProvider(({ "Type": "openvpn",
44 "VPN.Domain": sys.argv[4] }))
46 path = manager.ConnectProvider(({ "Type": "openvpn",
49 "VPN.Domain": sys.argv[4],
50 "OpenVPN.CACert": sys.argv[5],
51 "OpenVPN.Cert": sys.argv[6],
52 "OpenVPN.Key": sys.argv[7]}))
54 elif sys.argv[1] == "pptp":
55 path = manager.ConnectProvider(({ "Type": "pptp",
58 "VPN.Domain": sys.argv[4],
59 "PPTP.User": sys.argv[5],
60 "PPTP.Password": sys.argv[6]}))
61 elif sys.argv[1] == "l2tp":
62 path = manager.ConnectProvider(({ "Type": "l2tp",
65 "VPN.Domain": sys.argv[4],
66 "L2TP.User": sys.argv[5],
67 "L2TP.Password": sys.argv[6]}))
70 print "Unknown VPN type"
73 print "VPN service path is %s" %(path)