DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default autoconnect to wifi (script)

In order to automatize connection to the several wifi network in which my opebsd netbook travel, I tried to write a small script. Here it is :

Code:
#!/bin/sh

CONF=/etc/wifi-conf

. $CONF

# void any previous conf
ifconfig $IF -nwid -wpakey

# scan wifi network, list them by network name, and get rid any "nwid" still there
SCAN=`ifconfig $IF scan|grep nwid|cut -d" " -f 2|sed '/nwid/d'`

# read the list of known nets
while read line
do
	# the first args of each line is the net name
	NET=`echo $line|cut -d" " -f 1`

	# the second is the key
	KEY=`echo $line|cut -d" " -f 2`

	# we compare the name to the list of scanned nets
	for ID in $SCAN
	do
		if [ $NET = $ID ]; then
			ifconfig $IF nwid $ID wpakey $KEY
			ifconfig $IF up
			
			if [ $AICCU ]
			then
				aiccu start
			fi
		fi
	done

done < $LIST
The objective is that, as soon as the laptop find a network that I have credentials, it connects. Currently, this does not work at all and it's painfull !

If someone has knowledge of a script working for that purpose, I would use it of course !

Here is the conf :

Code:
IF=ral0

AICCU=true
RTSOL=true
DHCP=true

LIST=/etc/wifi-net
and the list of known nets :

Code:
decembre kalCkucakospevPOFardOs9Droy
NET4LD 2468000
Stjernen2 Vejlby2
Reply With Quote
  #2   (View Single Post)  
Old 20th January 2015
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 305
Default

Quote:
Originally Posted by 22decembre View Post
Currently, this does not work at all
What's not working? What does it do, what does it not do?

You don't seem to be running dhclient but I don't even know if you make it that far...

Tim.
Reply With Quote
  #3   (View Single Post)  
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default

Quote:
Originally Posted by TronDD View Post
What's not working? What does it do, what does it not do?
It connects often to a network I can't use.

Quote:
Originally Posted by TronDD View Post
You don't seem to be running dhclient but I don't even know if you make it that far...
I placed rtsol and dhcp request in hostname.ral0. I expect that it works when upping ral0.

Apparently not !

So at the end, yes I should dhcp, rtsol and aiccu if I don't have native ipv6 (which I have at home, but not in the two other networks.

But first, I would like that it connect/get an active link to a network I am allowed / have the credentials.
Reply With Quote
  #4   (View Single Post)  
Old 20th January 2015
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 305
Default

I don't have wifi on this system so I can't try the script as a whole.

I'd echo the value of ID and NET just before you compare them and make sure you are seeing expected values. Then if it's an ifconfig issue, we can focus on that.

Ifconfig doesn't use hostname.if, /etc/netstart does.

My solution to this problem, instead of maintaining a bunch of extra files, would be to configure each access point in hostname.if.nwid and then use the script to copy the right file as hostname.if and and run netstart.

Tim.
Reply With Quote
  #5   (View Single Post)  
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default

Quote:
Originally Posted by TronDD View Post
My solution to this problem, instead of maintaining a bunch of extra files, would be to configure each access point in hostname.if.nwid and then use the script to copy the right file as hostname.if and and run netstart.
Quite a smart idea ! Yet, I don't know... Will try.
Reply With Quote
  #6   (View Single Post)  
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default

Currently, it works.

Will test in real conditions tomorrow (as I am going in the two other networks).
Reply With Quote
  #7   (View Single Post)  
Old 20th January 2015
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

The ksh(1) -x option is your friend.
Reply With Quote
  #8   (View Single Post)  
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default

Just a few remarks as of last experiments for today :

I don't know why but "rtsol" alone doesn't work in this precise environnement, thus, I don't have ipv6 whereas I have native here (at home). To have it, I had to run it like a command at the end of my hostname file for the local network.

Code:
...
blabla...
up
dhcp
rtsol
!rtsol ral0
I launch the script through rc.local. It loads after slim. And bizarrely, slim doesn't run anymore after it. So I launch a graphical session after a text login.
Reply With Quote
  #9   (View Single Post)  
Old 20th January 2015
ibara ibara is offline
OpenBSD language porter
 
Join Date: Jan 2014
Posts: 783
Default

Quote:
Originally Posted by 22decembre View Post
I don't know why but "rtsol" alone doesn't work in this precise environnement
Heads up:
http://marc.info/?l=openbsd-cvs&m=141923963522262&w=2
You likely want this:
http://marc.info/?l=openbsd-cvs&m=140897526404246&w=2
Reply With Quote
Old 20th January 2015
22decembre 22decembre is offline
Port Guard
 
Join Date: Dec 2014
Posts: 42
Default

I Tried autoconf, and it failed indeed. But not inet6 autoconf.

Thanks !
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
wifi performance (rum) mickywicky OpenBSD General 11 25th October 2013 03:08 PM
wifi secured with 802.1x EAP petter OpenBSD General 1 13th March 2013 09:16 AM
DesktopBSD & usb wifi radtek FreeBSD General 1 10th September 2008 09:13 PM
Two FW + WiFi AP Inquiry revzalot OpenBSD Security 4 14th July 2008 11:24 PM
Any wifi enthusiasts here? PatrickBaer General software and network 14 1st July 2008 01:45 PM


All times are GMT. The time now is 01:20 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick