WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Resolved] Autostart wireless connection on EeePC 901  (Read 13609 times)

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
[Resolved] Autostart wireless connection on EeePC 901
« on: January 22, 2009, 03:06:36 AM »
Just got TC frugal working very well on my EeePC 901.
However, still one or two small problems.
In particular, although I'm using the "tce=hdXY" and "restore=hdXY" boot codes, I still have to go through a bit of a rigmarole to get my wireless connection after boot.
This involves two steps:
1. Using AppBrowser to load both wireless_tools.tcel and wpa-supplicant.tce which remain saved to /home/tc (as does the wireless driver)
2. Run this script to launch the wireless connection
Code: [Select]
#!/bin/sh
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254

To streamline this procedure, I would like to add the extension loading to the script but I can't figure out how. Using "tar -zxvf" seems to only partly achieve this.
Any clues?
Assuming this is possible, the next step would be to autostart the script so that the connection is available immediately after boot. Does TC handle autostarting?
« Last Edit: January 24, 2009, 06:18:26 AM by paulfxh »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14544
Re: How to load extension from CLI?
« Reply #1 on: January 22, 2009, 03:13:33 AM »
Here's what I use for a similar task:
Code: [Select]
#!/bin/sh -e
#
tce-load /mnt/sda1/source/buildtc/08_09_05/b43_firmware.tce
tce-load /mnt/sda1/extensions/wireless_tools.tcel
#
tce-load /mnt/sda1/extensions/wireless-2.6.26.tcem
tce-load /mnt/sda1/extensions/misc-2.6.26.tcem
tce-load /mnt/sda1/extensions/hwmon-cpufreq-2.6.26.tcem
#
sudo modprobe b43
#
sleep 5
sudo iwconfig wlan0 essid "ssid"
sudo iwconfig wlan0 key restricted 7D:3A:7C:72:F7:9A:6F:91:DF:CF:C9:AD:CE
#
sudo udhcpc -b -i wlan0
#
# EOF

