-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup-wifi-ubuntu.py
54 lines (44 loc) · 1.29 KB
/
setup-wifi-ubuntu.py
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/python3
from getpass import getpass
from pathlib import Path
from typing import Dict
from yaml import safe_dump
def setup_config(ssid: str, password: str) -> Dict[str, str]:
'''Create a basic Netplan configuration data structure
Args:
ssid: The name of the SSID
password: The password for the SSID
Returns:
A Netplan configuration data structure
'''
netplan_config = {
'network': {
'ethernets': {
'eth0': {
'dhcp4': True,
'optional': True
}
},
'version': 2,
'wifis': {
'wlan0': {
'optional': True,
'access-points': {
ssid: {
'password': password
}
},
'dhcp4': True
}
}
}
}
return netplan_config
def check_path() -> bool:
netplan_path = Path('/etc/netplan/')
if netplan_path.exists() is False:
if __name__ == '__main__':
'''No sanity checking because YOLO'''
ssid = input('WiFi SSID Name: ')
password = getpass('WiFi Password: ')
config = setup_config(ssid=ssid, password=password)