# cardmgr and setting pcmcia to default runlevel

## rommel

i finally setup a router using linux 

my internet connection is wireless broadband using an orinoco pcmcia card and hostadapter.

everything seems to working fine except i get a cardmgr error when rebooting or shutting down the system that says it cant shut down eht1 (the orinoco card) because it hasnt yet been started....this is because init has already brought eht1 down just before cardmgr comes on the scene and runs its ./network check of eth1....how could i correct this or is it worth correcting?

ciao

----------

## rojaro

i assume you've added /etc/init.d/net.eth1 vi rc-upate to some runlevel. remove it (rc-update del net.eth1) as pcmcia network devices are handled by the cardmgr in general, so it will start and stop the card itself

reason for that is also rather simple, if you boot the machine without the card being inserted and net.eth1 tries to configure the card would result in lots of error messages. therefore the cardmgr handles all that stuff.

----------

## rommel

ok i had already tried that....so i just ran 

```
#rc-update del net.eth1
```

 and it searched boot, default, nonetwork (?), and runlevel single....it found nothing so that is clear i think...but i still have eth1 going down before the cardmgr runs and shuts it down itself...so i am still recieving the error.

i know its not really a problem but i would like to know what is bringing eth1 down if its not cardmgr.

also the only thing started at boot before pcmcia and cardmgr startup is eth0...so whatever is bringing eth1 down its not starting it (or atleast trying to) so would this mean it has something to do with the /etc/init.d/net.eth1 script?

----------

## rojaro

well ... think so as this should be the only script in the whole /etc tree (besides your net.eth0 script) which contains an ifconfig command. so do

```
grep -ri ifconfig /etc
```

to see verify this. if it appears only in net.eth0 & 1, then some other script must be calling net.eth1 .. if that is the case, do the grep again but with "net.eth1" or just "net" again.

----------

## rommel

well grep is only listing eth1 in conjunction with stuff i guess its pulling  from the /etc/init.d/net.eth1, but there is no other refferance to eth1 other then those associated with /sbin/ifconfig.

is there something different to do when installing gentoo and using pcmcia along with pcmcia-cs and setting up net.ethX?

----------

## bendy

 *rommel wrote:*   

> everything seems to working fine except i get a cardmgr error when rebooting or shutting down the system that says it cant shut down eht1 (the orinoco card) because it hasnt yet been started....this is because init has already brought eht1 down just before cardmgr comes on the scene and runs its ./network check of eth1....how could i correct this or is it worth correcting?

 

I have the same issue on my laptop with my pcmcia wireless card (not being used as a router).  I get the same message about shutting down eth0, even though I never added a net.eth0 script using rc-update.

Cardmgr handles everything fine, and it doesn't seem to cause any problems, but like you I wondered what was causing it.

Bendy.

----------

## simon

Hi,

don't know if I am right, because I'm away from my box, but I think it is something like that: On startup cardmgr calls net.ethx to start ethx, on shutdown ethx is stopped by a generic script (?) befor pcmcia handles the shutdown of ethx. At this point, the ethx is not started (or already stopped). It is just a timing problem.

Is that comprehensible?

As mentioned somewhere in some guide, you do not have to add pcmcia network cards with rc-update add ethx default, cardmgr takes care of that and chooses the right startup-script. If you backup your net.ethx and delete it, you should see an errorlog from cardmgr because that file is missing.

Hope, that describtion is not garbage ;o)

I have the same effect on my notebook, but I don't care.

Simon

----------

## rommel

no simon its not garbage but i thought i already kinda made it understood that i was aware of it being a timing issue...the script thats pulling it down before cardmgr is itself the net.eth1 script...i was just wondering if someone had this issue and had an edit for net.ethx to get ride of it without borking something else.

actually its good to hear you two are having the problem also.....being the first pcmcia experience for me i was still unsure if it was something i had left out or done incorrectly although it works perfectly other then this silly issue.

----------

## simon

Hi,

why is net.ethx called on shutdown, if it is not in any profile. It would be nice, if cardmgr would start AND stop the interface it started.

Simon

----------

## rojaro

simon ... that's exactly what cardmgr IS DOING (and what it's basically for) and it works perfectly on my notebook...

----------

## simon

Ok,

maybe I'm a bit slow today.

I know, that cardmgr takes care of starting/stopping ethx, but someone is calling net.ethx stop on shutdown, and it is not cardmgr, on my notebook.

Simon

----------

## rommel

well rojaro do you have a suggestion as to what else might be calling the card down before cardmgr takes over on shutdown?....did you edit the your /etc/init.d/net.ethx at all when you were installing gentoo for your first boot?

running the grep search like you suggested earlier didnt seem to point to anything else but that script.

----------

## rojaro

just noticed again that i've edited my net.eth0 script on the notebook and changed the depend function (which is also noted in the installation documentation) from "use pcmcia" (which is the default in general) to "need pcmcia" so it looks like this:

```
# For pcmcia users. note that pcmcia must be added to the same

# runlevel as the net.* script that needs it.

depend() {

        need pcmcia

}
```

