summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authormickybart2016-06-03 20:35:24 -0400
committermickybart2016-06-03 20:35:24 -0400
commit789d5a045bc72096570427337dbad46f15e391ed (patch)
tree1c2c8a287328624fbe412420426fa7d4c8e500eb
downloadaur-789d5a045bc72096570427337dbad46f15e391ed.tar.gz
initial: hybris-usb
rndis mode for Android USB (not a full tethering because the dhcp is not configured to provide a default route. For now this package provide a way to access the Android device) This package is (at least) used for the GNU/Linux for Android devices project: https://github.com/mickybart/gnulinux_support
-rw-r--r--.SRCINFO21
-rw-r--r--PKGBUILD51
-rw-r--r--dhcpd.conf5
-rw-r--r--dhcpd4.service-customexec.conf4
-rw-r--r--tmpfiles.d.hybris-usb.conf2
-rw-r--r--usb-tethering63
-rw-r--r--usb-tethering.service10
7 files changed, 156 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..b455b0207e12
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,21 @@
+pkgbase = hybris-usb
+ pkgdesc = USB control for Android with hybris
+ pkgver = 0.1
+ pkgrel = 2
+ arch = armv7h
+ license = custom
+ depends = systemd
+ depends = dhcp
+ source = usb-tethering
+ source = usb-tethering.service
+ source = dhcpd.conf
+ source = dhcpd4.service-customexec.conf
+ source = tmpfiles.d.hybris-usb.conf
+ md5sums = 2d270508c91e94997236e5dacd7bbc8d
+ md5sums = 7976b6c3d662802cc54e3458ec3b891e
+ md5sums = 8d25b1c3f1146635800db77f300b908c
+ md5sums = 0aff78dea49297c615946ee310c49a6b
+ md5sums = 91422a3f2a69c9800d25cd65358fe5df
+
+pkgname = hybris-usb
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..eb318a0b8689
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,51 @@
+# Maintainer: Michaƫl Serpieri <mickybart@pygoscelis.org>
+
+pkgname=hybris-usb
+pkgver=0.1
+pkgrel=2
+pkgdesc="USB control for Android with hybris"
+arch=('armv7h')
+url=""
+license=('custom')
+provides=()
+depends=('systemd' 'dhcp')
+options=()
+source=('usb-tethering'
+ 'usb-tethering.service'
+ 'dhcpd.conf'
+ 'dhcpd4.service-customexec.conf'
+ 'tmpfiles.d.hybris-usb.conf')
+md5sums=('2d270508c91e94997236e5dacd7bbc8d'
+ '7976b6c3d662802cc54e3458ec3b891e'
+ '8d25b1c3f1146635800db77f300b908c'
+ '0aff78dea49297c615946ee310c49a6b'
+ '91422a3f2a69c9800d25cd65358fe5df')
+
+build() {
+ cd "${srcdir}"
+
+}
+
+package() {
+ cd "${srcdir}"
+
+ # usb tethering
+
+ install -d ${pkgdir}/usr/bin
+ install -m 755 usb-tethering ${pkgdir}/usr/bin/
+
+ install -d ${pkgdir}/usr/lib/systemd/system/
+ install -m 644 usb-tethering.service ${pkgdir}/usr/lib/systemd/system/
+
+ # dhcpd configuration
+
+ install -d ${pkgdir}/usr/lib/tmpfiles.d/
+ install -m 644 tmpfiles.d.hybris-usb.conf ${pkgdir}/usr/lib/tmpfiles.d/hybris-usb.conf
+
+ install -d ${pkgdir}/etc/systemd/system/dhcpd4.service.d/
+ install -m 644 dhcpd4.service-customexec.conf ${pkgdir}/etc/systemd/system/dhcpd4.service.d/customexec.conf
+
+ install -d ${pkgdir}/etc/hybris-usb/
+ install -m 644 dhcpd.conf ${pkgdir}/etc/hybris-usb/
+}
+
diff --git a/dhcpd.conf b/dhcpd.conf
new file mode 100644
index 000000000000..d7600ea7e4dc
--- /dev/null
+++ b/dhcpd.conf
@@ -0,0 +1,5 @@
+option domain-name-servers 8.8.8.8, 8.8.4.4;
+option subnet-mask 255.255.255.0;
+subnet 10.15.19.0 netmask 255.255.255.0 {
+ range 10.15.19.100 10.15.19.254;
+}
diff --git a/dhcpd4.service-customexec.conf b/dhcpd4.service-customexec.conf
new file mode 100644
index 000000000000..9b1b1394a483
--- /dev/null
+++ b/dhcpd4.service-customexec.conf
@@ -0,0 +1,4 @@
+[Service]
+PIDFile=/run/hybris-usb/dhcpd4.pid
+ExecStart=
+ExecStart=/usr/bin/dhcpd -4 -q -cf /etc/hybris-usb/dhcpd.conf -pf /run/hybris-usb/dhcpd4.pid -lf /run/hybris-usb/dhcpd4.lease
diff --git a/tmpfiles.d.hybris-usb.conf b/tmpfiles.d.hybris-usb.conf
new file mode 100644
index 000000000000..69e776d221ac
--- /dev/null
+++ b/tmpfiles.d.hybris-usb.conf
@@ -0,0 +1,2 @@
+d /run/hybris-usb 0755 root root
+f /run/hybris-usb/dhcpd4.lease 0644 root root
diff --git a/usb-tethering b/usb-tethering
new file mode 100644
index 000000000000..bbbc5667c2ae
--- /dev/null
+++ b/usb-tethering
@@ -0,0 +1,63 @@
+#!/bin/bash
+
+####
+# Default profile
+USB_IDVENDOR=0fce
+USB_IDPRODUCT=7169
+USB_IPRODUCT="Unknown"
+USB_ISERIAL="Unknown"
+USB_IMANUFACTURER="GNU/Linux Device"
+USB_IFACE=""
+
+####
+# Override profile
+if [ -f /etc/default/hybris-device ]; then
+ source /etc/default/hybris-device
+fi
+
+ANDROID_USB=/sys/class/android_usb/android0
+USB_FUNCTIONS=rndis
+LOCAL_IP=10.15.19.82
+
+write() {
+ echo -n "$2" > "$1"
+}
+
+usb_setup() {
+ write $ANDROID_USB/enable 0
+ write $ANDROID_USB/idVendor $USB_IDVENDOR
+ write $ANDROID_USB/idProduct $USB_IDPRODUCT
+ write $ANDROID_USB/iManufacturer "$USB_IMANUFACTURER"
+ write $ANDROID_USB/iProduct "$USB_IPRODUCT"
+ write $ANDROID_USB/iSerial "$USB_ISERIAL"
+ write $ANDROID_USB/functions $USB_FUNCTIONS
+ write $ANDROID_USB/enable 1
+}
+
+usb_info() {
+ write $ANDROID_USB/iSerial "$1"
+}
+
+ip_setup() {
+ if [ -n "$USB_IFACE" ]; then
+ ifconfig $USB_IFACE $LOCAL_IP
+ return
+ fi
+
+ ifconfig rndis0 $LOCAL_IP && USB_IFACE=rndis0
+ if [ -z "$USB_IFACE" ]; then
+ ifconfig usb0 $LOCAL_IP && USB_IFACE=usb0
+ fi
+
+ if [ -z "$USB_IFACE" ]; then
+ usb_info "could not setup USB tethering!"
+ return 1
+ fi
+
+ usb_info "$USB_IMANUFACTURER on $USB_IFACE $LOCAL_IP"
+}
+
+usb_setup
+ip_setup
+
+exit $?
diff --git a/usb-tethering.service b/usb-tethering.service
new file mode 100644
index 000000000000..f2ae6b7ec40f
--- /dev/null
+++ b/usb-tethering.service
@@ -0,0 +1,10 @@
+# systemd service file for usb-tethering
+
+[Unit]
+Wants=dhcpd4.service
+Description=USB Tethering
+ConditionPathExists=/sys/class/android_usb/android0
+
+[Service]
+Type=oneshot
+ExecStart=/bin/bash /usr/bin/usb-tethering