View previous topic :: View next topic |
Author |
Message |
Xamindar Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/19152502684468fa92999e5.gif)
Joined: 03 Oct 2004 Posts: 1155 Location: California
|
Posted: Mon Oct 01, 2007 7:18 am Post subject: How can I run a script when a certain net interface comes up |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
toralf Developer
![Developer Developer](/images/ranks/rank-dev.gif)
![](images/avatars/10034462014367c4dfe33c1.gif)
Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Mon Oct 01, 2007 7:54 am Post subject: |
|
|
What's about using the command for that ? And in ase of using dhcp you can simply use . |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
loki_val Retired Dev
![Retired Dev Retired Dev](/images/ranks/rank-retired.gif)
Joined: 13 Nov 2006 Posts: 418 Location: Denmark
|
Posted: Mon Oct 01, 2007 7:55 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
toralf Developer
![Developer Developer](/images/ranks/rank-dev.gif)
![](images/avatars/10034462014367c4dfe33c1.gif)
Joined: 01 Feb 2004 Posts: 3943 Location: Hamburg
|
Posted: Mon Oct 01, 2007 8:18 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Xamindar Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/19152502684468fa92999e5.gif)
Joined: 03 Oct 2004 Posts: 1155 Location: California
|
Posted: Mon Oct 01, 2007 6:38 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|