Created
June 13, 2015 19:28
-
-
Save lunatilia/79aa4aeb57589a54b571 to your computer and use it in GitHub Desktop.
Raspberry PiでWi-Fi接続が切れたときに自動で再接続させるスクリプト for Raspbian
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USSID="<自環境のSSIDを入力>" | |
IF_FILE="/etc/network/interfaces" | |
PARAM_GATEWAY=`grep -i gateway ${IF_FILE} | cut -f2 -d' '` | |
PARAM_ADDR=`grep -i address ${IF_FILE} | cut -f2 -d' '` | |
ping -c 4 ${PARAM_GATEWAY} > /dev/null 2>&1 | |
flag=$? | |
if [ $flag -ne 0 ]; then | |
/sbin/ifconfig wlan0 | grep inet | grep ${PARAM_ADDR} > /dev/null 2>&1 | |
flag=$? | |
if [ $flag -ne 0 ]; then | |
/sbin/iwconfig wlan0 | grep ${USSID} > /dev/null 2>&1 | |
flag=$? | |
if [ $flag -ne 0 ]; then | |
/etc/ifplugd/ifplugd.action wlan0 up | |
sleep 30 | |
/usr/sbin/service ntp restart | |
fi | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment