LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 08-12-2008, 11:57 AM   #1
MonctonJohn
Member
 
Registered: Aug 2007
Location: Canada
Distribution: Mint
Posts: 112

Rep: Reputation: 15
[Kubuntu] Which script initializes a USB wireless device once it is plugged in?


Here's the story. I have DansGuardian, tinyproxy and firehol working on my kid's computer. The issue is that the PC has a wireless usb adapter and when I reboot the PC after it gets an IP I always have to restart the three services for it to work. I would like to know which script sets up the wireless card and gives it an IP. I would like to insert some restart statements into this script so that I don't have to manually restart the three services. Any help is always appreciated.
 
Old 08-12-2008, 03:07 PM   #2
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 5,995

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
when I reboot the PC after it gets an IP I always have to restart the three services for it to work.
Why are you rebooting the computer after it gets an IP?
Quote:
I would like to know which script sets up the wireless card and gives it an IP.
This is configured in /etc/network/interfaces
Quote:
I would like to insert some restart statements into this script so that I don't have to manually restart the three services.
I don't think you want, or need, to restart them from the interfaces file.

Just put them into /home/USERNAME/.kde/Autostart and make them executable. For example in my /home/USERNAME/.kde/Autostart I have this file called localfixes :
Code:
#!/bin/bash
# Disable the stupid Caps Lock key, make it "Shift":
xmodmap -e "remove Lock = Caps_Lock"
xmodmap -e "add Shift = Caps_Lock"
# load the default nvidia settings (I like a dimmed screen)
nvidia-settings -l
The file is executable:
Code:
tred@vaio:~$ ls -al .kde/Autostart/localfixes
-rwxr-xr-x 1 tred tred 216 2008-06-15 17:20 .kde/Autostart/localfixes
Or, if you want them to run as root, call them just before the final exit 0 in /etc/rc.local
 
Old 08-12-2008, 06:43 PM   #3
MonctonJohn
Member
 
Registered: Aug 2007
Location: Canada
Distribution: Mint
Posts: 112

Original Poster
Rep: Reputation: 15
Quote:
Quote:
when I reboot the PC after it gets an IP I always have to restart the three services for it to work.
Why are you rebooting the computer after it gets an IP?
Oops... I should have been clearer. After I'm done working on it and I shut it down, the next day I boot it up and plug in the USB Wireless NIC then it gets an IP.

Quote:
Or, if you want them to run as root, call them just before the final exit 0 in /etc/rc.local
I do want them to run as root, but they have to be able to run at some point after the NIC is plugged in. rc.local runs at startup so this won't work for me I don't think. Somehow I want to restart these services after the NIC is configured with an IP.

Any ideas?
 
Old 08-13-2008, 02:16 AM   #4
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 5,995

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Perhaps take a look at the scripts in /etc/network/if-up.d/*
These seem to be executed after (any) interface comes up.

You'll need something like:
Code:
#! /bin/sh

if [ "$IFACE" = eth0 ]; then
	your commands here
fi
 
Old 08-13-2008, 06:58 AM   #5
MonctonJohn
Member
 
Registered: Aug 2007
Location: Canada
Distribution: Mint
Posts: 112

Original Poster
Rep: Reputation: 15
Quote:
Perhaps take a look at the scripts in /etc/network/if-up.d/*
Thanks.

I'll check it out tonight.

At work on Windoze. Can't play right now
 
Old 08-13-2008, 03:48 PM   #6
tredegar
Guru
 
Registered: May 2003
Location: London, UK
Distribution: Ubuntu 10.04, mostly
Posts: 5,995

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
Quote:
At work on Windoze. Can't play right now
That's why I have a tiny but fully functional Asus eee 701 - to "play" with at work. "Lunch 5-mins" and all that.
It is now running Kubuntu 8.04 perfectly, though a few tweaks were necessary. Goodbye Xandros

I just tried my suggestion for a solution for you:

I put this script into /etc/network/if-up.d/testing

Code:
#!/bin/bash
if [ "$IFACE" = eth1 ]; then
    echo eth1 was brought up at `date` >> /home/tred/eth_log
fi
And made it executable.

As root, I brought down my interface, then up again:

Code:
ifdown eth1
ifup eth1
The testing logfile appeared:

Code:
tred@vaio:~$ cat /home/tred/eth_log
eth1 was brought up at Wed Aug 13 21:40:36 BST 2008
And the resulting logfile is owned by root, so the script was run as root.

Therefore I would expect that you can run any arbitrary commands from such a script and they will be run after the interface is brought up.

Obviously, you'll need to change eth1 for whatever your relevant interface is called.

How much error-checking and reporting, you care to put into such a script is up to you (As you see, I have NONE, but it was just a test.)

Let us know how you get on.
 
Old 08-13-2008, 05:43 PM   #7
MonctonJohn
Member
 
Registered: Aug 2007
Location: Canada
Distribution: Mint
Posts: 112

Original Poster
Rep: Reputation: 15
Quote:
That's why I have a tiny but fully functional Asus eee 701 - to "play" with at work. "Lunch 5-mins" and all that.
It is now running Kubuntu 8.04 perfectly, though a few tweaks were necessary. Goodbye Xandros
I was able to use Ubuntu at work for a project for a while but we ran out of time and funds. I'm hoping something happens in the future so I can get back to it again.

Quote:
Let us know how you get on.
It works... after a little tweaking. Seems the whole tinyproxy/firehol/dansguardian is a little specific on which one needs to be started first so after playing with that it finally came up properly. Thanks for all the help tredegar. Now I just have to teach my daughter how to use it

btw: the ifup/ifdown commands didn't seem to work with my NIC. Complained about it not being configured. The NIC is call wlan0 so I don't know if that has anything to do with it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAT32 hd failure -plugged usb device Jose Rivas Fedora 2 04-03-2008 03:25 PM
How to detect programatically if a USB device is is plugged-in / plugged out? franc Linux - Software 3 02-01-2007 04:01 AM
usb device works only when is plugged in after booting Jaa Linux - Hardware 2 08-22-2006 10:00 AM
how to know a usb device is plugged in/out lordofring Linux - Software 2 04-25-2005 01:15 PM
Why does PC hang when USB device is plugged in? DeepSPiN Fedora 1 12-03-2003 10:59 AM


All times are GMT -5. The time now is 07:52 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration