Abhinav
Posts: 6
Joined: Wed Oct 17, 2012 4:45 pm

[Help] Creating a netctl startup wrapper code

Sat Dec 27, 2014 2:51 pm

Hi

I have a small issue with my Belkin USB Wifi (model: F7D1101). I have to continuously restart netctl till it connects to my wifi. So I want to create a small python script which would check the following in an ordered way:

1) Check if the wifi dongle is connected to a USB port. If it isn't, abort.
2) Check if the wifi profile is present in /etc/netctl/ . If not then abort.
3) Start a loop which would call netctl using "popen". The loop will continue till the router is 'ping-able'.
4) As soon as the router returns a packet, stop all processes called by popen and exit with status 0

I have tried my best to explain the algorithm in short. I am thinking of using Python2.7, ping, usbid and popen to reach the goal.
I just want to know if my approach is feasible or is there a better way to do it.

And yes I am using Arch Linux ARM.

Thanking in advance.

Abhinav :)

sdjf
Posts: 1395
Joined: Fri Mar 16, 2012 5:20 am
Location: California
Contact: Website

Re: [Help] Creating a netctl startup wrapper code

Wed Dec 31, 2014 2:08 am

I don't know if there is a better way to do this, but you certainly can write a script to do what you need to do.

And if you discover better ways to implement the various steps, you can modify your script accordingly. I script going online via dialup using bash, so the issues are different, but it takes the tedium out of redialing to have the script do all that is needed for me.

Some cool things you might want to add, once your basic script is working, might be popups (using xmessage, dialog, or xdialog) to inform you of various things. At this point, since I go off and do other things while my dialer script is doing it's thing, I now have the script play a sound clip on my speakers when the Pi is finally online.
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

Return to “Arch”