tangetools/wifi-reload/wifi-reload

69 lines
1.5 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
sudo killall wpa_supplicant
sudo parallel -j1 modprobe -r ::: iwldvm ath9k ath9k_common mac80211 ath9k_hw ath cfg80211 ath3k
sleep 1
sudo killall -9 wpa_supplicant
parallel -j1 sudo modprobe ::: ath9k ath9k_common mac80211 ath9k_hw ath cfg80211 ath3k iwldvm
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
forever dmesg | puniq
fi