main/postmarketos-base-ui: remove tethering script
Tethering is now integrated within usb-moded. Part-of: <https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6531>
This commit is contained in:
parent
002191af2b
commit
f2f4cdd1e2
4 changed files with 1 additions and 184 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Maintainer: Clayton Craft <clayton@craftyguy.net>
|
||||
pkgname=postmarketos-base-ui
|
||||
pkgver=42
|
||||
pkgver=43
|
||||
pkgrel=0
|
||||
pkgdesc="Meta package for minimal postmarketOS UI base"
|
||||
url="https://postmarketos.org"
|
||||
|
|
@ -31,7 +31,6 @@ subpackages="
|
|||
$pkgname-bluez-obexd:obexd
|
||||
$pkgname-elogind
|
||||
$pkgname-flatpak
|
||||
$pkgname-networkmanager-usb-tethering:usb_tethering
|
||||
$pkgname-networkmanager
|
||||
$pkgname-openrc
|
||||
$pkgname-openrc-settingsd:openrc_settingsd
|
||||
|
|
@ -76,19 +75,14 @@ _source644="
|
|||
usr/lib/NetworkManager/conf.d/50-hostname-mode.conf
|
||||
usr/lib/NetworkManager/conf.d/50-iwd.conf
|
||||
usr/lib/NetworkManager/conf.d/50-random-mac.conf
|
||||
usr/lib/NetworkManager/conf.d/50-tethering.conf
|
||||
usr/lib/NetworkManager/conf.d/50-use-dnsmasq.conf
|
||||
usr/lib/udev/rules.d/50-udmabuf.rules
|
||||
usr/share/flatpak/remotes.d/flathub.flatpakrepo
|
||||
usr/share/wireplumber/wireplumber.conf.d/50-bluetooth.conf
|
||||
usr/share/mkinitfs/files/10-wireless-regdb.files
|
||||
"
|
||||
_source600="
|
||||
usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection
|
||||
"
|
||||
_source755="
|
||||
usr/lib/NetworkManager/dispatcher.d/50-dns-filter.sh
|
||||
usr/lib/NetworkManager/dispatcher.d/50-tethering.sh
|
||||
usr/share/tinydm/env-wayland.d/50-sdl-wayland.sh
|
||||
etc/profile.d/qt-mobile-controls.sh
|
||||
etc/profile.d/qt-wayland.sh
|
||||
|
|
@ -192,15 +186,6 @@ obexd() {
|
|||
mkdir -p "$subpkgdir"
|
||||
}
|
||||
|
||||
usb_tethering() {
|
||||
install_if="$pkgname-networkmanager=$pkgver-r$pkgrel"
|
||||
replaces="$pkgname-networkmanager"
|
||||
|
||||
amove usr/lib/NetworkManager/conf.d/50-tethering.conf
|
||||
amove usr/lib/NetworkManager/dispatcher.d/50-tethering.sh
|
||||
amove usr/lib/NetworkManager/system-connections/USB_Networking.nmconnection
|
||||
}
|
||||
|
||||
networkmanager() {
|
||||
depends="
|
||||
busctl
|
||||
|
|
@ -314,15 +299,12 @@ cac604e25c46e695dd30bd5a10cfd2d69595fcc3bc290096ac94b76b10834d591ea6576afb79c46b
|
|||
3c9ae7415f4891bee8595166ed6a42cb577a837f741c6b5409d193558626348b41516888a01d0c4895282c5f4e9a1ff838c19712888750b2ef68429bb4b42ee3 rootfs-usr-lib-NetworkManager-conf.d-50-hostname-mode.conf
|
||||
439615745d5be0d1ab6801cfbf960a31b12da30bf5df64ba2914ff32dae9e650595d7f96e66f5dff6308f092de1f746277ea7f4e701888a22571f7c119b7bf0d rootfs-usr-lib-NetworkManager-conf.d-50-iwd.conf
|
||||
d4b4c4fed2dee7266f6a87ae266691377593014943e2953e4cd87a59f3110f25bfb5f3f866cc843519f628695e4df7602bfdcd3d79f2c2cd6e8256535c33b038 rootfs-usr-lib-NetworkManager-conf.d-50-random-mac.conf
|
||||
6507eb31cdd694a7db0280246433118a650bf5d99fbe639f967ae2d95945429a7e03ca6feb5bb6e7b9fb14fcec21e13e51209a79edd0041e77b5bf76b129ed6f rootfs-usr-lib-NetworkManager-conf.d-50-tethering.conf
|
||||
900554534191fa0797064d35350934cdd8af59f30f0ae7d8ec63c2e11c44a16c643d3024b6543940488cd590fec1d392548bcaacc3be88cddff90f69b17ece07 rootfs-usr-lib-NetworkManager-conf.d-50-use-dnsmasq.conf
|
||||
9431dd37801261002f2ac8a0c30483994897adaf7cb31e80fcb99b7354dbe3e10d79162a2f2baefc5d091bb192ff680f274d6481bb198958d08918529c64e26f rootfs-usr-lib-udev-rules.d-50-udmabuf.rules
|
||||
54620e508a5070ec8819e3661e592acfcfd26c52170b0ecc4dbbc1c61998963ce20bf9d9b051a608b76d6fc17e61c65decc16602b7d58061b9149667a968d258 rootfs-usr-share-flatpak-remotes.d-flathub.flatpakrepo
|
||||
92930f027626825b027f585a9be180f8a6ebae6dc44d2cf8f9d43cce00db8cbb43c33fc341fe382abacb832ea1b6414dc4c8129d265b0258d096599b2e206a93 rootfs-usr-share-wireplumber-wireplumber.conf.d-50-bluetooth.conf
|
||||
66a7a72746e822676d0ec76160e39b65c711e574a6334f3aad38c563d3104b33d0619d50b92c9201546fd81bfd10cfe0e4a59278cbcbddf20a238f6ad71c050c rootfs-usr-share-mkinitfs-files-10-wireless-regdb.files
|
||||
1b8add60574ec4644197cb93263c0653325c2e88e03673de918be5fb3280c7b81e8e97dce498850a07f2f3307771c44f3c876922e5cbd5207523ede31816296f rootfs-usr-lib-NetworkManager-system-connections-USB_Networking.nmconnection
|
||||
36e0037f6d26a99db7b47831263be610d594e2c1c4a8ee7f6fc8b41092f501d3064d80b80ddf6a82b616bd2da09aa4da896074ad9f7fd53aba7e397da4190d22 rootfs-usr-lib-NetworkManager-dispatcher.d-50-dns-filter.sh
|
||||
802c8ca1603c6bc536f83ea7158f9fb9cf0dd94c59cadab9d059c738ca6bc5c1deb1c982996efd3b1909d01592e5a3e32f005c043e203a83361d3c64994b713b rootfs-usr-lib-NetworkManager-dispatcher.d-50-tethering.sh
|
||||
ecaa57d033a119a53a6574c27636b7c89d659d75ea48a973a6a4ff6f90e5d07202529fd489bfc9dfc7430f5b60f40612f6d5c06f7fab47e681b0a3112a874058 rootfs-usr-share-tinydm-env-wayland.d-50-sdl-wayland.sh
|
||||
bf8db527c49fa724e640a90269ba2648a2555f5867b2adbfbd88d1f685261f757339757c09ee08f590c76de4bd3d0c73a47dea9bd340644dd4707e76152cefd1 rootfs-etc-profile.d-qt-mobile-controls.sh
|
||||
6e193eca3961a78d47b4656892eae34d019d9317a255a201f5ea61e3300caff04c526a27cd98d0edc072b36e3eaf3a1768f4cd27c5e2be8b19c167d535c820a6 rootfs-etc-profile.d-qt-wayland.sh
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
[main]
|
||||
# Do not auto-generate connections for usb0 iface
|
||||
no-auto-default=usb0
|
||||
|
||||
# USB gadgets are not managed by default, make exception for usb0 iface
|
||||
# Iface is configured in initfs, do not persist its NetworkManager connection
|
||||
[device-usb0]
|
||||
match-device=interface-name:usb0
|
||||
managed=true
|
||||
keep-configuration=no
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
#!/bin/sh -e
|
||||
# shellcheck disable=SC1091
|
||||
# Handle USB tethering with unudhcpd and NetworkManager while also
|
||||
# keeping SSH login over USB working when tethering is disabled.
|
||||
#
|
||||
# Copyright (c) 2023 Dylan Van Assche
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
# Must match with the supplied connection profile,
|
||||
# using UUID allows the user to change the connection name if they want to.
|
||||
con_uuid="83bd1823-feca-4c2b-9205-4b83dc792e1f"
|
||||
|
||||
. /usr/share/misc/source_deviceinfo
|
||||
|
||||
usb_network_function="${deviceinfo_usb_network_function:-ncm.usb0}"
|
||||
disable_dhcpd="${deviceinfo_disable_dhcpd:-false}"
|
||||
usb_network_function_fallback="rndis.usb0"
|
||||
if [ -n "$(cat /sys/kernel/config/usb_gadget/g1/UDC)" ]; then
|
||||
interface="$(
|
||||
cat "/sys/kernel/config/usb_gadget/g1/functions/$usb_network_function/ifname" 2>/dev/null ||
|
||||
cat "/sys/kernel/config/usb_gadget/g1/functions/$usb_network_function_fallback/ifname" 2>/dev/null ||
|
||||
echo 'usb0'
|
||||
)"
|
||||
else
|
||||
interface='eth0'
|
||||
fi
|
||||
|
||||
[ -e /etc/unudhcpd.conf ] && . /etc/unudhcpd.conf
|
||||
host_ip="${unudhcpd_host_ip:-172.16.42.1}"
|
||||
client_ip="${unudhcpd_client_ip:-172.16.42.2}"
|
||||
|
||||
# Skip if iface does not match
|
||||
if [ "$DEVICE_IFACE" != "$interface" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Trigger a disconnect/connect event on the client side to request a new DHCP lease.
|
||||
reactivate_gadget() {
|
||||
# Mount configFS
|
||||
mkdir -p /config
|
||||
mount -t configfs none /config || true
|
||||
|
||||
logger -t nm-tethering "configFS mounted"
|
||||
|
||||
# Reactivate gadget
|
||||
udc=$(cat /config/usb_gadget/g1/UDC)
|
||||
echo "" > /config/usb_gadget/g1/UDC
|
||||
sleep 1
|
||||
echo "$udc" > /config/usb_gadget/g1/UDC
|
||||
|
||||
logger -t nm-tethering "gadget reactivated"
|
||||
|
||||
# Unmount configFS
|
||||
umount /config
|
||||
rm -rf /config
|
||||
|
||||
logger -t nm-tethering "configFS unmounted"
|
||||
}
|
||||
|
||||
# Default static IP for SSH acccess
|
||||
# 1. Configure NetworkManager connection to use IP 172.16.42.1, same as initfs.
|
||||
# 2. Disable IPv6 as unudhcpd only supplies IPv4 addresses.
|
||||
# 3. Start unudhcpd to handle DHCP requests.
|
||||
# 4. Reactivate the USB Ethernet gadget to force the clients to reactivate the interface.
|
||||
disable_tethering() {
|
||||
# Configure static IP and bring up connection automatically
|
||||
nmcli connection modify "$con_uuid" ipv4.address "$host_ip/16"
|
||||
nmcli connection modify "$con_uuid" ipv4.method "manual"
|
||||
nmcli connection modify "$con_uuid" ipv6.method "link-local"
|
||||
nmcli connection modify "$con_uuid" connection.autoconnect "true"
|
||||
|
||||
# Restart unudhcpd and configure it similar to initfs
|
||||
killall unudhcpd || true
|
||||
|
||||
if [ "$disable_dhcpd" = "true" ]; then
|
||||
logger -t nm-tethering "unudhcpd not restarted because it is disabled"
|
||||
else
|
||||
(unudhcpd -i "$interface" -s "$host_ip" -c "$client_ip") &
|
||||
logger -t nm-tethering "unudhcpd started"
|
||||
fi
|
||||
|
||||
# Reactivate gadget to apply changes
|
||||
reactivate_gadget
|
||||
logger -t nm-tethering "USB tethering disabled"
|
||||
}
|
||||
|
||||
# USB tethering
|
||||
# 1. Enforce 172.16.42.1 as host IP even in tethering mode.
|
||||
# 2. Stop unudhcpd as NetworkManager will spawn dnsmasq to handle DNS and DHCP requests.
|
||||
# 3. Reactivate the USB Ethernet gadget to force the clients to reactivate the interface.
|
||||
enable_tethering() {
|
||||
# Enforce the same IP range as when tethering is disabled, this will retrigger
|
||||
# the script as we have to reapply again, also bring up connection automatically.
|
||||
ip=$(nmcli connection show "$con_uuid" --active | grep ipv4.addresses | tr -s " " | cut -d " " -f2)
|
||||
if [ "$ip" != "$host_ip/16" ]; then
|
||||
logger -t nm-tethering "Enforcing $host_ip/16 as DHCP range"
|
||||
nmcli connection modify "$con_uuid" ipv4.address "$host_ip/16"
|
||||
nmcli connection modify "$con_uuid" connection.autoconnect "true"
|
||||
nmcli device reapply "$interface"
|
||||
return
|
||||
fi
|
||||
|
||||
# Kill unudhcpd if needed
|
||||
killall unudhcpd || true
|
||||
logger -t nm-tethering "unudhcpd stopped"
|
||||
|
||||
# Reactivate gadget to apply changes
|
||||
reactivate_gadget
|
||||
logger -t nm-tethering "USB tethering enabled"
|
||||
}
|
||||
|
||||
# Handle dispatcher events for tethering
|
||||
method=$(nmcli connection show "$con_uuid" --active | grep ipv4.method | tr -s " " | cut -d " " -f2)
|
||||
case $NM_DISPATCHER_ACTION in
|
||||
# Always disable tethering on insert or removal for security
|
||||
"up"|"down")
|
||||
disable_tethering
|
||||
|
||||
# The connection may have been configured before to tethering which
|
||||
# is not desired when iface comes up or is shut down as tethering must be
|
||||
# disabled. Enforce this by triggering a reapply after modifying the connection
|
||||
# which will cause NetworkManager to trigger the script again.
|
||||
# If the iface is already down since dispatcher scripts are executed async,
|
||||
# the command will fail which is fine to ignore
|
||||
if [ "$method" = "shared" ]; then
|
||||
logger -t nm-tethering "Enforcing tethering disabled on iface up/down"
|
||||
nmcli device reapply "$interface" || true
|
||||
fi
|
||||
;;
|
||||
# Enable tethering if the user explicitly enabled it
|
||||
"reapply")
|
||||
if [ "$method" = "shared" ]; then
|
||||
enable_tethering
|
||||
elif [ "$method" = "manual" ]; then
|
||||
disable_tethering
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
[connection]
|
||||
id=USB Networking
|
||||
uuid=83bd1823-feca-4c2b-9205-4b83dc792e1f
|
||||
type=ethernet
|
||||
interface-name=usb0
|
||||
|
||||
[ethernet]
|
||||
|
||||
[ipv4]
|
||||
address1=172.16.42.1/16
|
||||
method=manual
|
||||
|
||||
[ipv6]
|
||||
addr-gen-mode=default
|
||||
method=link-local
|
||||
|
||||
[proxy]
|
||||
Loading…
Add table
Add a link
Reference in a new issue