# hotplug führt wlan-script mehrfach aus [solved]

## Sas

ähm ja, irgendwie hab ichs heute mit mehrfach laufenden dingen, die eigentlich nur einmal passieren sollten ^^ (siehe meinen xdm thread)

also ich hab ne für meine wlankarte ein simples script geschrieben, das unter /etc/hotplug/pci/ath_pci liegt und nur /etc/init.d/net.ath0 start auführen soll. (oder auch ...restart aber da verhält er sich genauso.)

klappt soweit auch ganz gut, allerdings übertreibt ers etwas:

```
s-mobile silas # /etc/init.d/hotplug restart

 * Stopping USB and PCI hotplugging...                                   [ ok ]

 * Starting USB and PCI hotplugging...

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.

 * WARNING:  "net.ath0" has already been started.                        [ ok ]

s-mobile silas #
```

führe ich das initscript von hand aus, klappts einwandfrei. woher kann das kommen? jemand ne idee? danke...

gruss, Silas

----------

## steveb

poste doch mal das script.

gruss

SteveB

----------

## Sas

danke erstmal für die hilfe!

das hotplug-script? naja, wie gesagt reichlich unspektakulär:

```
#!/bin/bash

/etc/init.d/net.ath0 start
```

und das net.ath0 script läuft ja einwandfrei...

irgend ne idee?

----------

## steveb

ath0? sollte das nicht eth0 sein? wie auch immer... ich würde das skript etwa so gestalten:

```
#!/bin/bash 

if [ -f "/etc/init.d/net.ath0" ] ; then

   case "$(/etc/init.d/net.ath0 status 2>/dev/null | awk '{print $3}')" in

   started)

      /etc/init.d/net.ath0 {stop,zap,start} 2>/dev/null

      ;;

   *)

      /etc/init.d/net.ath0 start 2>/dev/null

      ;;

   esac

   exit 0

else

   echo -ne "\\033[31;01mERROR:\\033[00m Script \\033[33;01m\"/etc/init.d/net.ath0\"\\033[00m not found.\n"

   exit 1

fi
```

gruss

SteveB

----------

## Sas

nein, ath0 ist schon richtig, die wlan karte nutzt den atheros chip-satz und der einzige halbwegs brauchbare treiber dafür (madwifi, ist mittlerweile auch im portage  :Smile: ) nennt die devices halt athN.

ich probier dein script mal aus, vielen dank!

----------

## Sas

nein, da verhält er sich leider genauso:

```
silas@s-mobile silas $ su

Password:

s-mobile silas # /etc/init.d/hotplug restart

 * Stopping USB and PCI hotplugging...                                   [ ok ]

 * Starting USB and PCI hotplugging...

 * Bringing ath0 down...                                                 [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...        [ ok ]

 * Bringing ath0 up...                                                   [ ok ]

 *   Setting default gateway...                                          [ ok ]

 * Bringing ath0 down...                                                 [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...        [ ok ]

 * Bringing ath0 up...                                                   [ ok ]

 *   Setting default gateway...                                          [ ok ]

 * Bringing ath0 down...                                                 [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...        [ ok ]

 * Bringing ath0 up...                                                   [ ok ]

 *   Setting default gateway...                                          [ ok ]

 * Bringing ath0 down...                                                 [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...        [ ok ]

 * Bringing ath0 up...                                                   [ ok ]

[...]

```

am script liegts aber nicht, denn wenn ichs von hand ausführe, klappts:

```
s-mobile silas # /etc/hotplug/pci/ath_pci

 * Bringing ath0 down...                                                 [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...        [ ok ]

 * Bringing ath0 up...                                                   [ ok ]

 *   Setting default gateway...                                          [ ok ]

s-mobile silas #
```

bleibt also noch hotplug - womit ich mich leider überhaupt nicht auskenne. noch eine idee?

----------

## steveb

schau dir mal das skript /etc/hotplug/net.agent an.

gruss

steve

----------

## Sas

hm sry, da werd ich nicht wirklich schlau draus. also mir ist schon klar, dass das script genau das machen soll, was ich möchte (nämlich das net.* init-script aufrufen), allerdings ist mir nicht klar, wie ich es verwenden muss. ich habs mit "/etc/hotplug/net.agent register ath0" und ein paar ähnlichen befehlen versucht, aber es tut sich immer ganz genau gar nix. also auch keine fehlermeldung oder sowas. wie geht das?

und danke nochmal für deine mühe  :Wink: 

----------

## steveb

kannst du mir einen gefallen machen und das script aus /etc/init.d/net.ath0 mal hier auflisten?

gruss

steve

----------

## Sas

na klar. wobei ich nachwievor nicht verstehe, warum es keine probleme gibt, wenn ich das script von hand (oder beim systemstart) ausführe...

