aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime/files/wifi_connect.exp
blob: c0a077583c2918822f732e547dbd0af4328427cb (plain)
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
#!/usr/bin/expect
set timeout 100
set login 0
set ip       [lindex $argv 0]
set cmd      [lindex $argv 1]
set service  [lindex $argv 2]
set password [lindex $argv 3]

spawn ssh root@$ip -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR "$cmd"
 expect {
 "Agent registered"
   {
    send "config $service --remove\n";
    sleep 2; send "connect $service\n"; exp_continue
   }
 "Operation timeout"
   {
    sleep 1; send "connect $service\n"; exp_continue
   }
 "Operation aborted"
   {
    sleep 1; send "connect $service\n"; exp_continue
   }
 "Input/output error"
   {
    sleep 1; send "connect $service\n"; exp_continue
   }
 "Retry (yes/no)?"
   {
    sleep 1; send "yes\n"; exp_continue
   }
 "Passphrase?"
   {
    sleep 1; send "$password\n"; exp_continue
   }
 "Connected wifi*"
   {
    send "exit\n"; exit 2
   }
 "connmanctl*"
   {
    if {$login==0} {set login 1;send "agent on\n"; exp_continue} else {exp_continue}
   }
 eof
   {}
 }