diff --git a/scripts/_common.sh b/scripts/_common.sh index ef09b18..9fe1b65 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -26,6 +26,23 @@ function check_armbian_nonfree_conflict() } + +function hot_reload_usb_wifi_cards() +{ + modulesList="acx-mac80211 ar5523 ar9170usb at76c50x-usb at76_usb ath9k_htc carl9170 orinoco_usb p54usb prism2_usb r8712u r8192s_usb r8192u_usb rndis_wlan rt2500usb rt2800usb rt2870sta rt73usb rtl8187 rtl8192cu usb8xxx vt6656_stage zd1201 zd1211rw" + modprobe --quiet --remove $modulesList || true + possibleUsbDevicesNeedingReload=$(dmesg | grep -Pio '(?<=usb )[0-9-]+(?=:.*firmware)' | sort | uniq) + for usbPath in $possibleUsbDevicesNeedingReload; do + if [[ -f "/sys/bus/usb/devices/$usbPath/authorized" ]]; then + echo "Try to reload driver for usb $usbPath" >&2 + echo 0 > /sys/bus/usb/devices/$usbPath/authorized + echo 1 > /sys/bus/usb/devices/$usbPath/authorized + # Wait for driver reloading + sleep 2 + fi + done +} + #================================================= # EXPERIMENTAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index ebf038c..6ae580e 100644 --- a/scripts/install +++ b/scripts/install @@ -168,6 +168,7 @@ if [[ ! -v ip6_net ]]; then # if ip6_net not set fi fi +hot_reload_usb_wifi_cards wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }') ynh_app_setting_set --app=$app --key=multissid --value=1 diff --git a/scripts/restore b/scripts/restore index 62e46a8..551f17b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -140,6 +140,7 @@ yunohost service add $service_name --description "Creates a Wi-Fi access point" #================================================= ynh_script_progression --message="Starting a systemd service..." +hot_reload_usb_wifi_cards wifi_device=$(bash ../settings/conf/iw_devices | awk -F\| '{ print $1 }') if [[ -z $wifi_device ]]; then diff --git a/scripts/upgrade b/scripts/upgrade index 7b67c31..38f151d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -206,6 +206,7 @@ yunohost service add $service_name --description "Creates a Wi-Fi access point" #================================================= ynh_script_progression --message="Starting a systemd service..." +hot_reload_usb_wifi_cards wifi_device=$(bash ../conf/iw_devices | awk -F\| '{ print $1 }') if [[ -z $wifi_device ]]; then