```
#!/sbin/runscript

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /etc/init.d/net.eth0,v 1.30 2003/10/18 18:03:19 faye Exp $

#NB: Config is in /etc/conf.d/net

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

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

depend() {

   use hotplug

}

checkconfig() {

   if [ -z "${iface_IFACE}" ]

   then

      eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"

      return 1

   fi

}

setup_env() {

   # No reason to check these multiple times in the file

   iface_IFACE="$(eval echo \$\{iface_${IFACE}\})"

   dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${IFACE}\})"

   inet6_IFACE="$(eval echo \$\{inet6_${IFACE}\})"

   alias_IFACE="$(eval echo \$\{alias_${IFACE}\})"

   status_IFACE="$(ifconfig | gawk -v IFACE="${IFACE}" '/Link/ { if ($1 == IFACE) print "up" }')"

   if [ -x `which iwconfig` ]; then

      wireless_IFACE="$(iwconfig 2>/dev/null | gawk -v IFACE="${IFACE}" '/IEEE/ { if ($1 == IFACE) print "yes" }')"

   fi

   wireless_IFACE=${wireless_IFACE:-"no"}

   if [ -x `which mii-tool` ]; then

      link_IFACE=$(mii-tool ${IFACE} 2>/dev/null | gawk '{print $2}')

   fi

   link_IFACE=${link_IFACE:-"yes"}

}

setup_wireless() {

   # Reset to some defaults

   iwconfig $IFACE mode Managed

   iwconfig $IFACE rate auto

   iwconfig $IFACE key off

   iwconfig $IFACE rts off

   iwconfig $IFACE frag off

   iwconfig $IFACE essid any

   # Initiate a scan

   ifconfig $IFACE up

   # Wait for a response

   sleep 1

   # Find known access points

   for AP in `iwlist ${IFACE} scan 2>/dev/null | grep ESSID | awk -F: '{print $2}' | sed 's/[-"]//g'`; do

      if [ -z ${essid_AP} ]; then

         essid_AP="$(eval echo \$\{essid_${AP}\})"

         if [ ! -z ${essid_AP} ]; then

            # setup variables

            key_AP="$(eval echo \$\{key_${AP}\})"

            iface_IFACE="$(eval echo \$\{iface_${AP}\})"

            gateway="${IFACE}/$(eval echo \$\{gateway_${AP}\})"

         fi

      else

         ebegin "No access points found. Using settings from /etc/conf.d/net"

      fi

   done

   # Bring interface down to apply changes

   ifconfig $IFACE down

#ewarn "Setting wireless parameters mode=${mode_AP}, essid=${essid_AP} and key=${key_AP}" # Debug only!

   if [ ! -z ${mode_AP} ]; then

      iwconfig ${IFACE} mode ${mode_AP}

   fi

   if [ ! -z ${essid_AP} ]; then

      iwconfig ${IFACE} essid ${essid_AP}

   fi

   if [ ! -z ${key_AP} ]; then

      iwconfig ${IFACE} key ${key_AP}

   fi

   # Bring the interface up

   ifconfig $IFACE up

   # Wait for the system to associate

   while [ `iwconfig $IFACE | awk '/\<..:..:..:..:..:..\>/{print}' | sed 's/^.*\<\(..:..:..:..:..:..\)\>.*$/\1/g'` = FF:FF:FF:FF:FF:FF ]; do

      LC_NUMERIC=C sleep 0.5

   done

   return 0

}

start() {

   local retval=0

   setup_env

   checkconfig || return 1

   if [ ${wireless_IFACE} == "yes" ]; then

      ebegin "Detecting network for ${IFACE}"

      setup_wireless

      eend 0

   fi

   ebegin "Bringing ${IFACE} up"

   if [ ${link_IFACE} == "no" ]

   then

      retval=1

      eend ${retval} "Failed to bring ${IFACE} up"

      return ${retval}

   fi

   if [ "${iface_IFACE}" != "dhcp" ]

   then

      /sbin/ifconfig ${IFACE} ${iface_IFACE} >/dev/null || {

         retval=$?

         eend ${retval} "Failed to bring ${IFACE} up"

         return ${retval}

      }

      # ifconfig do not always return failure ..

      /sbin/ifconfig ${IFACE} &> /dev/null || {

         retval=$?

         eend ${retval} "Failed to bring ${IFACE} up"

         return ${retval}

      }

   else

      # Check that ath0 was not brough up by the kernel ...

      if [ "${status_IFACE}" != "up" ]

      then

         /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || {

            retval=$?

            eend ${retval} "Failed to bring ${IFACE} up"

            return ${retval}

         }

      fi

   fi

   eend 0

   if [ -n "${alias_IFACE}" ]

   then

      local x=""

      local num=0

      local aliasbcast=""

      local aliasnmask=""

      ebegin "  Adding aliases"

      for x in ${alias_IFACE}

      do

         aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"

         if [ -n "${aliasbcast}" ]

         then

            aliasbcast="broadcast ${aliasbcast}"

         fi

         aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"

         if [ -n "${aliasnmask}" ]

         then

            aliasnmask="netmask ${aliasnmask}"

         fi

         ebegin "    ${IFACE}:${num}"

         /sbin/ifconfig ${IFACE}:${num} ${x} \

            ${aliasbcast} ${aliasnmask} >/dev/null

         num=$((num + 1))

         eend 0

      done

      save_options "alias" "${alias_IFACE}"

   fi

   if [ -n "${inet6_IFACE}" ]

   then

      local x=""

      ebegin "  Adding inet6 addresses"

      for x in ${inet6_IFACE}

      do

         ebegin "    ${IFACE} inet6 add ${x}"

         /sbin/ifconfig ${IFACE} inet6 add ${x} >/dev/null

         eend 0

      done

      save_options "inet6" "${inet6_IFACE}"

   fi

   if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]

   then

      ebegin "  Setting default gateway"

      # First delete any existing routes if it was setup by kernel ..

      /sbin/route del default dev ${gateway%/*} &>/dev/null

      /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \

         netmask 0.0.0.0 metric 1 >/dev/null || {

         local error=$?

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

         eend ${error} "Failed to bring ${IFACE} up"

         stop

         return ${error}

      }

      eend 0

   fi

   # Enabling rp_filter causes wacky packets to be auto-dropped by

   # the kernel

   if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ]

   then

      echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter

   fi

   # If started by hotplug, this doesn't get done.

   # perhaps the right fix is in hotplug

   ln -sf /etc/init.d/net.${IFACE} /var/lib/init.d/started/net.${IFACE}

}

stop() {

   local myalias="$(get_options alias)"

   local myinet6="$(get_options inet6)"

   setup_env

   ebegin "Bringing ${IFACE} down"

   # Also down the inet6 interfaces

   if [ -n "${myinet6}" ]

   then

      local x=""

      for x in ${myinet6}

      do

         /sbin/ifconfig ${IFACE} inet6 del ${x} >/dev/null

      done

   fi

   # Do some cleanup in case the amount of aliases change

   if [ -n "${myalias}" ]

   then

      local x=""

      local num=0

      for x in ${myalias}

      do

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

         num=$((num + 1))

      done

   fi

   if [ "${iface_IFACE}" = "dhcp" ]

   then

      local count=0

      while /sbin/dhcpcd -k ${IFACE} &>/dev/null && [ "${count}" -lt 9 ]

      do

         # Give dhcpcd time to properly shutdown

         sleep 1

         count=$((count + 1))

      done

      if [ "${count}" -ge 9 ]

      then

         eerror "Timed out trying to stop dhcpcd"

      fi

   else

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

   fi

   eend 0

}

# vim:ts=4

```

