Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How can I run a script when a certain net interface comes up
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Xamindar
Veteran
Veteran


Joined: 03 Oct 2004
Posts: 1155
Location: California

PostPosted: Mon Oct 01, 2007 7:18 am    Post subject: How can I run a script when a certain net interface comes up Reply with quote

I want to launch a script that will rsync a remote directory when the network interface comes up with an IP. I already have the rsync script working. It will basically ping the host and start the rsync if it gets a response. So now I need a way to launch it automatically. This net interface will only come up when I connect the host to it and go away when I disconnect it (usb networking).

Do I use udev rules? Should I use hotplug? I am a little confused because it looks like they both can do it if configured. Which is better? Or is there another, better way to do this?

Thanks for any suggestions.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3943
Location: Hamburg

PostPosted: Mon Oct 01, 2007 7:54 am    Post subject: Reply with quote

What's about using the command
Code:
ifconfig
for that ? And in ase of using dhcp you can simply use
Code:
/etc/dhcpcd.sh
.
Back to top
View user's profile Send private message
loki_val
Retired Dev
Retired Dev


Joined: 13 Nov 2006
Posts: 418
Location: Denmark

PostPosted: Mon Oct 01, 2007 7:55 am    Post subject: Reply with quote

The "Gentoo Way" of doing this would probably be to set up a postup() rule in /etc/conf.d/net. You can read about doing that in /etc/conf.d/net.example.
Back to top
View user's profile Send private message
toralf
Developer
Developer


Joined: 01 Feb 2004
Posts: 3943
Location: Hamburg

PostPosted: Mon Oct 01, 2007 8:18 am    Post subject: Reply with quote

peteralf wrote:
The "Gentoo Way" of doing this would probably be to set up a postup() rule in /etc/conf.d/net. You can read about doing that in /etc/conf.d/net.example.
Yep, but using /etc/dhcpcd.sh is charming if you use dhcpcd at the command line too.
Back to top
View user's profile Send private message
Xamindar
Veteran
Veteran


Joined: 03 Oct 2004
Posts: 1155
Location: California

PostPosted: Mon Oct 01, 2007 6:38 pm    Post subject: Reply with quote

peteralf wrote:
The "Gentoo Way" of doing this would probably be to set up a postup() rule in /etc/conf.d/net. You can read about doing that in /etc/conf.d/net.example.


Thanks a lot guys. Got it working "the gentoo way" and it works GREAT!! Here is what I put in the net file:

Code:

postup() {
#       Launches the zaurus rsync script when it is connected
       if [ ${IFACE} == "usb0" ] ; then
               einfo "rsyncing music from Zaurus"
               /home/xamindar/scripts/rsync_zaurus.sh
       fi
}


I don't know what einfo does, I'll probably take it out.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum