Help needed to add scheduling to a small rc.d script
    Pietro Sammarco 
    pietro.bsdml at gmail.com
       
    Thu May 29 16:16:17 UTC 2014
    
    
  
Hello everyone,
let me begin saying I know very little about sh scripting and shell
scripting in general, so by reading here and there I have managed to create
a small sh scrip that ping google.com and if the ping timed out it will
take wlan0 down, take it back up and run dhclient on it.
Essentially what I need to do is to add a 30 seconds scheduling time to
this script, so that each and every 30 seconds it will check if
google.comis pingable, and if not it will do what the script it
supposed to do, and
at the same time I want to keep the start and stop feature.
Lastly, the main reason why I need to make this script is because when my
laptop resumes from suspending ( hw.acpi.lid_switch_state ) the wireless
goes numb, and those steps are required for the OS to associate with the AP
again, and becase this laptop is not always connected through wireless and
sometimes it act as gateway sharing the connection from the ethernet card
to the wireless card, I would rather avoid to make this script a cronjob.
Here's the mini script itself
Thanks
#!/bin/sh
. /etc/rc.subr
name="resumewlan"
start_cmd="resumewlan_start"
stop_cmd="resumewlan_stop"
if ! [ "`ping -c 1 google.com`" ]; then
    ifconfig wlan0 down & ifconfig wlan0 up & dhclient wlan0
#if ping timed out, takes down the wireless, takes it back up and executes
dhlient on it
   fi
    
    
More information about the freebsd-rc
mailing list