danke nochmal

----------

## steveb

 *Sas wrote:*   

> na klar. wobei ich nachwievor nicht verstehe, warum es keine probleme gibt, wenn ich das script von hand (oder beim systemstart) ausführe...

 es ist nicht das gleiche! das ding läuft offenbar mit dem gentoo init script sauber aber eben nicht über hotplug!

beim betrachten des scripts kann ich mir nur eines vorstellen: kann es nicht sein, dass die karte beim anmelden jeweils hotplug ereignisse auslöst, so dass hotplug durch eine endlosschlaufe immer wieder das gerät abmeldet und dann wieder anmeldet?

evt wäre ein eintrag auf bugs.gentoo.org nötig?

gruss

SteveB

----------

## steveb

kannst du mal folgedes ausführen und zurückschreiben, was für ein resultat du erhällst:

```
/etc/hotplug/pci/ath_pci ; echo $?
```

und auch das reslutat von:

```
/etc/init.d/net.ath0 ; echo $?
```

gruss

SteveB

----------

## Sas

es ist ja keine endlosschleife (siehe mein erstes posting, da hab ich nix gekürzt.)

ja, das könnte natürlich sein, hatte ich auch schon dran gedacht, da 3 kernelmodule geladen werden (wovon ath_pci allerdings das letzte ist).

nur kenne ich mich - wie gesagt - leider nicht mit hotplug aus und wüsste auch nicht, wie ich diese these verifizieren könnte und wie ich den mehrfach-aufruf verhindern könnte...

----------

## steveb

 *Sas wrote:*   

> es ist ja keine endlosschleife (siehe mein erstes posting, da hab ich nix gekürzt.)
> 
> ja, das könnte natürlich sein, hatte ich auch schon dran gedacht, da 3 kernelmodule geladen werden (wovon ath_pci allerdings das letzte ist).
> 
> nur kenne ich mich - wie gesagt - leider nicht mit hotplug aus und wüsste auch nicht, wie ich diese these verifizieren könnte und wie ich den mehrfach-aufruf verhindern könnte...

 aha! welche module wären das denn?

