blob: 423cbca0f5fd69ab205ceb7054da73abe9a7a728 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
#!/usr/bin/env python
import keyring, sys, time, verdict
# To store the password, run this from an interactive python session:
# import keyring; keyring.set_password(SSID, 'psk', 'mysecret')
SSID = 'RedFelineNetwork'
PASSWD = keyring.get_password(SSID, 'psk')
if not PASSWD:
print 'No password for ' + SSID
sys.exit(1)
def run(args=[]):
#console = verdict.netcat('hazel', 5002)
console = verdict.serial('/dev/ttyUSB0')
# Check we have a command prompt
console.sendline('')
console.expect('root.*# ')
# Check we can see the router
console.sendline('nmcli dev wifi list')
console.expect(SSID)
console.expect('root.*# ')
# Change the hostname to avoid collisions with other 96Boards and
# ensure NetworkManager is restarted and observes the change.
console.sendline('sed -ie s/linaro-developer/hikey/ /etc/hostname')
console.expect('root.*# ')
console.sendline('hostname dragonboard')
console.expect('root.*# ')
console.sendline('exit')
console.expect('root.*# ')
console.sendline('systemctl restart NetworkManager\n')
console.expect('root.*# ')
# Wait for the SSID to detect the network
for i in range(20):
console.sendline('nmcli dev wifi list')
m = console.expect([SSID, 'root.*# '])
if m == 0:
console.expect('root.*# ')
break
time.sleep(1)
# Setup the connection (using network manager makes it durable
# through reboot cycles).
console.sendline('nmcli dev wifi con "{}" password "{}" name "Home"'.format(SSID, PASSWD))
console.expect('Connection with UUID .* created and activated on device')
console.expect('root.*# ')
# The next set of commands are network based commands and might
# have unpredictable runtimes
verdict.expect_slow_replies(console)
console.sendline('apt-get update')
console.expect('Reading package lists')
console.expect('root.*# ')
console.sendline('apt-get install -y mosh')
console.expect('Reading package lists')
console.expect('Unpacking mosh')
console.expect('Setting up mosh')
console.expect('root.*# ')
verdict.good(cleanup=(console,))
if __name__ == '__main__':
run(sys.argv[1:])
|