Hi Community!
I'm a happy owner of a ridiculous Freenas installation running on 6-year-old Lenovo laptop through USB network adapter and with new drives that are connected through SATA II & SATA III . Yeah, way to go, I know :D Works good enough anyway.
For some time I had issues with my router (until provider replaced it), in particular, it was rebooting from time to time. On Freenas side this resulted in total net loss. So I had to kneel down by the wall, open the old pal praying 6-year old Lenovo plastic doesn't fall apart into atoms in my hands, and either manually reboot or to try fix the net.
It was troublesome enough so I wrote a couple of scripts that are intended to be used in this situation. I would like your "code review" on them from the FreeNas specifics standpoint. For instance, I spent days torturing
Script #1 - this one is called every 5 minutes by Cron:
Script #2 - this is the "fixnet.sh". I made it a separate script to be able to call it manually when/if needed. "ue0" is the USB Ethernet.
Ping google is added so that when executing manually, I can see the proof with my own eyes.
Now this box successfully survives temporary power loss, router reboots and updates etc.
What do you think of the scripts above?
I'm a happy owner of a ridiculous Freenas installation running on 6-year-old Lenovo laptop through USB network adapter and with new drives that are connected through SATA II & SATA III . Yeah, way to go, I know :D Works good enough anyway.
For some time I had issues with my router (until provider replaced it), in particular, it was rebooting from time to time. On Freenas side this resulted in total net loss. So I had to kneel down by the wall, open the old pal praying 6-year old Lenovo plastic doesn't fall apart into atoms in my hands, and either manually reboot or to try fix the net.
It was troublesome enough so I wrote a couple of scripts that are intended to be used in this situation. I would like your "code review" on them from the FreeNas specifics standpoint. For instance, I spent days torturing
jail command until I read your puthon scripts and understood I needto actually call iocage :)Script #1 - this one is called every 5 minutes by Cron:
Code:
ping -c 1 google.ie
if [ $? != 0 ]
then
./fixnet.sh
else
if [ "$1" = "-v" ]
then
echo "Test successful."
fi
fiScript #2 - this is the "fixnet.sh". I made it a separate script to be able to call it manually when/if needed. "ue0" is the USB Ethernet.
Code:
service netif onerestart
ifconfig ue0 up
service routing restart
service dhclient forcerestart ue0
service smbd restart
service nmbd restart
ping -c 1 google.com
jls | grep -v JID | awk '{system("iocage restart " $2)}'
Ping google is added so that when executing manually, I can see the proof with my own eyes.
Now this box successfully survives temporary power loss, router reboots and updates etc.
What do you think of the scripts above?