network: rework android_usb support by using udev and avoid calling blocking systemctl for ttyG* but create symlinks
This commit is contained in:
parent
e42a6503e6
commit
7f9aac7a35
9
Makefile
9
Makefile
@ -94,6 +94,12 @@ install-plugins: $(pck_plugins)
|
||||
$(DESTDIR)$(postplugrcdir)/$$plugin;\
|
||||
done
|
||||
|
||||
install-udev-files:
|
||||
@echo "installing udev files..."
|
||||
@$(INSTALL_DIR) $(DESTDIR)/lib/udev/rules.d
|
||||
$(INSTALL_SCRIPT) udev/android_usb $(DESTDIR)/lib/udev/android_usb
|
||||
$(INSTALL_DATA) udev/76-android_usb.rules $(DESTDIR)/lib/udev/rules.d/76-android_usb.rules
|
||||
|
||||
install-sysconfig: $(pck_sysconfig)
|
||||
@$(INSTALL_DIR) $(DESTDIR)$(sysconfigdir)
|
||||
$(INSTALL_DATA) $^ $(DESTDIR)$(sysconfigdir)
|
||||
@ -114,7 +120,8 @@ install: \
|
||||
install-initscript \
|
||||
install-logrotate \
|
||||
install-locales \
|
||||
install-sysconfig
|
||||
install-sysconfig \
|
||||
install-udev-files
|
||||
|
||||
uninstall:
|
||||
rm -f $(DESTDIR)$(sbin)/$(PACKAGE)
|
||||
|
@ -106,8 +106,6 @@ function android_usb() {
|
||||
echo 0 > /sys/class/android_usb/android0/enable
|
||||
echo rndis,acm > /sys/class/android_usb/android0/functions
|
||||
echo 2 > /sys/class/android_usb/android0/f_acm/instances
|
||||
systemctl enable getty@ttyGS0
|
||||
systemctl enable getty@ttyGS1
|
||||
echo $ANDROID_ETHADDR > /sys/class/android_usb/android0/f_rndis/ethaddr
|
||||
echo 2d01 > /sys/class/android_usb/android0/idProduct
|
||||
echo 1 > /sys/class/android_usb/android0/enable
|
||||
@ -123,6 +121,7 @@ ONBOOT=yes
|
||||
NM_CONTROLLED=no
|
||||
_EOF
|
||||
}
|
||||
|
||||
[ -e /etc/dhcpd-rndis0.conf ] || {
|
||||
[ "$NETWORK_ANDROID_SUBNET" ] && ANDROID_SUBNET=$NETWORK_ANDROID_SUBNET
|
||||
[ "$NETWORK_ANDROID_RANGE_FROM" ] && ANDORID_RANGE_FROM=$NETWORK_ANDROID_RANGE_FROM
|
||||
@ -134,9 +133,11 @@ subnet $ANDROID_SUBNET netmask $ANDROID_NETMASK {
|
||||
}
|
||||
_EOF
|
||||
}
|
||||
ifup rndis0
|
||||
touch /var/lib/dhcp/dhcpd-rndis0.leases
|
||||
/sbin/dhcpd -q rndis0 -pf /run/dhcpd-rndis0.pid -cf /etc/dhcpd-rndis0.conf -lf /var/lib/dhcp/dhcpd-rndis0.leases
|
||||
|
||||
for d in ttyGS0 ttyGS1; do
|
||||
[ -e /etc/systemd/system/getty.target.wants/getty@$d.service ] ||
|
||||
ln -s /lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@$d.service
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
7
udev/76-android_usb.rules
Normal file
7
udev/76-android_usb.rules
Normal file
@ -0,0 +1,7 @@
|
||||
# do not edit this file, it will be overwritten on update
|
||||
|
||||
ACTION!="add|change", GOTO="android_usb_probe_end"
|
||||
|
||||
SUBSYSTEM=="android_usb", KERNEL=="android*", IMPORT{program}="android_usb %p"
|
||||
|
||||
LABEL="android_usb_probe_end"
|
10
udev/android_usb
Executable file
10
udev/android_usb
Executable file
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# FIXME: hardcoded values
|
||||
if [ -e /sys$1 ]; then
|
||||
ANDROID_STATE=`cat /sys$1/state`
|
||||
[ "$ANDROID_STATE" = "CONFIGURED" ] || exit 0
|
||||
|
||||
ifup rndis0
|
||||
touch /var/lib/dhcp/dhcpd-rndis0.leases
|
||||
/sbin/dhcpd rndis0 -d -pf /run/dhcpd-rndis0.pid -cf /etc/dhcpd-rndis0.conf -lf /var/lib/dhcp/dhcpd-rndis0.leases
|
||||
fi
|
Loading…
Reference in New Issue
Block a user