From 50ef03bf0a0506833303f34c050564ec5849279a Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 4 Oct 2024 19:14:16 +0200 Subject: [PATCH] Revert "rndis: remove" This reverts commit ac18f4dc41cde23687109b1d53dada30e0a53bf8. --- rndis/all/usr/bin/rndis.sh | 24 ++++++++++++++++++ rndis/install.sh | 51 ++++++++++++++++++++++++++++++++++++++ rndis/manifest.yml | 20 +++++++++++++++ 3 files changed, 95 insertions(+) create mode 100755 rndis/all/usr/bin/rndis.sh create mode 100755 rndis/install.sh create mode 100644 rndis/manifest.yml diff --git a/rndis/all/usr/bin/rndis.sh b/rndis/all/usr/bin/rndis.sh new file mode 100755 index 0000000..8701bdf --- /dev/null +++ b/rndis/all/usr/bin/rndis.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env ash +# +# Copyright (C) 2023 AuxXxilium and Ing +# +# This is free software, licensed under the MIT License. +# See /LICENSE for more information. +# + +for I in $(ls -d /sys/class/net/usb* 2>/dev/null); do + NAME=${I##*/} + /sbin/ifconfig ${NAME} up || true + if [ -x /usr/syno/sbin/synonet ]; then # DSM + /usr/syno/sbin/synonet --dhcp ${NAME} || true + fi + if [ -x /sbin/udhcpc ]; then # junior + if [ -f "/etc/dhcpc/dhcpcd-${NAME}.pid" ]; then + kill -9 $(cat /etc/dhcpc/dhcpcd-${NAME}.pid) + rm -f /etc/dhcpc/dhcpcd-${NAME}.pid + fi + /sbin/udhcpc -i ${NAME} -p /etc/dhcpc/dhcpcd-${NAME}.pid -b -x hostname:$(hostname) || true + fi +done + +exit 0 diff --git a/rndis/install.sh b/rndis/install.sh new file mode 100755 index 0000000..29bd4e1 --- /dev/null +++ b/rndis/install.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env ash +# +# Copyright (C) 2023 AuxXxilium and Ing +# +# This is free software, licensed under the MIT License. +# See /LICENSE for more information. +# + +if [ "${1}" = "rcExit" ]; then + echo "Installing addon rndis - ${1}" + + /usr/bin/rndis.sh +elif [ "${1}" = "late" ]; then + echo "Installing addon rndis - ${1}" + mkdir -p "/tmpRoot/usr/arc/addons/" + cp -vf "${0}" "/tmpRoot/usr/arc/addons/" + + cp -vf /usr/bin/rndis.sh /tmpRoot/usr/bin/rndis.sh + + mkdir -p /tmpRoot/usr/lib/udev/rules.d + echo 'SUBSYSTEMS=="net", KERNEL=="usb*", TAG+="systemd", ENV{SYSTEMD_WANTS}+="rndis.service"' >/tmpRoot/usr/lib/udev/rules.d/99-rndis.rules + chmod a+r /tmpRoot/usr/lib/udev/rules.d/99-rndis.rules + + mkdir -p "/tmpRoot/usr/lib/systemd/system" + DEST="/tmpRoot/usr/lib/systemd/system/rndis.service" + cat <${DEST} +[Unit] +Description=Android USB Network Adapter +After=multi-user.target +ConditionPathExists=/sys/class/net/usb0 + +[Service] +Type=simple +Restart=always +ExecStart=/usr/bin/rndis.sh + +[Install] +WantedBy=multi-user.target +EOF + + mkdir -vp /tmpRoot/usr/lib/systemd/system/multi-user.target.wants + ln -vsf /usr/lib/systemd/system/rndis.service /tmpRoot/usr/lib/systemd/system/multi-user.target.wants/rndis.service +elif [ "${1}" = "uninstall" ]; then + echo "Installing addon rndis - ${1}" + + rm -f "/tmpRoot/usr/lib/systemd/system/multi-user.target.wants/rndis.service" + rm -f "/tmpRoot/usr/lib/systemd/system/rndis.service" + + rm -f "/tmpRoot/usr/lib/udev/rules.d/99-rndis.rules" + rm -f "/tmpRoot/usr/bin/rndis.sh" +fi \ No newline at end of file diff --git a/rndis/manifest.yml b/rndis/manifest.yml new file mode 100644 index 0000000..b05f303 --- /dev/null +++ b/rndis/manifest.yml @@ -0,0 +1,20 @@ +version: 1 +name: rndis +description: "Android USB Network Adapter support" +system: false +beta: true +target: system +all: + install-script: "install.sh" + copy: "all" +apollolake: true +broadwell: true +broadwellnk: true +broadwellnkv2: true +broadwellntbap: true +denverton: true +geminilake: true +purley: true +v1000: true +r1000: true +epyc7002: true \ No newline at end of file