tangetools/wifi-reload/wifi-reload
Ole Tange f6a34e1200 transpose: parallelized.
w4it-for-port-open: -q (quiet) implemented.
2018-03-27 02:56:54 +02:00

77 lines
1.8 KiB
Bash
Executable file

#!/bin/bash
: <<=cut
=encoding utf8
=head1 NAME
wifi-reload - reload wifi setup
=head1 SYNOPSIS
B<wifi-reload>
=head1 DESCRIPTION
Sometimes the wifi config gets stuck. B<wifi-reload> tries to get the
config unstuck by reloading modules, wpa_supplicant and
NetworkManager.
=head1 AUTHOR
Copyright (C) 2017 Ole Tange,
http://ole.tange.dk and Free Software Foundation, Inc.
=head1 LICENSE
Copyright (C) 2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
at your option any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=head1 SEE ALSO
B<bash>(1)
=cut
modules="iwl4965 iwl3945 iwldvm ath9k ath9k_common ath9k_hw ath ath3k brcmfmac rt73usb rt2x00lib cfg80211 mac80211"
sudo killall wpa_supplicant
sudo parallel -j0 --delay 0.03 --retries 50 modprobe -r ::: $modules
sudo killall -9 wpa_supplicant
parallel -j1 sudo modprobe ::: $modules
sudo rfkill unblock all
PID=$(sudo NetworkManager 2>&1 | grep -Eo '[0-9]+')
sudo kill $PID || sudo killall NetworkManager
sleep 1
sudo kill -9 $PID
#sudo NetworkManager &
if tty -s ; then
# STDIN is terminal
timeout 12 dmesg -Tw
# timeout 12 forever dmesg | puniq
fi
#sudo bash -c 'cat >> /etc/resolv.conf' < /etc/resolvconf/resolv.conf.d/head
#sudo iwconfig wls1 essid Turris
#sudo dhclient wls1 &
#sudo wpa_supplicant -Dwext -c/etc/wpa_supplicant.conf -iwls1 -d &