# Device initiated services.

## venquessa2

Device initiated services.

Who's bright idea was this?

It's a curse!

Had a power out here.  Power came back on and my network didn't.  Why?  Server had started eth1 first.  When I had explicitly left eth1 out of start up as it's a backup on the same subnet used to allow the server to stand in as an emergency firewall.  So the system got it's route to the LAN via the wrong interface and no-one would talk to it....  not even itself as most services expected the other address.  Plus, it had the same IP address as the firewall, which promptly failed to come up.  So I had to crawl around behind the cabinet putting monitors and keyboards into both and getting them to boot!

I'm not really complaining, I know how to fix it eth1_start="no"  it's just that, regarding networking it's somewhat idiotic to willy nilly enable devices at boot without being specifically told to do so.  It's not only asking for annoying episodes like I just had, but also dangerous regarding security!

----------

## UberLord

 *venquessa2 wrote:*   

> dangerous regarding security!

 

How? I sometimes here this, but no-one has yet to prove it is insecure.

Besides, I like it as things just work when I plug them in.

----------

## fullaxx

I have a wireless device, ath0 that I dont want to be started on startup.

It it not listed in any runlevel, yet because of "devices initiated services" it does start on startup.

I tried adding ath0_start="no" to /etc/conf.d/net but that didn't change anything.

How can i change this behavior?

Thanks,

Fullaxx

----------

## clattuc

 *Quote:*   

> Besides, I like it as things just work when I plug them in.

 

So would I - but they don't. :-/

Through all the incarnations of the gentoo network setup, not once has it 'just worked'. At least, not on a machine with more than 1 interface.

My laptop has one wired, one wireless card. The wired is configured with ifplugd. Wireless uses wpa_supplicant. The only way that I can get networking up and running is by manually bringing interfaces up/down - the combination of wired & wireless seems to confuse the Gentoo network scripts: I end up with a resolv.conf for a wireless interface that is no longer associated, or an ip-address for the wired interface that is no longer plugged in.

I've been using Gentoo for 6 years now (so I *think* I know what I'm doing), but the network-infrastructure has remained a bit of a moving target  :Sad: 

----------

## UberLord

 *fullaxx wrote:*   

> I have a wireless device, ath0 that I dont want to be started on startup.
> 
> It it not listed in any runlevel, yet because of "devices initiated services" it does start on startup.
> 
> I tried adding ath0_start="no" to /etc/conf.d/net but that didn't change anything.
> ...

 

Look at /etc/conf.d/rc for RC_COLDPLUG and RC_HOTPLUG and RC_PLUG_SERVICES.

----------

## UberLord

 *clattuc wrote:*   

>  *Quote:*   Besides, I like it as things just work when I plug them in. 
> 
> So would I - but they don't. :-/
> 
> Through all the incarnations of the gentoo network setup, not once has it 'just worked'. At least, not on a machine with more than 1 interface.
> ...

 

Sounds like you need to install resolvconf-gentoo to manage resolv.conf for you.

----------

## clattuc

 *UberLord wrote:*   

>  *clattuc wrote:*    *Quote:*   Besides, I like it as things just work when I plug them in. 
> 
> So would I - but they don't. :-/
> 
> [...] 
> ...

 

Why? dhcpcd already manages resolv.conf. (I know - I forgot to mention that both interfaces use dhcp.)

----------

## UberLord

 *clattuc wrote:*   

> Why? dhcpcd already manages resolv.conf. (I know - I forgot to mention that both interfaces use dhcp.)

 

Wrong.

A dhcp client is responsible for setting up /etc/resolv.conf for the interface it's running on.

So >1 dhcp client (and there is no guarantee they are the same dhcp client) competes for the same file. The last dhcp to work creates a new /etc/resolv.conf from the information it got from the dhcp server on the interface.

To solve this, we have resolvconf-gentoo which all dhcp clients + some others like openvpn will use if installed.

----------

## clattuc

 *UberLord wrote:*   

>  *clattuc wrote:*   Why? dhcpcd already manages resolv.conf. (I know - I forgot to mention that both interfaces use dhcp.) 
> 
> Wrong.
> 
> A dhcp client is responsible for setting up /etc/resolv.conf for the interface it's running on.
> ...

 

Yes. And since I only want *one* interface to be up at any one time (Ergo only one dhcp client.), dhcpcd should do just fine. 

However, it seems the only way to prevent the network-scripts/ifplugd/device-iniated stuff from tripping over itself is to stop/start the interfaces manually. I'd be very interested to learn otherwise.

----------

## UberLord

Well, you'll have to control each interface manually then.

Or write a patch todo otherwise.

----------

## kingcrabmeat

i had a similar problem where eth0 started at boot but i preferred to use a wireless connection, so i did what's posted at the bottom of the following page: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4

----------

## turtles

Quick question on this topic. My laptop that now has pcmcia wireless no longer needs a wired lan. However it attempts to start net.eth0 on boot as "device initiated". I adjusted the time out to make it painless. However if I need to plug in to a LAN wile keeping my wifi going I would like udev auto start net.eth0. 

In this case would it not make sence to add 

```
RC_PLUG_SERVICES="!net.eth0"
```

 and just keep the device initiated services?

Also what if I alternate between 2 wifi pcmcia cards will wlan0, ath0 and eth0 all try to start? then I will have 2 devices to time out for 1 to start.

Can I configure it to check which one is actualy plugged in?

Cheers

turtle

----------

## VinzC

Hi guys.

I am one who is interrested in using device initiated services. I'd like to know how I could have a given service start whenever a given module is loaded (not by udev unfortunately). First is it possible? I'd like to start /etc/init.d/multipathd as soon as kernel module dm-multipath is loaded - it is loaded with /etc/modules.autoload.d/kernel-2.6.

I'm asking this because multipathd is a service that provides new disk nodes *after* /etc/fstab is processed. So when multipath device nodes get created it's already too late for automounting. Hence I'm looking for a quick a neat way to get these multipath'ed nodes to be created beforehand.

Thanks.

----------

## UberLord

The init script needs this dependency block then

```
depend()

{

   use modules

   before localmount

}
```

For baselayout-2 (or OpenRC), it will start the init script before local mounting takes place.

It won't work for baselayout-1.

----------

## VinzC

Thanks UberLord.

Since I'm using baselayout version 1.* the only way of achieving what I want would be an initial ramdrive then?

----------

## UberLord

Yes.

Although you could try baselayout-2 or OpenRC (easily available using layman)

----------

## MostAwesomeDude

Off-topic, but every single ifplugd-related problem I've seen is fixed by switching to netplug.

----------