If you call your script from bootlocal.sh, it will start on boot

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: How to load extension from CLI?
« Reply #2 on: January 22, 2009, 03:58:50 AM »
Quote
1. Using AppBrowser to load both wireless_tools.tcel and wpa-supplicant.tce which remain saved to /home/tc (as does the wireless driver)[/quote

Move your extensions to your tce directory as specified by the tce boot code.
They will auto load. Saving you from having to use appbrowser to manually load them.

Storing extensions in home dir only slows down the backup.
Factorization of static vs dynamic content is a principle of TC.
Extensions, code, is static. You should not have to be saving code eveytime.

Your boot time script to configure wireless can be stored in /opt/bootlocal.sh or could be made into a personal .tce.
10+ Years Contributing to Linux Open Source Projects.

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
Re: How to load extension from CLI?
« Reply #3 on: January 22, 2009, 08:20:41 AM »
Thank you for the replies.
Moving both wireless_tools.tcel and wpa-supplicant.tce from /home/tc/ to /mnt/hdd7/tce nicely eliminated the need to load these two extensions after booting.
However, I had less success in getting the wireless configuration script to complete during the boot.
As suggested I added my script to /opt/bootlocal.sh which now looks like this:
Code: [Select]
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
sudo su
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
However, running the script (as root) after the boot works just as well as before.
Two possible reasons for this failure is that network configuration commands (like iwconfig) only run as root. I tried to include a "sudo su" line in the script but this didn't work.
Another possibility is that the script runs before the wireless_tools have had a chance to load in which case iwconfig will not be available.
Any clues?

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10961
Re: How to load extension from CLI?
« Reply #4 on: January 22, 2009, 08:25:35 AM »
bootlocal already runs as root, the sudo su is not needed.
Perhaps this is a timing problem, try inserting "sleep 5" as the first command after #!/bin/sh to wait 5 secs.
The only barriers that can stop you are the ones you create yourself.

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
Re: How to load extension from CLI?
« Reply #5 on: January 22, 2009, 12:24:08 PM »
Unfortunately, putting in the "sleep 5" line in the bootlocal.sh script didn't get me any further.
Indeed, I tried sleep 10, sleep 60 and sleep 300 but none of them worked. What was noticeable, however, was that there was no indication at all that the boot was being prolongued by the time included in the "sleep" line.
In fact, for "sleep 300", the script didn't seem to run at all as typing  "iwconfig" after boot did not show the ra0 interface.
Other things I tried were:
1. Load both wireless_tools and wpa-supplicant as part of the bootlocal.sh script using the commands shown in Juanito's post to make sure that wireless_tools were indeed loaded before needing to use iwconfig in the script
2. Include my script as part of ra0.sh which itself is part of the bootlocal.sh script.
However, neither of these caused any improvement.
This is very puzzling as I've already used very similar scripts to autostart wireless connections in some other OSes on this EeePC 901.
Perhaps somebody else can see what might be wrong here?
 

Offline ^thehatsrule^

  • Administrator
  • Hero Member
  • *****
  • Posts: 1726
Re: How to load extension from CLI?
« Reply #6 on: January 22, 2009, 12:51:40 PM »
That's because bootlocal.sh is backgrounded.  If you put "sleep 300" in it, you would have to wait 5 min after boot for the rest of the script to be executed.

Also, note that tce-load will not run as root.

What's in the /opt/ra0.sh and ra00.sh?

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
Re: How to load extension from CLI?
« Reply #7 on: January 22, 2009, 01:44:53 PM »
/opt /ra0.sh now looks like this
Code: [Select]
#!/bin/sh
pkill udhcpc
ifconfig ra0 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf
#cd /home/tc
#cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
#depmod -a
#modprobe rt2860sta
#ifconfig ra0 up
#iwconfig ra0 key open
#iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
#iwconfig ra0 essid "xxxxxxxxxxxxxxx"
The commented-out stuff is what I had added in one of my "experiments".
Here below is /opt/ra00.sh
Code: [Select]
#!/bin/sh
pkill udhcpc
ifconfig ra00 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255 up
route add default gw 192.168.1.254
echo nameserver 208.67.222.222 > /etc/resolv.conf
echo nameserver 208.67.220.220 >> /etc/resolv.conf

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14544
Re: How to load extension from CLI?
« Reply #8 on: January 22, 2009, 08:01:49 PM »
1. Load both wireless_tools and wpa-supplicant as part of the bootlocal.sh script using the commands shown in Juanito's post to make sure that wireless_tools were indeed loaded before needing to use iwconfig in the script
In case it wasn't clear, I don't call the script via bootlocal.sh and I run the script as user tc - since I'm using tc in development/testing mode 95% of the time, I don't have a backup.

If you did want to load an extension via bootlocal.sh, I guess you could use "su tc tce-load /path/extension"
« Last Edit: January 22, 2009, 08:03:59 PM by Juanito »

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
Re: How to load extension from CLI?
« Reply #9 on: January 23, 2009, 04:40:03 AM »
@Juanito
Thanks for those comments.
Quote
I don't call the script via bootlocal.sh and I run the script as user tc
Do you, therefore, run the script during the boot but not as root?
If so, how do you do that?
I'm fairly convinced now that my problem is that I can't get wireless_tools loaded before my script runs with the result that the three "iwconfig" commands don't function.
As bootlocal.sh runs as root, and "tce-load" cannot be run as root, I've got a problem.
I did, of course, try your suggestion
Quote
If you did want to load an extension via bootlocal.sh, I guess you could use "su tc tce-load /path/extension"
but this didn't work for me.
Indeed, If I run the script (after boot) in a root terminal, the two "tce-load" lines give me this error:
Quote
sh: can't open tce-load
So, in summary I believe what I need are either a) a means to allow the wireless_tools and wpa-supplement tce's to be loaded from bootlocal.sh or b) some way to get a script to be run during, or immediately after (but automatically), the boot other than through bootlocal.sh

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14544
Re: How to load extension from CLI?
« Reply #10 on: January 23, 2009, 05:13:46 AM »
Quote
Do you, therefore, run the script during the boot but not as root?
Sorry, no - I run it after boot

