Skip to content
Snippets Groups Projects
Unverified Commit 74ac6819 authored by Martijn Braam's avatar Martijn Braam Committed by Oliver Smith
Browse files

main/postmarketos-mkinitfs: verbose network log (!468)

Make the initfs show better errors in the network setup part.
parent 17292f4f
Branches
No related tags found
No related merge requests found
Pipeline #194246 passed
pkgname=postmarketos-mkinitfs
pkgver=0.7.9
pkgver=0.7.10
pkgrel=0
pkgdesc="Tool to generate initramfs images for postmarketOS"
url="https://postmarketos.org"
......@@ -25,5 +25,5 @@ package() {
}
sha512sums="2479b08e48450f7d46c83b1117d0d81edf26dad8f2107e2ae1b10689f1b063c38181be735957ec1a16392302815355ca879ab71fc28d084e075f490cb2ac42b5 init.sh.in
d458c47bb7734562f299a2f1bcf5f2bc3be8f4721d51716aadefa9addf553a5fd9582f9b2d452fbc1016bf4bcdde8a1d9fe4cd0475af030002ac660cfb86da89 init_functions.sh
8fc3241420de637aec1715073fe6419c87a9b83587eb88fd6325dfbfdfd38bcd1809df0928ac15b67bac5343926937778a0341c3c25478a0b09f7bd5f032203c init_functions.sh
6e0e6a08d17c5b6f22d049d51692819ebb9a86d4ef7307e384077a868ace61aaa0a59b9166cb8494142ddf150cd1d204f13889b3afd5108b2a4a95a8ecda9444 mkinitfs.sh"
......@@ -22,8 +22,8 @@ setup_log() {
mount_proc_sys_dev() {
# mdev
mount -t proc -o nodev,noexec,nosuid proc /proc
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys
mount -t proc -o nodev,noexec,nosuid proc /proc || echo "Couldn't mount /proc"
mount -t sysfs -o nodev,noexec,nosuid sysfs /sys || echo "Couldn't mount /sys"
mkdir /config
mount -t configfs -o nodev,noexec,nosuid configfs /config
......@@ -207,7 +207,12 @@ mount_root_partition() {
setup_usb_network_android() {
# Only run, when we have the android usb driver
SYS=/sys/class/android_usb/android0
[ -e "$SYS" ] || return
if ! [ -e "$SYS" ]; then
echo " /sys/class/android_usb does not exist, skipping android_usb"
return
fi
echo " Setting up an USB gadget through android_usb"
# Do the setup
printf "%s" "0" >"$SYS/enable"
......@@ -219,25 +224,44 @@ setup_usb_network_android() {
setup_usb_network_configfs() {
CONFIGFS=/config/usb_gadget
[ -e "$CONFIGFS" ] || return
mkdir $CONFIGFS/g1
if ! [ -e "$CONFIGFS" ]; then
echo " /config/usb_gadget does not exist, skipping configfs usb gadget"
return
fi
echo " Setting up an USB gadget through configfs"
# Create an usb gadet configuration
mkdir $CONFIGFS/g1 || echo " Couldn't create $CONFIGFS/g1"
printf "%s" "0x18D1" >"$CONFIGFS/g1/idVendor"
printf "%s" "0xD001" >"$CONFIGFS/g1/idProduct"
mkdir $CONFIGFS/g1/strings/0x409
# Create english (0x409) strings
mkdir $CONFIGFS/g1/strings/0x409 || echo " Couldn't create $CONFIGFS/g1/strings/0x409"
echo "postmarketOS" > "$CONFIGFS/g1/strings/0x409/manufacturer"
echo "Debug network interface" > "$CONFIGFS/g1/strings/0x409/product"
# Create rndis function
mkdir $CONFIGFS/g1/functions/rndis.usb0 || echo " Couldn't create $CONFIGFS/g1/functions/rndis.usb0"
mkdir $CONFIGFS/g1/functions/rndis.usb0
# Create configuration instance for the gadget
mkdir $CONFIGFS/g1/configs/c.1 || echo " Couldn't create $CONFIGFS/g1/configs/c.1"
mkdir $CONFIGFS/g1/configs/c.1/strings/0x409 || echo " Couldn't create $CONFIGFS/g1/configs/c.1/strings/0x409"
printf "%s" "rndis" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration || echo " Couldn't write configration name"
mkdir $CONFIGFS/g1/configs/c.1
mkdir $CONFIGFS/g1/configs/c.1/strings/0x409
printf "%s" "rndis" > $CONFIGFS/g1/configs/c.1/strings/0x409/configuration
# Link the rndis instance to the configuration
ln -s $CONFIGFS/g1/functions/rndis.usb0 $CONFIGFS/g1/configs/c.1 || echo " Couldn't symlink rndis.usb0"
ln -s $CONFIGFS/g1/functions/rndis.usb0 $CONFIGFS/g1/configs/c.1
# Check if there's an USB Device Controller
if [ -z "$(ls /sys/class/udc)" ]; then
echo " No USB Device Controller available"
return
fi
# See also: #338
# Link the gadget instance to an USB Device Controller
# See also: https://github.com/postmarketOS/pmbootstrap/issues/338
# shellcheck disable=SC2005
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC
echo "$(ls /sys/class/udc)" > $CONFIGFS/g1/UDC || echo " Couldn't write UDC"
}
setup_usb_network() {
......@@ -263,16 +287,26 @@ start_udhcpd() {
return
fi
echo "Starting udhcpd"
# Get usb interface
INTERFACE=""
ifconfig rndis0 "$IP" && INTERFACE=rndis0
ifconfig rndis0 "$IP" 2>/dev/null && INTERFACE=rndis0
if [ -z $INTERFACE ]; then
ifconfig usb0 "$IP" && INTERFACE=usb0
ifconfig usb0 "$IP" 2>/dev/null && INTERFACE=usb0
fi
if [ -z $INTERFACE ]; then
ifconfig eth0 "$IP" && INTERFACE=eth0
ifconfig eth0 "$IP" 2>/dev/null && INTERFACE=eth0
fi
if [ -z $INTERFACE ]; then
echo " Could not find an interface to run a dhcp server on"
echo " Interfaces:"
ip link
return
fi
echo " Using interface $INTERFACE"
# Create /etc/udhcpd.conf
{
echo "start 172.16.42.2"
......@@ -285,7 +319,7 @@ start_udhcpd() {
echo "option subnet 255.255.255.0"
} >/etc/udhcpd.conf
echo "Start the dhcpcd daemon (forks into background)"
echo " Start the dhcpcd daemon (forks into background)"
udhcpd
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment