developer | 0a994c3 | 2022-02-09 10:39:21 +0800 | [diff] [blame] | 1 | --- a/package/base-files/files/etc/hotplug.d/net/00-sysctl 2022-02-09 17:30:24.308209645 +0800 |
| 2 | +++ b/package/base-files/files/etc/hotplug.d/net/00-sysctl 2022-02-09 21:01:24.392931550 +0800 |
| 3 | @@ -1,4 +1,29 @@ |
| 4 | #!/bin/sh |
| 5 | +# $1: module name |
| 6 | +# return value |
| 7 | +# 1: if the module named $1 is built-in or inserted. |
| 8 | +# 0: if the module exists but has not been inserted. |
| 9 | +# -1: if the module does not exist. |
| 10 | +module_exist() |
| 11 | +{ |
| 12 | + mpath="/lib/modules/`uname -r`" |
| 13 | + retval=-1 |
| 14 | + mod_in_lib=`find $mpath -name "$1".ko > /dev/null 2>&1` |
| 15 | + #echo "find $mpath -name "$1".ko" > /dev/console |
| 16 | + if [ ! -z $mod_in_lib ]; then |
| 17 | + retval=0 |
| 18 | + fi |
| 19 | + # TODO find out a way in OpenWRT |
| 20 | + mod_builtin=`grep $1 $mpath/modules.builtin 2>/dev/null` |
| 21 | + if [ ! -z "$mod_builtin" ]; then |
| 22 | + retval=1 |
| 23 | + fi |
| 24 | + mod_inserted=`lsmod | grep $1 2>/dev/null` |
| 25 | + if [ ! -z "$mod_inserted" ]; then |
| 26 | + retval=1 |
| 27 | + fi |
| 28 | + echo $retval |
| 29 | +} |
| 30 | |
| 31 | if [ "$ACTION" = add ]; then |
| 32 | for CONF in /etc/sysctl.d/*.conf /etc/sysctl.conf; do |
| 33 | @@ -6,4 +31,11 @@ |
developer | 11a1774 | 2021-05-18 15:28:31 +0800 | [diff] [blame] | 34 | sed -ne "/^[[:space:]]*net\..*\.$DEVICENAME\./p" "$CONF" | \ |
| 35 | sysctl -e -p - | logger -t sysctl |
| 36 | done |
developer | 0a994c3 | 2022-02-09 10:39:21 +0800 | [diff] [blame] | 37 | + is_mac80211=$(module_exist "mt76") |
developer | 11a1774 | 2021-05-18 15:28:31 +0800 | [diff] [blame] | 38 | + |
developer | 0a994c3 | 2022-02-09 10:39:21 +0800 | [diff] [blame] | 39 | + if [ "$is_mac80211" = "1" ]; then |
developer | a2c52f5 | 2022-02-18 09:49:01 +0800 | [diff] [blame] | 40 | + [ -f /sbin/smp-mt76.sh ] && /sbin/smp-mt76.sh |
developer | 0a994c3 | 2022-02-09 10:39:21 +0800 | [diff] [blame] | 41 | + else |
| 42 | + [ -f /sbin/smp.sh ] && /sbin/smp.sh |
| 43 | + fi |
developer | 11a1774 | 2021-05-18 15:28:31 +0800 | [diff] [blame] | 44 | fi |