"su dsl mydsl-load /path/extension" works in dsl from bootlocal.sh, but (as you say) "su tc tce-load /path/extension" does not work in tc.

Looking at mydsl-load and tce-load, the tests for user are different - perhaps roberts would consider changing the test in tce-load to allow loading extensions from bootlocal.sh with "su tc tce-load /path/extension"?

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: How to load extension from CLI?
« Reply #11 on: January 23, 2009, 06:31:32 AM »
TC uses a different default shell than DSL. However, I don't understand why one would want to manually maintain and load extensions from bootlocal.sh when there are already the options of autoloading at boot or manually loading from optional directory. All extensions load before /opt/bootlocal.sh is started. In fact as I pointed out in the opera/flash thread that order of tces before tczs are important. So what would be the benefit of delaying extension loading? It would seem to me to have more of a 'timing' issue? Perhaps not backgrounding /opt/bootlocal.sh would be better? I have no issue with my wireless extensions in tce directory and configuration in /opt/bootlocal.sh Given the fact that autoloading the wireless extensions from tce directory then manually running your script is successful would suggest no need to  move extension loading.
10+ Years Contributing to Linux Open Source Projects.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10961
Re: How to load extension from CLI?
« Reply #12 on: January 23, 2009, 07:08:50 AM »
Quote
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
sudo su
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
I think the part where this fails is that there is no ra0 interface when the ra0 and ra00 scripts are run, and that the sleep should be inserted after the modprobe. I don't think the backgrounding has anything to do with this. paulfxh, try this as bootlocal.sh:
Quote
#!/bin/sh
# put other system startup command here
PATH=$PATH:/usr/local/sbin
pkill udhcpc
cp /home/tc/rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
sleep 10
ifconfig ra0 up
iwconfig ra0 key open
iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxx
iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
Since the script is backgrounded, you will need to wait that 10s before checking if your wireless is up.
« Last Edit: January 23, 2009, 08:13:48 AM by curaga »
The only barriers that can stop you are the ones you create yourself.

Offline roberts

  • Administrator
  • Hero Member
  • *****
  • Posts: 7361
  • Founder Emeritus
Re: How to load extension from CLI?
« Reply #13 on: January 23, 2009, 07:25:19 AM »
Hopefully this is it. I can reproduce the issue.

iwconfig was/is not being found in running of /opt/bootlocal.sh

The solution is to use full path to iwconfig.  /usr/local/sbin/iwconfig
It is best to use full pathing on everything in /opt/bootlocal.sh

To help troubleshoot  boot time processes, use the pause boot option.
10+ Years Contributing to Linux Open Source Projects.

Offline paulfxh

  • Newbie
  • *
  • Posts: 40
Re: How to load extension from CLI?
« Reply #14 on: January 23, 2009, 09:45:12 AM »
Yeah, that's it!!!  :D
Everything working fine now.
This is my bootlocal.sh and startwifi (my script slightly munged) if anybody else wants to do something similar:

bootlocal.sh
Code: [Select]
#!/bin/sh
# put other system startup command here
/opt/ra0.sh &
/opt/ra00.sh &
/home/tc/startwifi &

startwifi
Code: [Select]
#!/bin/sh
cd /home/tc
cp rt2860sta.ko.gz /lib/modules/2.6.26-tinycore/kernel/drivers/net/
depmod -a
modprobe rt2860sta
sleep 15
ifconfig ra0 up
/usr/local/sbin/iwconfig ra0 key open
/usr/local/sbin/iwconfig ra0 key xxxxxxxxxxxxxxxxxxxxxxxxxx
/usr/local/sbin/iwconfig ra0 essid "xxxxxxxxxxxxxxx"
ifconfig ra0 192.168.1.5 netmask 255.255.255.0
route add default gw 192.168.1.254
Perhaps I should move my script to /opt and I'll try to reduce the sleep time to a minimum.
Thanks to everybody for the suggestions.  :)