-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
232 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
deb http://repo.mobian.org/ @@SUITE@@ main non-free-firmware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Match] | ||
Type=gadget | ||
|
||
[Link] | ||
RequiredForOnline=no | ||
|
||
[Network] | ||
DHCPServer=yes | ||
Address=172.16.42.1/24 | ||
|
||
[DHCPServer] | ||
EmitDNS=no | ||
EmitNTP=no | ||
EmitRouter=no | ||
EmitTimezone=no |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[Match] | ||
Name=wlan0 | ||
|
||
[Link] | ||
RequiredForOnline=no | ||
|
||
[Network] | ||
DHCP=yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,49 @@ | ||
#!/bin/bash | ||
echo "*** rc.local ***" | ||
setterm -blank 1 | ||
setterm -powerdown 1 | ||
|
||
echo "*** USB network gadget setup ***" | ||
CONFIGFS=/sys/kernel/config/usb_gadget/g1 | ||
# Don't do anything if the USB gadget already exists | ||
if ! [ -d $CONFIGFS ] | ||
then | ||
# Required to make a composite gadget | ||
modprobe libcomposite | ||
|
||
# Create all required directories | ||
echo "Creating the USB gadget..." | ||
mkdir -p $CONFIGFS | ||
mkdir -p $CONFIGFS/strings/0x409 | ||
mkdir -p $CONFIGFS/configs/c.1 | ||
mkdir -p $CONFIGFS/configs/c.1/strings/0x409 | ||
|
||
# Setup IDs and strings | ||
USB_VENDORID="0x1D6B" # Linux Foundation | ||
USB_PRODUCTID="0x0104" # Multifunction composite gadget | ||
USB_MANUF="AYN" | ||
USB_PRODUCT="Odin USB Ethernet" | ||
USB_SERIAL=$(sha256sum < /etc/machine-id | cut -d' ' -f1) | ||
|
||
echo $USB_VENDORID > $CONFIGFS/idVendor | ||
echo $USB_PRODUCTID > $CONFIGFS/idProduct | ||
echo $USB_MANUF > $CONFIGFS/strings/0x409/manufacturer | ||
echo $USB_PRODUCT > $CONFIGFS/strings/0x409/product | ||
echo $USB_SERIAL > $CONFIGFS/strings/0x409/serialnumber | ||
|
||
# Create ECM (ethernet) function | ||
mkdir $CONFIGFS/functions/ecm.usb0 | ||
|
||
# Create configuration | ||
echo "Ethernet" > $CONFIGFS/configs/c.1/strings/0x409/configuration | ||
ln -s $CONFIGFS/functions/ecm.usb0 $CONFIGFS/configs/c.1 | ||
|
||
UDC="$(ls /sys/class/udc)" | ||
echo "$UDC" > $CONFIGFS/UDC | ||
fi | ||
|
||
set -x | ||
sleep 1 | ||
ip addr | ||
networkctl | ||
networkctl status | ||
networkctl status |
13 changes: 13 additions & 0 deletions
13
overlays/wlan-mac-from-android/etc/systemd/system/set-wlan-mac.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Set wlan0 persistent MAC address | ||
Wants=sysinit.target | ||
After=-.mount tmp.mount | ||
Before=systemd-networkd.service | ||
ConditionPathExists=!/etc/udev/rules.d/10-wlan0-persistent-mac-address.rules | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/local/libexec/set-wlan-mac.sh | ||
|
||
[Install] | ||
WantedBy=basic.target |
24 changes: 24 additions & 0 deletions
24
overlays/wlan-mac-from-android/usr/local/libexec/set-wlan-mac.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
wlan_mac="empty" | ||
if [[ -b /dev/disk/by-partlabel/persist ]] | ||
then | ||
mountpoint="$(mktemp -d)" | ||
mount -o ro /dev/disk/by-partlabel/persist "$mountpoint" | ||
set +e | ||
wlan_mac="$(grep -Po '(?<=Intf0MacAddress=)[A-Fa-f0-9]{12}' ${mountpoint}/wlan_mac.bin)" | ||
set -e | ||
umount "$mountpoint" | ||
rmdir "$mountpoint" | ||
fi | ||
|
||
if [[ "${#wlan_mac}" != "12" ]] | ||
then | ||
echo "Could not read wlan0 MAC address from Android partition, generating random one..." | ||
wlan_mac="$(printf '02%02X%02X%02X%02X%02X' $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256] $[RANDOM%256])" | ||
fi | ||
|
||
cat > /etc/udev/rules.d/10-wlan0-persistent-mac-address.rules <<EOT | ||
ACTION=="add", SUBSYSTEM=="net", INTERFACE=="wlan0", PROGRAM="/sbin/ip link set %k address ${wlan_mac:0:2}:${wlan_mac:2:2}:${wlan_mac:4:2}:${wlan_mac:6:2}:${wlan_mac:8:2}:${wlan_mac:10:2}" | ||
EOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/sh | ||
|
||
DEBIAN_SUITE=$1 | ||
SUITE=$2 | ||
CONTRIB=$3 | ||
NONFREE=$4 | ||
|
||
COMPONENTS="main" | ||
[ "$CONTRIB" = "true" ] && COMPONENTS="$COMPONENTS contrib" | ||
[ "$NONFREE" = "true" ] && COMPONENTS="$COMPONENTS non-free" | ||
|
||
# Add debian-security for bullseye & bookworm; note that only the main component is supported | ||
if [ "$DEBIAN_SUITE" = "bullseye" ] || [ "$DEBIAN_SUITE" = "bookworm" ]; then | ||
echo "deb http://security.debian.org/ $DEBIAN_SUITE-security $COMPONENTS" >> /etc/apt/sources.list | ||
# Temporary hack: add unstable as a lower priority source to install packages removed from testing | ||
else | ||
echo "deb http://deb.debian.org/debian unstable $COMPONENTS" >> /etc/apt/sources.list.d/unstable.list | ||
echo "deb http://deb.debian.org/debian experimental $COMPONENTS" >> /etc/apt/sources.list.d/experimental.list | ||
|
||
cat > /etc/apt/preferences.d/10-unstable-priority << EOF | ||
Package: * | ||
Pin: release a=unstable | ||
Pin-Priority: 200 | ||
EOF | ||
|
||
cat > /etc/apt/preferences.d/20-experimental-priority << EOF | ||
Package: * | ||
Pin: release a=experimental | ||
Pin-Priority: 250 | ||
EOF | ||
fi | ||
|
||
# Set the proper suite in our sources.list | ||
sed -i "s/@@SUITE@@/${SUITE}/" /etc/apt/sources.list.d/mobian.list | ||
|
||
# Setup repo priorities so mobian comes first | ||
cat > /etc/apt/preferences.d/00-mobian-priority << EOF | ||
Package: * | ||
Pin: release o=Mobian | ||
Pin-Priority: 700 | ||
EOF |