gruss

steve

----------

## Sas

```
s-mobile silas # /etc/hotplug/pci/ath_pci ; echo $?

 * Bringing ath0 down...                                                             [ ok ]

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...                    [ ok ]

 * Bringing ath0 up...                                                               [ ok ]

 *   Setting default gateway...                                                      [ ok ]

0

```

```
s-mobile silas # /etc/init.d/net.ath0 ; echo $?

Gentoo Linux RC-Scripts; http://www.gentoo.org/

 Copyright 2001-2003 Gentoo Technologies, Inc.; Distributed under the GPL

Usage: net.ath0 < flags > [ options ]

Options:

    start

      Start service, as well as the services it depends on (if not already

      started).

    stop

      Stop service, as well as the services that depend on it (if not already

      stopped).

    restart

      Restart service, as well as the services that depend on it.

      Note to developers:  If this function is replaced with a custom one,

      'svc_start' and 'svc_stop' should be used instead of 'start' and

      'stop' to restart the service.  This is so that the dependencies

      can be handled correctly.  Refer to the portmap rc-script for an

      example.

    pause

      Same as 'stop', but the services that depends on it, will not be

      stopped.  This is useful for stopping a network interface without

      stopping all the network services that depend on 'net'.

    zap

      Reset a service that is currently stopped, but still marked as started,

      to the stopped state.  Basically for killing zombie services.

    status

      Prints "status:  started" if the service is running, else it

      prints "status:  stopped".

      Note that if the '--quiet' flag is given, it will return true if the

      service is running, else false.

    ineed|iuse

      List the services this one depends on.  Consult the section about

      dependencies for more info on the different types of dependencies.

    needsme|usesme

      List the services that depend on this one.  Consult the section about

      dependencies for more info on the different types of dependencies.

    broken

      List the missing or broken dependencies of type 'need' this service

      depends on.

Flags:

    --quiet

      Suppress output to stdout, except if:

      1) It is a warning, then output to stdout

      2) It is an error, then output to stderr

    --nocolor

      Suppress the use of colors.

Dependencies:

    This is the heart of the Gentoo RC-Scripts, as it determines the order

    in which services gets started, and also to some extend what services

    get started in the first place.

    The following example demonstrates how to use dependencies in

    rc-scripts:

    depend() {

        need foo bar

        use ray

    }

    Here we have foo and bar as dependencies of type 'need', and ray of

    type 'use'.  You can have as many dependencies of each type as needed, as

    long as there is only one entry for each type, listing all its dependencies

    on one line only.

    need

      These are all the services needed for this service to start.  If any service

      in the 'need' line is not started, it will be started even if it is not

      in the current, or 'boot' runlevel, and then this service will be started.

      If any services in the 'need' line fails to start or is missing, this

      service will never be started.

    use

      This can be seen as representing optional services this service depends on

      that are not critical for it to start.  For any service in the 'use' line,

      it must be added to the 'boot' or current runlevel to be considered a valid

      'use' dependency.  It can also be used to determine startup order.

    before

      This, together with the 'after' dependency type, can be used to control

      startup order.  In core, 'before' and 'after' do not denote a dependency,

      but should be used for order changes that will only be honoured during

      a change of runlevel.  All services listed will get started *after* the

      current service.  In other words, this service will get started *before*

      all listed services.

    after

      All services listed will be started *before* the current service.  Have a

      look at 'before' for more info.

    provide

      This is not really a dependency type, rather it will enable you to create

      virtual services.  This is useful if there is more than one version of

      a specific service type, system loggers or crons for instance.  Just

      have each system logger provide 'logger', and make all services in need

      of a system logger depend on 'logger'.  This should make things much more

      generic.

    parallel

      This is not really a dependency type, but enable you to specify if a

      service can start in parallel or not.  It takes one of two arguments,

      either 'yes' or 'no', and if it is not specified, it is presumed that

      it is set to 'yes'.

    Note that the 'need', 'use', 'before' and 'after' dependeny types can have '*'

    as argument.  Having:

    depend() {

        before *

    }

    will make the service start first in the current runlevel, and:

    depend() {

        after *

    }

    will make the service the last to start.

    You should however be careful how you use this, as I really will not

    recommend using it with the 'need' or 'use' dependency type ... you have

    been warned!

'net' Dependency and 'net.*' Services:

    Example:

    depend() {

        need net

    }

    This is a special dependency of type 'need'.  It represents a state where

    a network interface or interfaces besides lo is up and active.  Any service

    starting with 'net.' will be treated as a part of the 'net' dependency,

    if:

    1.  It is part of the 'boot' runlevel

    2.  It is part of the current runlevel

    A few examples are the /etc/init.d/net.eth0 and /etc/init.d/net.lo services.

Configuration files:

    There are three files which will be sourced for possible configuration by

    the rc-scripts.  They are (sourced from top to bottom):

    /etc/conf.d/basic

    /etc/conf.d/net.ath0

    /etc/rc.conf

Management:

    Services are added and removed via the 'rc-update' tool.  Running it without

    arguments should give sufficient help.

0

s-mobile silas #
```

die module sind wlan.ko ath_hal.ko (hardware abstraktions schicht) und der eigentliche treiber ath_pci.ko

----------

## steveb

sorry! sollte:

```
/etc/init.d/net.ath0 start; echo $?
```

sein.... stopp aber noch das ding bevor du den befehl aufrufst.

was passiert, wenn du die 3 module mal in /etc/hotplug/blacklist hinzufügst. evt solltest/kannst du das letzte modul mal nicht dort reinfügen?!?!

gruss

steve

----------

## Sas

```
s-mobile silas # /etc/init.d/net.ath0 stop

 * Bringing ath0 down...                                                             [ ok ]

s-mobile silas # /etc/init.d/net.ath0 start; echo $?

 * Detecting network for ath0...

 * No access points found. Using settings from /etc/conf.d/net...                    [ ok ]

 * Bringing ath0 up...                                                               [ ok ]

 *   Setting default gateway...                                                      [ ok ]

0

s-mobile silas #
```

die module in der blacklist einzutragen macht seltsamerweise überhauptkeinen unterschied...

----------

## steveb

 *Sas wrote:*   

> 
> 
> ```
> s-mobile silas # /etc/init.d/net.ath0 stop
> 
> ...

 

hast du die module auch aus dem speicher genommen, bevor du hotplug neu gestartet hast?

versuch noch in /etc/hotplug/hotplug.functions die debug informationen einzuschalten und zu schauen, was passiert.

gruss

steve

----------

## Sas

klar, hab ich.

hab die debug funktion mal angemacht und hotplug neu gestartet. er verhält sich genauso, ich sehe nirgendwo zusätzliche ausgaben und auch neue logfiles konnte ich nicht entdecken.

das hier steht aber unter /var/log/everything/current: 

```
[...]

Feb 29 21:58:29 [default.hotplug] invoke /etc/hotplug/pci.agent ()

Feb 29 21:58:29 [pci.agent] pcimodules is scanning more than 02:00.0 ...

Feb 29 21:58:30 [pci.agent] Setup ath_pci for PCI slot 02:00.0

Feb 29 21:58:30 [pci.agent] Module setup ath_pci for PCI slot 02:00.0

Feb 29 21:58:36 [usb.agent] ... no modules for USB product 0/0/0

                - Last output repeated 3 times -

[...]

```

sagt dir das irgendwas?

----------

## steveb

was für einen kernel hast du dort bei dir am laufen?

gruss

steve

----------

## Sas

```

s-mobile / # cat /proc/version

