Skip to content

Commit ebec6da

Browse files
committed
Move default ssid argument to common arguments.
1 parent 9108d98 commit ebec6da

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

extras/netconnectd.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ap:
2828
#driver: nl80211
2929

3030
# your AP wifi's SSID
31-
ssid: MrBeam2-AP
31+
#ssid: MrBeam2-AP
3232

3333
# your AP wifi's passphrase
3434
psk: mrbeamsetup

netconnectd/server.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,6 @@ def dhcp_range(arg):
10691069
config = copy.deepcopy(default_config)
10701070

10711071
configfile = args.config
1072-
if not configfile:
1073-
configfile = "/etc/netconnectd.yaml"
10741072

10751073
import os
10761074

@@ -1145,12 +1143,9 @@ def dhcp_range(arg):
11451143
"Wifi interface is missing, supply with either --interface-wifi or via config file"
11461144
)
11471145
if not config["ap"]["ssid"]:
1148-
try:
1149-
import socket
1150-
# Default SSID should be the hostname
1151-
config["ap"]["ssid"] = socket.gethostname()
1152-
except Exception:
1153-
parse.error("Failed to read system hostname")
1146+
parser.error(
1147+
"AP SSID is missing, supply with either --ap-ssid or via config file"
1148+
)
11541149

11551150
if args.foreground:
11561151
# start directly instead of as daemon

netconnectd/util.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import print_function, absolute_import
22

33
import argparse
4+
import socket
45
import subprocess
56
import yaml
67
import os
@@ -14,7 +15,7 @@
1415
help="Address of Unix Domain Socket used for communication",
1516
)
1617
common_arguments.add_argument(
17-
"-c", "--config", type=str, help="Location of config file to use"
18+
"-c", "--config", type=str, help="Location of config file to use", default="/etc/netconnectd.yaml"
1819
)
1920

2021

@@ -50,7 +51,7 @@ class InvalidConfig(Exception):
5051
ap=dict(
5152
name="netconnectd_ap",
5253
driver="nl80211",
53-
ssid=None,
54+
ssid=socket.gethostname(),
5455
psk=None,
5556
channel=3,
5657
ip="10.250.250.1",
@@ -78,7 +79,7 @@ def parse_configfile(configfile):
7879
if not os.path.exists(configfile):
7980
return None
8081

81-
mandatory = ("interface.wifi", "ap.ssid")
82+
mandatory = ("interfaces.wifi")
8283

8384
try:
8485
with open(configfile, "r") as f:

0 commit comments

Comments
 (0)