Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP wifi-menu #935

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
11 changes: 11 additions & 0 deletions image_builder/image_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ def build_image():
run_command(f"cp -r {KERNEL_VERSION_NAME} "
f"{ROOTFS_MOUNT}/lib/modules/{KERNEL_VERSION_NAME}")

print("Write polkit override, so Link can modify wifi settings")
nm_rule_path = join(BUILDER_DATA_PATH, "01-prusalink-nm.rules")
polkit_rules = join(ROOTFS_MOUNT, "etc/polkit-1/rules.d/")
run_command(f"cp {nm_rule_path} {polkit_rules}")

print("Write dnsmasq ap0 settings")
nm_dnsmasq_path = join(BUILDER_DATA_PATH, "ap0-dnsmasq.conf")
dnsmasq_shared_path = join(ROOTFS_MOUNT,
"etc/NetworkManager/dnsmasq-shared.d/")
run_command(f"cp {nm_dnsmasq_path} {dnsmasq_shared_path}")

config_txt_path = join(BOOTFS_MOUNT, "config.txt")
with open(config_txt_path, "a", encoding="utf-8") as config_txt:
config_txt.write("dtoverlay=disable-bt\n")
Expand Down
6 changes: 6 additions & 0 deletions prusa/link/data/image_builder/01-prusalink-nm.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
polkit.addRule(function(action, subject) {
if (action.id.match("org.freedesktop.NetworkManager") &&
(subject.isInGroup("sudo") || subject.isInGroup("netdev"))) {
return polkit.Result.YES;
}
});
15 changes: 15 additions & 0 deletions prusa/link/data/image_builder/add-ap0.service-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[Unit]
Description=Add ap0 interface
Requires=sys-subsystem-net-devices-wlan0.device
Before=dhcpcd.service
Before=wpa_supplicant.service
Restart=on-failure
StartLimitIntervalSec=1
StartLimitBurst=5

[Service]
Type=oneshot
ExecStart=/usr/sbin/iw dev {device} interface add ap0 type __ap

[Install]
WantedBy=multi-user.target
19 changes: 19 additions & 0 deletions prusa/link/data/image_builder/ap0-dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Disable DNS server functionality
port=0

# Specify the interface
interface=ap0

# Define the range of IP addresses that will be handed out by the DHCP server
dhcp-range=172.16.188.100,172.16.188.200,255.255.255.0,43200

# Set the default gateway (note that this is a 'dummy' gateway as per your requ>
dhcp-option=option:router,172.16.188.1

# Set the lease time (you can adjust this as needed)
dhcp-leasefile=/var/lib/misc/dnsmasq.leases
dhcp-lease-max=150

# Disable DNS server functionality
no-resolv
no-hosts
1 change: 1 addition & 0 deletions prusa/link/data/image_builder/manager-start-script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Forward the port 80 to 8080 even on the loopback, so we van ping ourselves
iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i ap0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -I OUTPUT -p tcp -o lo -d localhost --dport 80 -j REDIRECT --to-ports 8080

set_up_port () {
Expand Down
1 change: 1 addition & 0 deletions prusa/link/data/image_builder/prusalink-start-script.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Forward the port 80 to 8080 even on the loopback, so we van ping ourselves
iptables -t nat -A PREROUTING -i wlan0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -i ap0 -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -I OUTPUT -p tcp -o lo -d localhost --dport 80 -j REDIRECT --to-ports 8080

set_up_port () {
Expand Down
Loading
Loading