Linux version 2.6.3-gentoo-r2 (root@s-mobile) (gcc-Version 3.3.3 20040217 (Gentoo Linux 3.3.3, propolice-3.3-7)) #1 Tue Feb 24 18:21:43 CET 2004
```

vielen dank für deine hilfe nochmal, aber ich muss jetzt wirklich ins bett. muss morgen sehr früh raus  :Sad: 

ich guck folglich dann erst wieder morgen am späten nachmittag oder abend hier ins forum, danke für deine mühe.

----------

## steveb

schreib mal den output von "lspci -v" und auch den output von:

```
for foo in /sys/bus/pci/devices/0000\:02\:00.0/* ; do [[ -f "${foo}" ]] && echo ${foo} && cat ${foo} && echo ; done
```

gruss

steve

----------

## steveb

hmmm.. ich glaube ich habe das problem gefunden, bin mir aber nicht 100%tig sicher.

so wie ich das sehe, wird dein script bei jedem pci device aufgerufen (17 mal! irq 0 bis 16).

wenn ich mich nicht ganz täusche, dann müsste das script anders aufgebaut sein und nur auf deine wlan karte reagieren. ich könnte so ein script schon bauen, müsste aber mehr infos von dir haben. (siehe meinen vorletzten beitrag).

gruss

steve

----------

## steveb

hier ist mal mein erster entwurf. keine ahnung ob es geht oder nicht?!?!

```
#!/bin/bash

# Kernel Cardbus/PCI params are:

#

#       ACTION=%s [add or remove]   a PCI device has been added or removed;

#       PCI_CLASS=%06X              $Vendor:$Device, from PCI descriptor. numbers are four hexadecimal characters

#       PCI_ID=%04X:%04X            $Vendor:$Device, from PCI descriptor (subsystem info) numbers are four hexadecimal characters

#       PCI_SLOT_NAME=%s

#       PCI_SUBSYS_ID=%04X:%04X     $Bus:$Slot.$Func, from PCI descriptor. The pci slot name that 'lspci' shows.

source /etc/hotplug/hotplug.functions

script="/etc/init.d/net.ath0"

# 00:09.0 Ethernet controller: Broadcom Corporation BCM4401 100Base-T (rev 01)

# 00:09.0 Class 0200: 14e4:4401 (rev 01)

if [ "${PCI_CLASS}" == "020000" ] && [ "${PCI_ID}" == "14e4:4401" ]

then

   if [ ! -f "${script}" ]; then

      debug_mesg script "${script}" is not executable

      ## echo -ne "\\033[31;01mScript \"${script}\" does not exist\\033[00m\n"

      exit 1

   fi

   if [ ! -x "${script}" ]; then

      debug_mesg script "${script}" is not executable

      ## echo -ne "\\033[31;01mScript \"${script}\" is not executable\\033[00m\n"

      exit 1

   fi

   case $ACTION in

   add|register)

      # Don't do anything if the network is stopped

      if [ ! -f /var/lock/subsys/network ]; then

         debug_mesg Network is stopped

         ## echo -ne "\\033[31;01mNetwork is stopped\\033[00m\n"

         exit 0

      fi

      export IN_HOTPLUG=1

      debug_mesg invoke "${script}" --quiet start

      exec "${script}" --quiet start

      exit 0 ;;

   remove|unregister)

      debug_mesg invoke "$script" --quiet stop

      exec "$script" --quiet stop

      exit 0 ;;

   *)

      debug_mesg $ACTION event not supported

      exit 1 ;;

   esac

fi
```

als beispiel habe ich mal eine andere netzwerk karte genommen.

```
00:09.0 Ethernet controller: Broadcom Corporation BCM4401 100Base-T (rev 01)

00:09.0 Class 0200: 14e4:4401 (rev 01)
```

ich habe mal alle geräte bei mir angeschaut und alle netzwerk karten haben bei mir die pci class id 0x020000. auf eine wireless carte die ich so hier herum liegen habe hat diese id:

```
06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd.: Unknown device 8180 (rev 20)

06:00.0 Class 0200: 10ec:8180 (rev 20)
```

gemäss dokumentation wird die pci class id als 6-stellige zahl übergeben. ich weiss nicht, ob da ein 0x noch dazu kommt oder nicht?

wie auch immer... ich glaube das obere script ist der richtige ansatz, um das problem zu lösen.

gruss

steve

----------

## Sas

hallo steve,

nochmal vielen dank für deine mühe, hier die gewünschten infos:

```
s-mobile silas # lspci -v

0000:00:00.0 Host bridge: Silicon Integrated Systems [SiS] 740 Host (rev 01)

        Flags: bus master, medium devsel, latency 32

        Memory at e8000000 (32-bit, non-prefetchable)

        Capabilities: [c0] AGP version 2.0

0000:00:01.0 PCI bridge: Silicon Integrated Systems [SiS] SiS 530 Virtual PCI-to-PCI bridge (AGP) (prog-if 00 [Normal decode])

        Flags: bus master, fast devsel, latency 0

        Bus: primary=00, secondary=01, subordinate=01, sec-latency=0

        I/O behind bridge: 0000d000-0000dfff

        Memory behind bridge: e7800000-e7ffffff

        Prefetchable memory behind bridge: f0000000-febfffff

        Expansion ROM at 0000d000 [disabled] [size=4K]

0000:00:02.0 ISA bridge: Silicon Integrated Systems [SiS] SiS962 [MuTIOL Media IO] (rev 04)

        Flags: bus master, medium devsel, latency 0

0000:00:02.1 SMBus: Silicon Integrated Systems [SiS]: Unknown device 0016

        Flags: medium devsel, IRQ 5

        I/O ports at e800 [size=32]

0000:00:02.5 IDE interface: Silicon Integrated Systems [SiS] 5513 [IDE] (prog-if 80 [Master])

        Subsystem: Asustek Computer, Inc.: Unknown device 1658

        Flags: bus master, medium devsel, latency 32

        I/O ports at b800 [size=16]

        Capabilities: [58] Power Management version 2

0000:00:02.6 Modem: Silicon Integrated Systems [SiS] Intel 537 [56k Winmodem] (rev a0) (prog-if 00 [Generic])

        Subsystem: Asustek Computer, Inc.: Unknown device 1696

        Flags: medium devsel, IRQ 9

        I/O ports at b400

        I/O ports at b000 [size=128]

        Capabilities: [48] Power Management version 2

0000:00:02.7 Multimedia audio controller: Silicon Integrated Systems [SiS] Sound Controller (rev a0)

        Subsystem: Asustek Computer, Inc.: Unknown device 1653

        Flags: bus master, medium devsel, latency 32, IRQ 9

        I/O ports at a800

        I/O ports at a400 [size=128]

        Capabilities: [48] Power Management version 2

0000:00:03.0 USB Controller: Silicon Integrated Systems [SiS] USB 1.0 Controller (rev 0f) (prog-if 10 [OHCI])

        Subsystem: Asustek Computer, Inc.: Unknown device 1659

        Flags: bus master, medium devsel, latency 32, IRQ 9

        Memory at e7000000 (32-bit, non-prefetchable)

        Capabilities: [dc] Power Management version 2

0000:00:03.1 USB Controller: Silicon Integrated Systems [SiS] USB 1.0 Controller (rev 0f) (prog-if 10 [OHCI])

        Subsystem: Asustek Computer, Inc.: Unknown device 1659

        Flags: bus master, medium devsel, latency 32, IRQ 9

        Memory at e6800000 (32-bit, non-prefetchable)

        Capabilities: [dc] Power Management version 2

0000:00:03.2 USB Controller: Silicon Integrated Systems [SiS] USB 1.0 Controller (rev 0f) (prog-if 10 [OHCI])

        Subsystem: Asustek Computer, Inc.: Unknown device 1659

        Flags: bus master, medium devsel, latency 32, IRQ 9

        Memory at e6000000 (32-bit, non-prefetchable)

        Capabilities: [dc] Power Management version 2

0000:00:03.3 USB Controller: Silicon Integrated Systems [SiS] USB 2.0 Controller (prog-if 20 [EHCI])

        Subsystem: Asustek Computer, Inc.: Unknown device 165a

        Flags: bus master, medium devsel, latency 32, IRQ 9

        Memory at e5800000 (32-bit, non-prefetchable)

        Capabilities: [50] Power Management version 2

0000:00:04.0 Ethernet controller: Silicon Integrated Systems [SiS] SiS900 10/100 Ethernet (rev 90)

        Subsystem: Asustek Computer, Inc.: Unknown device 1455

        Flags: bus master, medium devsel, latency 32, IRQ 11

        I/O ports at a000

        Memory at e5000000 (32-bit, non-prefetchable) [size=4K]

        Capabilities: [40] Power Management version 2

0000:00:0a.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev aa)

        Subsystem: Asustek Computer, Inc.: Unknown device 1654

        Flags: bus master, medium devsel, latency 168, IRQ 5

        Memory at e4800000 (32-bit, non-prefetchable)

        Bus: primary=00, secondary=02, subordinate=05, sec-latency=176

        Memory window 0: 1f800000-1fbff000 (prefetchable)

        Memory window 1: 1fc00000-1ffff000

        I/O window 0: 00004000-000040ff

        I/O window 1: 00004400-000044ff

        16-bit legacy interface ports at 0001

0000:00:0a.1 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev aa)

        Subsystem: Asustek Computer, Inc.: Unknown device 1654

        Flags: bus master, medium devsel, latency 168, IRQ 9

        Memory at e2800000 (32-bit, non-prefetchable)

        Bus: primary=00, secondary=06, subordinate=09, sec-latency=176

        Memory window 0: 20000000-203ff000 (prefetchable)

        Memory window 1: 20400000-207ff000

        I/O window 0: 00004800-000048ff

        I/O window 1: 00004c00-00004cff

        16-bit legacy interface ports at 0001

0000:00:0a.2 FireWire (IEEE 1394): Ricoh Co Ltd R5C552 IEEE 1394 Controller (rev 02) (prog-if 10 [OHCI])

        Subsystem: Asustek Computer, Inc.: Unknown device 1657

        Flags: bus master, medium devsel, latency 32, IRQ 11

        Memory at e0800000 (32-bit, non-prefetchable)

        Capabilities: [dc] Power Management version 2

0000:01:00.0 VGA compatible controller: Silicon Integrated Systems [SiS] SiS650/651/M650/740 PCI/AGP VGA Display Adapter (prog-if 00 [VGA])

        Subsystem: Asustek Computer, Inc.: Unknown device 1612

        Flags: 66Mhz, medium devsel

        BIST result: 00

        Memory at f0000000 (32-bit, prefetchable)

        Memory at e7800000 (32-bit, non-prefetchable) [size=128K]

        I/O ports at d800 [size=128]

        Capabilities: [40] Power Management version 2

        Capabilities: [50] AGP version 2.0

0000:02:00.0 Ethernet controller: Atheros Communications, Inc.: Unknown device 0013 (rev 01)

        Subsystem: Atheros Communications, Inc.: Unknown device 1025

        Flags: bus master, medium devsel, latency 168, IRQ 5

        Memory at 1fc00000 (32-bit, non-prefetchable)

        Capabilities: [44] Power Management version 2

```

```

s-mobile silas # for foo in /sys/bus/pci/devices/0000\:02\:00.0/* ; do [[ -f "${foo}" ]] && echo ${foo} && cat ${foo} && echo ; done

/sys/bus/pci/devices/0000:02:00.0/class

0x020000

/sys/bus/pci/devices/0000:02:00.0/config

 ÀP%D

@Æ

/sys/bus/pci/devices/0000:02:00.0/detach_state

0

/sys/bus/pci/devices/0000:02:00.0/device

0x0013

/sys/bus/pci/devices/0000:02:00.0/irq

5

/sys/bus/pci/devices/0000:02:00.0/resource

0x000000001fc00000 0x000000001fc0ffff 0x0000000000000200

0x0000000000000000 0x0000000000000000 0x0000000000000000

0x0000000000000000 0x0000000000000000 0x0000000000000000

0x0000000000000000 0x0000000000000000 0x0000000000000000

0x0000000000000000 0x0000000000000000 0x0000000000000000

0x0000000000000000 0x0000000000000000 0x0000000000000000

0x0000000000000000 0x0000000000000000 0x0000000000000000

/sys/bus/pci/devices/0000:02:00.0/subsystem_device

0x1025

/sys/bus/pci/devices/0000:02:00.0/subsystem_vendor

0x168c

/sys/bus/pci/devices/0000:02:00.0/vendor

0x168c

s-mobile silas #

```

werde jetzt dein script mal ausprobieren,

grüsse Silas

----------

## Sas

lspci -vn gibt folgendes aus:

```
0000:02:00.0 Class 0200: 168c:0013 (rev 01)

        Subsystem: 168c:1025

        Flags: bus master, medium devsel, latency 168, IRQ 5

        Memory at 1fc00000 (32-bit, non-prefetchable)

        Capabilities: [44] Power Management version 2

```

daraufhin hab ich die äusserste if-abfrage in deinem script folgendermassen angepasst:

```
if [ "${PCI_CLASS}" == "020000" ] && [ "${PCI_ID}" == "168c:0013" ]
```

allerdings leider ohne erfolg. selbst wenn ich sie ganz weglasse, macht hotplug gar nichts mehr... 

muss ich mit dem script noch irgendwas machen? was hats mit dem parameter ACTION auf sich? ich hab auch schon versucht es von hand aufzurufen und als parameter "add" bzw "register" übergeben... mit dem gleichen resultat.

gruss, Silas

edit: also laut http://linux-hotplug.sourceforge.net/?selected=hotplug sollten die actions ja als events vom kernel modul kommen, ich muss mich also nicht drum kümmern...

----------

## Sas

also ich habs jetzt ganz einfach gemacht und führe nur für die richtige karte das init-script nochmal aus:

```

#!/bin/bash

 if [ "${PCI_CLASS}" == "020000" ] && [ "${PCI_ID}" == "168c:0013" ]

then

        /etc/init.d/net.ath0 restart

fi

```

das funktioniert soweit. wenn ich zeit habe, schaue ich mir das von net.agent abgeleitete script nochmal an und versuche rauszufinden, warum das nicht will.

auf jeden fall nochmal vielen dank steve, denn allein wäre ich da wohl kaum drauf gekommen  :Wink: 

grüsse Silas

----------

## steveb

 *Sas wrote:*   

> also ich habs jetzt ganz einfach gemacht und führe nur für die richtige karte das init-script nochmal aus:
> 
> ```
> 
> #!/bin/bash
> ...

 Hey! Super! Endlich! Es freut mich, dass es geklappt hat  :Wink: 

Lieben Gruss

Steve

----------

## Sas

ja, und mich erst  :Wink: 

war wirklich ne harte nuss; finds echt klasse von dir, dass du soviel mühe (und freizeit) geopfert hast, um jemandem, den du nicht mal kennst bei nem problem zu helfen, das dich nicht im geringsten betrifft! 

ich finde das muss in dieser deutlichkeit mal gesagt werden und es kann ruhig jeder versuchen, sich ein kleines beispiel daran zu nehmen  :Wink: 

grüsse, Silas

----------

## steveb

 *Sas wrote:*   

> ja, und mich erst 
> 
> war wirklich ne harte nuss; finds echt klasse von dir, dass du soviel mühe (und freizeit) geopfert hast, um jemandem, den du nicht mal kennst bei nem problem zu helfen, das dich nicht im geringsten betrifft! 
> 
> ich finde das muss in dieser deutlichkeit mal gesagt werden und es kann ruhig jeder versuchen, sich ein kleines beispiel daran zu nehmen 
> ...

 Ich glaube, wir helfen uns alle hier. Sonst würde das Gentoo Forum nicht so einen guten Ruf haben  :Wink: 

Übrigens habe ich auch sehr viel dazu gelernt, bei der Suche nach der Lösung.

Lieben Gruss

Steve

----------

