-
Notifications
You must be signed in to change notification settings - Fork 14
/
wifi
executable file
·54 lines (44 loc) · 1.36 KB
/
wifi
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
#!/usr/bin/env python3
import sys
import glob
from utils import *
configs = glob.glob("env/wifi_networks/*.yaml")
config_names = [".".join(config.split("/")[-1].split(".")[:-1]) for config in configs]
ip: str = "10.0.0.1" if len(sys.argv) == 1 else sys.argv[1]
hostname: str = rhio_get_value(ip, "/server/hostname")
robot_ips: dict = {
"olive": "41",
"nova": "42",
"arya": "43",
"tom": "44",
"rush": "45"
}
if hostname not in robot_ips:
error(f"Unknown robot {hostname}")
exit()
if len(sys.argv) < 3:
while True:
print("")
bright("Configuration available: ")
for config in config_names:
bright(f"* {config}")
print("")
bright("Enter the desired configuration:")
config: str = input()
if config in config_names:
break
else:
config: str = sys.argv[2]
bright(f"[WIFI] Deploying WiFi configuration {config} to {ip}")
# Reading configuration file
f = open(f"env/wifi_networks/{config}.yaml", "r")
config = f.read()
f.close()
config = config.replace("{IP}", robot_ips[hostname])
# Writing it back with proper IP
f = open("/tmp/wifi.yaml", "w")
f.write(config)
f.close()
os.system(f"scp /tmp/wifi.yaml rhoban@{ip}:/tmp/wifi.yaml")
os.system(f"ssh rhoban@{ip} sudo cp /tmp/wifi.yaml /etc/netplan/00-installer-config-wifi.yaml")
os.system(f"ssh rhoban@{ip} sudo netplan apply")