Shell script to activate wlan0 access point mode when eth0 is offline

#!/bin/bash ifup='/sbin/ifup' ifdown='/sbin/ifdown' ifconfig='/sbin/ifconfig' hostapd='/usr/sbin/hostapd' x=`ping -c1 2>&1 | grep unknown` if [ ! "$x" = "" ]; then $ifup wlan0 $hostapd -B /etc/hostapd/hostapd.conf fi x2=`ping -c1 2>&1 | grep received` if [ ! "$x2" = "" ]; then $ifdown wlan0 killall hostapd fi

I’m using this script on bananapipro to activate ap wlan0 mode when due to electric loss at home or router wlan0 failure.At my setup, i’m using a 650va ups to backup bananapipro but due to docsis3.0 while power loss internet link becomes fail too so my modem and router isn’t on the ups line, waste of energy at times like that and only bananapi works on ups line and fires up wlan0 an ap to provide a wireless local network.Using a cron job to run this command on every five minutes.

*/5 * * * * root /root/ > /dev/null 2>&1






Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir