forked from jamescoverdale/docker-forticlient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforticlient
executable file
·51 lines (42 loc) · 1.15 KB
/
forticlient
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/expect -f
set timeout $env(VPNTIMEOUT)
spawn "/usr/share/forticlient/opt/forticlient-sslvpn/64bit/forticlientsslvpn_cli" --server $env(VPNADDR) --vpnuser $env(VPNUSER) --keepalive
# Send command
expect -exact "Password for VPN:"
send -- "$env(VPNPASS)\n"
expect -exact "STATUS::Connecting..."
# In case of invalid certificate
expect -exact "Would you like to connect to this server? (Y/N)" {
send -- "Y\n"
}
# If two factor token is requested
#delay so server will send the email
sleep 10
set docker $spawn_id
expect "An email message containing a Token Code will be sent to*"
set token [split [exec python2.7 /imap.py $env(MAILUSER) $env(MAILPASSWORD) $env(MAILSERVER)]]
expect EOF
send -i $docker $token
send -i $docker "\n"
# In case of token
expect -exact "A FortiToken code is required for SSL-VPN login authentication." {
send -- "$env(VPNTOKEN)\n"
}
# Expect tunnel to actually start
expect {
"STATUS::Tunnel running" {
} timeout {
send_user -- "Failed to bring tunnel up after $env(VPNTIMEOUT)s\n"
exit 1
}
}
# Expect tunnel to stop but not exit
set timeout -1
expect {
"STATUS::Tunnel closed" {
exit 1
}
eof {
exit
}
}