also note the comment (which is also in the original file) ... maybe this solves your problem ..

----------

## chadh

Hi everyone,

   The pcmcia-cs package is my responsibility, so maybe I can shed some light here.  Here are the issues

When I made the pcmcia-cs package, my goal was to make it as integrated with the rest of the distribution as possible.  I want all the pcmcia-cs scripts to call the Gentoo scripts to take advantage of settings in /etc/conf.d.  Unfortunately, Gentoo's init scripts don't get along so well with this scheme.  In this particular case, what happens is this:

1. At bootup, no net.anything is started (correct behavior)

2. Once the pcmcia sevice is started and a card is inserted, cardmgr looks it up in its config files in /etc/pcmcia and calls the appropriate script for the card.  In the case of a network card, that means cardmgr launches /etc/pcmcia/network.  The default Gentoo script just calls /etc/init.d/net.eth? start.  That is all well and good.

3.  Here is where things go bad.  Bringing up the net.foo service registers it with Gentoo's init scripts as running (hint -- see /mnt/.init.d)

4. When you shut down your machine, Gentoo runs through the currently running services and calls "stop" on all of them.  Probably because net.eth? is lexicographically before pcmcia, net.eth? is stopped and then sometime later pcmcia is stopped.

5.  Now pcmcia tries to stop net.eth? and of course that is bad.

There are a few short-term solutions that I haven't had time to try yet, but in the long run, we need to get init script support for this situation, and I want to also add in support for profiles/schemes for /etc/conf.d while we are at it

----------

## rommel

aaahhhh well  even if it wasnt a post that led to a fix i feel better...lol....thanks chad

----------

## miunk

Try this

I added this to the net.eth0 script after the dhcpcd -k command section:

/sbin/ifconfig ${IFACE} down >/dev/null

And this to the "check" section of /etc/pcmcia/network:

/sbin/config $DEVICE | grep -q RUNNING || exit 1

...

for gentoo 1.2 i only had to do the second part, 1.4 needs the first because dhcpcd -k alone does not actually bring the interface down.  It seems to be only a cosmetic error, but an error nonetheless.

rojaro - it was sort of broke.[/url]

----------

## chrisost

I've run in to the problem that I want pcmcia to control the starting and stopping of my network card (for example - I don't want the net.eth0 started if the card's not in the socket when the machine is booted).

If I do not have net.eth0 added to the default runlevel, after the boot runlevel is reached and the switch is made to the default runlevel, since I do not have net.eth0 added to the default runlevel, it is stopped.

If I add net.eth0 to the default runlevel, if the card is not inserted when the machine boots, it tries to start net.eth0 anyway.

I think one solution would be to change the pcmcia scripts to *not* use net.eth0, so that it is not registered in /etc/.init.d as running.  This seems like an ugly fix that goes against the point of having the net.eth0 script.  Does anyone else have any ideas?

----------

## int1

 *chrisost wrote:*   

> I've run in to the problem that I want pcmcia to control the starting and stopping of my network card (for example - I don't want the net.eth0 started if the card's not in the socket when the machine is booted).

 

I wrote an init script for my laptop for just this issue.  Basically, it starts wireless if the card is in the socket, otherwise it checks to see if eth1 exists (in my docking station at work) and starts it, otherwise it starts eth0.  

https://forums.gentoo.org/viewtopic.php?t=22717&highlight=

You could easily modify the script for your purposes.

Enjoy!

int1

----------

## GurliGebis

I'm also installing Gentoo for the first time on a laptop.

So I'm wondering, if I add sshd to default, what will happend then?

Since net.eth0 isn't added to the default runlevel, because cardmgr does that, how does the things that uses network reacts during boot?

(Sorry for my bad english, but it's 01:44 AM here right now, and I'm soooo tired   :Shocked:  )

----------

## jcosters

 *miunk wrote:*   

> Try this
> 
> I added this to the net.eth0 script after the dhcpcd -k command section:
> 
> /sbin/ifconfig ${IFACE} down >/dev/null
> ...

 

works fine, but I don't need the first part of your mod (dhcpcd -k brings down my interface fine?)

thanxLast edited by jcosters on Wed Sep 10, 2003 10:45 pm; edited 1 time in total

----------

## krunk

Well it's good to know where that little error is coming from and that is more involved than my modest poking around would have revealed.

Thanks for the heads up, Chad, you should post here when the solution comes out so I can be sure to implement it.    :Very Happy: 

----------

## deuce

I have just submitted a bug report, with a solution, here https://bugs.gentoo.org/show_bug.cgi?id=28130.  All the details are there.

----------

## colinmacleod

I know the bug and solution have already been posted, but here's a simple quick fix which got me up and running. It helped me, so I thought this might be useful to someone else too...

It's really simple. Remove pcmcia from the depend section of /etc/init.d/net.eth0 and add a depend section to /etc/init.d/pcmcia:

```
depend() {

    need net

}
```

The only other thing I did was to remove net.eth0 from the runlevel:

```
rc-update del net.eth0
```

And that's all. Now when I shutdown, the network card only shuts down once, when the cardmanager tells it to.

----------

