Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bootstrap/startup.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"bind": "/sys/",
"mode": "rw"
},
"/var/run/wpa_supplicant/wlan0": {
"bind": "/var/run/wpa_supplicant/wlan0",
"/var/run/wpa_supplicant": {
"bind": "/var/run/wpa_supplicant",
"mode": "rw"
},
"/tmp/wpa_playground": {
Expand Down
24 changes: 22 additions & 2 deletions core/services/wifi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import asyncio
import logging
import os
import stat
import sys
from pathlib import Path
from typing import Any, List, Optional
Expand Down Expand Up @@ -231,10 +232,29 @@ def get_hotspot_credentials() -> Any:
socket_name = args.socket_name
else:
logger.info("Connecting via default socket.")
available_sockets = os.listdir(wpa_socket_folder)

def is_socket(file_path: str) -> bool:
try:
mode = os.stat(file_path).st_mode
return stat.S_ISSOCK(mode)
except Exception as error:
logger.warning(f"Could not check if '{file_path}' is a socket: {error}")
return False

# We are going to sort and get the latest file, since this in theory will be an external interface
# added by the user
entries = os.scandir(wpa_socket_folder)
available_sockets = sorted(
[
entry.path
for entry in entries
if entry.name.startswith(("wlan", "wifi", "wlp")) and is_socket(entry.path)
]
)
if not available_sockets:
raise RuntimeError("No wifi sockets available.")
socket_name = available_sockets[0]
socket_name = available_sockets[-1]
logger.info(f"Going to use {socket_name} file")
WLAN_SOCKET = os.path.join(wpa_socket_folder, socket_name)
wifi_manager.connect(WLAN_SOCKET)
except Exception as socket_connection_error:
Expand Down
11 changes: 6 additions & 5 deletions core/tools/blueos_startup_update/blueos_startup_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,17 @@
DELTA_JSON = {
"core": {
"binds": {
"/run/udev": {"bind": "/run/udev", "mode": "ro"},
"/etc/blueos": {"bind": "/etc/blueos", "mode": "rw"},
"/etc/machine-id": {"bind": "/etc/machine-id", "mode": "ro"},
"/etc/dhcpcd.conf": {"bind": "/etc/dhcpcd.conf", "mode": "rw"},
"/usr/blueos/userdata": {"bind": "/usr/blueos/userdata", "mode": "rw"},
"/usr/blueos/extensions": {"bind": "/usr/blueos/extensions", "mode": "rw"},
"/usr/blueos/bin": {"bind": "/usr/blueos/bin", "mode": "rw"},
"/etc/machine-id": {"bind": "/etc/machine-id", "mode": "ro"},
"/etc/resolv.conf.host": {"bind": "/etc/resolv.conf.host", "mode": "ro"},
"/home/pi/.ssh": {"bind": "/home/pi/.ssh", "mode": "rw"},
"/run/udev": {"bind": "/run/udev", "mode": "ro"},
"/sys/": {"bind": "/sys/", "mode": "rw"},
"/usr/blueos/bin": {"bind": "/usr/blueos/bin", "mode": "rw"},
"/usr/blueos/extensions": {"bind": "/usr/blueos/extensions", "mode": "rw"},
"/usr/blueos/userdata": {"bind": "/usr/blueos/userdata", "mode": "rw"},
"/var/run/wpa_supplicant": {"bind": "/var/run/wpa_supplicant", "mode": "rw"},
}
}
}
Expand Down