# [fichiers de conf] fichiers corrompus...

## kangal

Salut a tous!!

Voila, j'ai par accident un peu pourris mon /etc/conf.d/rc, par consequent j'ai enormement de warning au boot concernant le checkroot et le checkfs et de plus, je ne peux plus faire de sshd start:

root:/home/kangal >> /etc/init.d/sshd start

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...                                                                              [ !! ]

 * ERROR:  Problem starting needed services.

 *         "sshd" was not started.

ma question est assez generique: Comment faire pour recuperer un fichier si ce dernier a ete corrompu/effacer???

Merci beaucoup de votre aide:wink:

----------

## kopp

Pour le sshd, tu reemerges ssh

pour le rc, tu reemerge baselayout (enfin, me semble)

----------

## El_Goretto

 *kopp wrote:*   

> Pour le sshd, tu reemerges ssh
> 
> pour le rc, tu reemerge baselayout (enfin, me semble)

 

C'est normal que sshd ne démarre pas si aucune interface réseau n'est présente. Il n'y a "que" baselayout à réinstaller (mais attention au miyard de fichiers de conf à manipuler derrière avec etc-update).

----------

## kangal

C'est bizare, j'ai remerger baselayout:

root:~ >> etc-update 

Scanning Configuration files...

Exiting: Nothing left to do; exiting.  :Smile: 

et quand je lance sshd

 * Starting eth0

 *   Bringing up eth0

 *     dhcp

 *       Running dhcpcd ...                                                                              [ !! ]

 * ERROR:  Problem starting needed services.

 *         "sshd" was not started.

Surtout que ma carte ethernet est eth1 et pas eth0...

----------

## kopp

Qu'est ce qu'il y a dans ton fichier /etc/conf.d/net ?

----------

## kangal

root:/home/kangal >> cat /etc/conf.d/net

# /etc/conf.d/net:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface

#

iface_eth1="dhcp"

#iface_eth0="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"

# For passing options to dhcpcd use dhcpcd_eth?

#

# For adding aliases to a interface

#

#alias_eth0="192.168.0.3 192.168.0.4"

# NB:  The next is only used for aliases.

#

# To add a custom netmask/broadcast address to created aliases,

# uncomment and change accordingly.  Leave commented to assign

# defaults for that interface.

#

#broadcast_eth0="192.168.0.255 192.168.0.255"

#netmask_eth0="255.255.255.0 255.255.255.0"

# For setting the default gateway

#

#gateway="eth0/192.168.0.1"

Mais j'ai l'impression que mon probleme viens de mon /sbin/rc...

root:/home/kangal >> /sbin/rc

/etc/init.d/domainname: line 12: syntax error: unexpected end of file

 * ERROR:  "/etc/init.d/domainname" has syntax errors in it; not executing...

 * Starting eth0

 *   Bringing up eth0

 *     Configuration not set for eth0 - assuming dhcp

 *     dhcp

 *       Running dhcpcd ...                                                                                                      [ !! ]

 * ERROR:  Problem starting needed services.

 *         "netmount" was not started.

 * ERROR:  Problem starting needed services.

 *         "sshd" was not started.

Au boot, j'ai des messages d'erreur a propo de mon /sbin/rc... :Sad: 

----------

## El_Goretto

J'ai eu une fois aussi des boulettes de ce genre parce que j'avais introduit une faute de syntaxe dans rc.conf je crois. Enfin , à toi de passer tes fichiers de conf en revue, avec la coloration syntaxique gentoo de vim pour t'aider à voir ce qui peut coincer.

Après, je vois pas.  :Confused: 

----------

## ghoti

 *kangal wrote:*   

> Surtout que ma carte ethernet est eth1 et pas eth0...

 

Ton problème ressemble furieusement à celui-ci ...

----------

## kangal

non parce que eth1 et eth0 ne se melange pas...C'est defini comme ca: eth0=firewire, eth1=ethernet

kangal:~ >> cat /etc/conf.d/net

# /etc/conf.d/net:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface

#

iface_eth1="dhcp"

#iface_eth0="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"

# For passing options to dhcpcd use dhcpcd_eth?

#

# For adding aliases to a interface

#

#alias_eth0="192.168.0.3 192.168.0.4"

# NB:  The next is only used for aliases.

#

# To add a custom netmask/broadcast address to created aliases,

# uncomment and change accordingly.  Leave commented to assign

# defaults for that interface.

#

#broadcast_eth0="192.168.0.255 192.168.0.255"

#netmask_eth0="255.255.255.0 255.255.255.0"

# For setting the default gateway

#

#gateway="eth0/192.168.0.1"

Et c'est tres bizare parce que quand ma gentoo boot, internet ne marche pas alors je fais un dhcpcd eth1 et ca me donne ca:

root:/home/kangal >> dhcpcd eth1 

****  dhcpcd: already running

****  dhcpcd: if not then delete /var/run/dhcpcd-eth1.pid file

et je suis obliger d'effacer le fichier et de refaire un dhcpcd eth1 pour que ca marche...

Et puis comment dire a sshd de ne pas demarrer eth0???

root:~ >> /etc/init.d/sshd start

 * Starting eth0

 *   Bringing up eth0

 *     Configuration not set for eth0 - assuming dhcp

 *     dhcp

 *       Running dhcpcd ...                                                                              [ !! ]

 * ERROR:  Problem starting needed services.

 *         "sshd" was not started.

root:~ >>

----------

## kangal

En fait mon principal probleme viens de mon /sbin/rc, j'ai cette erreur qui reviens regulierement:

Start command not found, a la ligne 416...Voici la ligne en question:

start || eerror "failed to start /etc/inid.d/$(service)"

Au boot il y a donc plein de truc qu'il ne peut pas lancer:(

----------

## kangal

Personne n'as d'idee sur ce qui peut causer ce probleme??? :Embarassed:   :Sad: 

----------

## ghoti

 *kangal wrote:*   

> En fait mon principal probleme viens de mon /sbin/rc, j'ai cette erreur qui reviens regulierement:
> 
> Start command not found, a la ligne 416...Voici la ligne en question:
> 
> start || eerror "failed to start /etc/inid.d/$(service)"
> ...

 

En fait, les fonctions "start()" sont définies dans les différents services à lancer et sont "sourcées" à la ligne 410 du script /sbin/rc :

 *Quote:*   

> 	start_critical_service() {
> 
> 		(
> 
> 		local retval=
> ...

 

Les problèmes proviendraient donc plutôt des scripts /etc/init.d/* eux-mêmes.

Pourrais-tu lister le code d'un de ces scripts qui foirent ?

----------

## kangal

Je ne comprend pas alors la commande start suivi du double pipe, elle est cence faire quoi???

enfin bref, voici certain de mes script qui deconne:

mon clock, mais je croit que c'est parce qu'il est incomplet:

root:/home/kangal >> cat /etc/init.d/clock  

#!/sbin/runscript

# Copyright 1999-2005 Gentoo Foundation

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

opts="save"

depend() {

        need localmount

}

setupopts() {

        if is_uml_sys ; then

                TBLURB="UML"

                fakeit=1

        elif is_vserver_sys ; then

                TBLURB="VServer"

                fakeit=1

        elif is_xenU_sys ; then

                TBLURB="xen"

                fakeit=1

        elif grep -q ' cobd$' /proc/devices ; then

                TBLURB="coLinux"

                fakeit=1

        elif [[ ${CLOCK} == "UTC" ]] ; then

                myopts="--utc"

                TBLURB="UTC"

        else

                myopts="--localtime"

                TBLURB="Local Time"

        fi

        [[ ${fakeit} -eq 1 ]] && return 0

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

                myadj="--noadjfile"

        else

                myadj="--adjust"

        fi

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

                myopts="${myopts} --srm"

        fi

        if [[ ${ARC} == "arc" ]] ; then

                myopts="${myopts} --arc"

        fi

        myopts="${myopts} ${CLOCK_OPTS}"

        # Make sure user isn't using rc.conf anymore.

        if grep -qs ^CLOCK= /etc/rc.conf ; then

                ewarn "CLOCK should not be set in /etc/rc.conf but in /etc/conf.d/clock"

        fi

}

start() {

        local myopts=""

        local myadj=""

        local TBLURB="" fakeit=0

        local errstr=""

le fichier checkroot ne marhe pas non plus, ainsi que le checkfs mais ils sont vide!!! je ne sais pas quoi mettre dedans...

Je crois que le hostname ne passe pas non plus:

root:/home/kangal >> cat /etc/init.d/hostname 

#!/sbin/runscript

# Copyright 1999-2005 Gentoo Foundation

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

depend() {

        need checkroot

}

start() {

        local myhost=$(/bin/hostname 2>/dev/null)

        local retval=0

        # If the hostname is already set via the kernel, and /etc/hostname 

        # isn't setup, then we shouldn't go reseting the configuration #38172.

        if [[ -z ${myhost} ]] || [[ ${myhost} == "(none)" ]] ; then

                myhost="localhost"

        fi

        if [[ -f /etc/hostname ]] ; then

                ewarn "You should stop using /etc/hostname and use /etc/conf.d/hostname"

                myhost=$(</etc/hostname)

        else

                myhost=${HOSTNAME}

        fi

        ebegin "Setting hostname to ${myhost}"

        /bin/hostname "${myhost}"

        retval=$?

        eend ${retval} "Failed to set the hostname"

        if [[ ${retval} -eq 0 ]] ; then

                # setup $HOSTNAME, ignore errors in case /etc is readonly.

                echo "HOSTNAME=\"${myhost}\"" 2>/dev/null > /etc/env.d/01hostname

        fi

        return ${retval}

}

# vim:ts=4

Et le plus chiant, le ssh qui ne marche pas (tu peux voir mon message d'erreur plus haut...)

root:/home/kangal >> cat /etc/init.d/sshd 

#!/sbin/runscript

# Copyright 1999-2004 Gentoo Foundation

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

# $Header: /var/cvsroot/gentoo-x86/net-misc/openssh/files/sshd.rc6,v 1.14 2005/04/20 02:08:38 vapier Exp $

depend() {

        use logger dns

        need net

}

checkconfig() {

        if [ ! -d /var/empty ] ; then

                mkdir -p /var/empty || return 1

        fi

        if [ ! -e /etc/ssh/sshd_config ] ; then

                eerror "You need an /etc/ssh/sshd_config file to run sshd"

                eerror "There is a sample file in  /usr/share/doc/openssh"

                return 1

        fi

        gen_keys

}

gen_keys() {

        if [ ! -e /etc/ssh/ssh_host_key ] ; then

                einfo "Generating Hostkey..."

                /usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh/ssh_host_key -N ''

        fi

        if [ ! -e /etc/ssh/ssh_host_dsa_key ] ; then

                einfo "Generating DSA-Hostkey..."

                /usr/bin/ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key -N ''

        fi

        if [ ! -e /etc/ssh/ssh_host_rsa_key ] ; then

                einfo "Generating RSA-Hostkey..."

                /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''

        fi

}

start() {

        checkconfig || return 1

        ebegin "Starting sshd"

        /usr/sbin/sshd

        eend $?

}

stop() {

        ebegin "Stopping sshd"

        start-stop-daemon --stop --quiet --pidfile /var/run/sshd.pid

        eend $?

}

Merci de ton aide:(

----------

## ghoti

 *kangal wrote:*   

> Je ne comprend pas alors la commande start suivi du double pipe, elle est cence faire quoi???

 

C'est un chaînage de commandes : la commande à droite du "||" n'est exécutée que si le return code de la commande de gauche est différent de 0.

Un rc différent de 0 signifie en général "erreur" et le but du double pipe est alors d'afficher le message d'erreur idoine.

Mais ici, la commande "start" n'est pas trouvée, donc pas de return code (voir ci-après).

 *Quote:*   

> enfin bref, voici certain de mes script qui deconne:
> 
> mon clock, mais je croit que c'est parce qu'il est incomplet:

 

Si ton copier/coller est correct alors, en effet, le script est pourri. En particulier, la fonction start n'est pas complète, donc pas définie, ce qui bien sûr provoque un "start not found" et termine le script.

 *Quote:*   

> le fichier checkroot ne marhe pas non plus, ainsi que le checkfs mais ils sont vide!!! je ne sais pas quoi mettre dedans...
> 
> Je crois que le hostname ne passe pas non plus:

 

Le hostname ne passe pas parce qu'il a besoin de checkroot :

 *Quote:*   

> depend() {
> 
>        need checkroot
> 
> }

 

 *Quote:*   

> Et le plus chiant, le ssh qui ne marche pas (tu peux voir mon message d'erreur plus haut...)

 

Là, c'est parce qu'il a besoin que le réseau soit fonctionnel, ce qui n'est pas le cas puisque le démarrage de ton dhcpd a planté!

Bref, j'ai l'impression que ton dernier "emerge baselayout" a complètement foiré  :Sad: 

Refais une tentative et dis quoi ...

----------

## kangal

Le probleme c'est que quand j'essaye de le reemerger, il me dit qu'il est deja a jour et du coup ne fais rien  :Sad: 

Je sais vraiment pas comment resoudre mon probleme... :Confused: 

----------

## boozo

'alute

je prends en cours dsl après tout tu es dans de très bonnes mains...  :Wink: 

si tu fais simplement un 

```
emerge -Dv baselayout
```

 pour voir ?

----------

## kangal

l'emerge marche mais par contre:

root:/home/kangal >> etc-update 

Scanning Configuration files...

Exiting: Nothing left to do; exiting.  :Smile: 

Donc en gros il remplace pas les fichiers  :Crying or Very sad: 

Dommage, car ca semble etre la solution...

----------

## boozo

essayes de te refaire les fichiers nécessaires avec les fichiers d'exemples tq /etc/conf.d/net.example qui est à la base de ton /etc/conf.d/net tu en fais une copie tu le renseigne comme il se doit et tu testes après  :Wink: 

ps: tu devrais avoir des fichiers similaires pour les autres fichiers qui te posent pb je pense... sinon tu les copies et on regardera

[Edit] Quelle est ta version de baselayout stp et ton archi également... je ne m'en souviens plus  :Very Happy: 

----------

## kangal

sys-apps/baselayout-1.11.13

Je vais essayer de refaire chacun des fichiers...Mais je pourrait pas les effacer, re-emerger baselayout et faire un etc-update???la au moin il trouverait des fichiers a modifier non???

----------

## boozo

plutôt que d'effacer tes anciens fichiers moi je rajouterais une ligne de commentaire à l'intérieur comme çà ils seront bien reconnus comme différent par emerge et tu auras tous les ._c0000 ... et si tu veux la liste des fichiers fournit par baselayout 

```
equery f baselayout
```

  :Wink: 

----------

## kangal

ALors, j'ai resolu plein de mes problemes en effacant les fichiers en question et en les reemergeant:

seul 2 probleme subistent:

J'ai effacer mon /etc/init.d/sshd, quand je veux emerger ssh pour pouvoir le remplacer. j'ai ca:

root:/home/kangal >> emerge ssh 

Calculating dependencies ...done!

!!! Error: the net-misc/openssh package conflicts with another package.

!!!        both can't be installed on the same system together.

!!!        Please use 'emerge --pretend' to determine blockers.

Je ne sais pas si je doit donc unmerger openssh ou et emerger ssh apres ou pas:( 

Mon autre probleme viens d'internet, puisque j'ai un message d'erreur:

starting eth0

bringing up eth0     (ma carte est eth1...)

    configuration not set for eth0 - assuming dhcpcd

dhcpcd

running dhcpcd

error :probleme starting  needed device

netmount was not started

Apres ca quand je boote, je suis obliger de faire un rm /var/run/dhcpcd-eth1.pid file

puis un dhcpcd eth1 pour avoir une connection...

merci de votre aide!

----------

## boozo

attention net-misc/openssh n'est pas net-misc/ssh (d'ou ton conflit) je pense que celui que tu as est openssh et c'est lui qui te fournis le demon sshd alors re-emerges le  :Wink: 

```
emerge -Dv openssh
```

----------

## Dais

Pour le ssh, garde openssh, tout simplement. Tu peux utiliser le ssh comme d'habitude.

----------

## kangal

g reemerger openssh, j'ai donc de nouveau mon sshd mais:

root:/home/kangal >> /etc/init.d/sshd start

 * Caching service dependencies ...                                                                      [ ok ]

 * Starting eth0

 *   Bringing up eth0

 *     Configuration not set for eth0 - assuming dhcp

 *     dhcp

 *       Running dhcpcd ...                                                                              [ !! ]

 * ERROR:  Problem starting needed services.

 *         "sshd" was not started.

----------

## boozo

tu as quoi dans ton /etc/conf.d/net ?

 *Quote:*   

> iface_eth0="dhcp"
> 
> dhcpcd_eth0=" -t 10"
> 
> 

 

----------

## kangal

root:/home/kangal >> cat /etc/conf.d/net

# /etc/conf.d/net:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $

# Global config file for net.* rc-scripts

# This is basically the ifconfig argument without the ifconfig $iface

#

iface_eth1="dhcp"

#iface_eth0="207.170.82.202 broadcast 207.0.255.255 netmask 255.255.0.0"

# For DHCP set iface_eth? to "dhcp"

# For passing options to dhcpcd use dhcpcd_eth?

#

# For adding aliases to a interface

#

#alias_eth0="192.168.0.3 192.168.0.4"

# NB:  The next is only used for aliases.

#

# To add a custom netmask/broadcast address to created aliases,

# uncomment and change accordingly.  Leave commented to assign

# defaults for that interface.

#

#broadcast_eth0="192.168.0.255 192.168.0.255"

#netmask_eth0="255.255.255.0 255.255.255.0"

# For setting the default gateway

#

#gateway="eth0/192.168.0.1"

----------

## boozo

question bête mais : tu as bien un lien net.eth1 qui pointe sur ton /etc/conf.d/net ?

[Edit] et un net.eth1 qui pointe sur /etc/init.d/net.lo...

----------

## kangal

C'est bizare...Il me semblait bien que oui mais plus maintenant....c'est surement du a un des mes emerges...

----------

## kangal

Bon finalement j'ai retrouver mon net.eth0 mais j'ai pas de net.eth1, il y a bien un lien vers net,lo

#!/sbin/runscript

# Copyright (c) 2004-2005 Gentoo Foundation

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

# $Header$

# Contributed by Roy Marples (uberlord@gentoo.org)

# Many thanks to Aron Griffis (agriffis@gentoo.org)

# for help, ideas and patches

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

if [[ -n ${NET_DEBUG} ]]; then

        set -x

        devnull=/dev/stderr

else

        devnull=/dev/null

fi

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

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

depend() {

        use coldplug hotplug pcmcia usb isdn4linux wlan

        # Load any custom depend functions for the given interface

        # For example, br0 may need eth0 and eth1

        local iface=${myservice##*.}

        [[ $( type -t depend_${iface} ) == "function" ]] && depend_${iface}

}

# Define where our modules are

MODULES_DIR=/lib/rcscripts/net.modules.d

# Load some functions shared between ourselves and our dhcp helpers

source ${MODULES_DIR}/helpers.d/functions

# Make some wrappers to fudge after/before/need/use depend flags.

# These are callbacks so mods[i] will be set.

after() {

        local x="$*"

        [[ $# -gt 1 ]] && x=$( echo -e "${x// /\n}" | sort | xargs )

        eval "${MODULE}_after() { echo \"$x\"; }"

 Does the minimum checking on a module - even when forcing

module_load_minimum() {

        local f=${1} MODULE=${1##*/}

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

                eerror "${f} does not exist"

                return 1

        fi

        if ! source ${f} ; then

                eerror "${MODULE} failed a sanity check"

                return 1

        fi

        for f in check_installed provides check_depends depend; do

                [[ $( type -t ${MODULE}_${f} ) == function ]] && continue

                eerror "${MODULE} does not support the required function ${f}"

                return 1

        done

        # Wrap our before/after/need/use functions

        ${MODULE}_depend

        return 0

}

# bool modules_load_auto()

#

# Load and check each module for sanity

# If the module is not installed, the functions are to be removed

modules_load_auto() {

        local e f i j beforefuncs afterfuncs diffs unload

        # Populate the MODULES array

        MODULES=( $( find ${MODULES_DIR}/ -maxdepth 1 -type f ! -name ".*" | sort ) )

        # Each of these sources into the global namespace, so it's

        # important that module functions and variables are prefixed with

        # the module name, for example iproute2_

        beforefuncs="$( typeset -F )"

        j=${#MODULES[@]}

        loaded_interface=false

        for (( i=0; i<j; i++ )); do

                unload=false

                module_load_minimum ${MODULES[i]} || unload=true

                MODULES[i]=${MODULES[i]##*/}

                ! ${unload} && ${MODULES[i]}_check_installed false || unload=true

                if [[ ${MODULES[i]} == interface ]]; then

                        eerror "interface is a reserved name - cannot load a module called interface"

                        return 1

                fi

                afterfuncs="$( typeset -F )"

                if ${unload} ; then

                        unset MODULES[i]

                        unsetfuncs="${unsetfuncs} $( diff -U0 <( echo "${beforefuncs}" ) <( echo "${afterfuncs}" ) 2>/dev/n

ull \

                                | awk 'BEGIN { ORS = " "; } /+declare -f/ { print $3; }' )"

                fi

                beforefuncs="${afterfuncs}"

        done

        MODULES=( "${MODULES[@]}" )

        PROVIDES=( "${PROVIDES[@]}" )

}

# bool modules_check_user(void)

modules_check_user() {

        local -a umods

        local i j k l npref nmods=${#MODULES[@]}

        # Has the interface got any specific modules?

        eval umods=( \"\$\{modules_${iface}\[@\]\}\" )

        # Global setting follows interface-specific setting

        umods=( "${umods[@]}" "${modules[@]}" )

        # Add our preferred modules

        npref=3

        umods=( "${umods[@]}" "ifconfig" "dhcpcd" "iwconfig" )

        # First we strip any modules that conflict from user settings

        # So if the user specifies pump then we don't use dhcpcd

        for (( i=0; i<${#umods[@]}; i++ )); do

                # Some users will inevitably put "dhcp" in their modules

                # list.  To keep users from screwing up their system this

                # way, ignore this setting so that the default dhcp

                # module will be used.

                [[ ${umods[i]} == dhcp ]] && continue

                # We remove any modules we explicitly don't want

                if [[ ${umods[i]} == !* ]]; then

                        for (( j=0; j<nmods; j++ )); do

                                [[ -z ${MODULES[j]} ]] && continue

                                if [[ ${umods[i]:1} == ${MODULES[j]} || ${umods[i]:1} == ${PROVIDES[j]} ]]; then

                                       # We may need to setup a class wrapper for it even though

                                        # we don't use it directly

                                        ${MODULES[j]}_check_installed && module_class_wrap ${MODULES[j]}

                                        unset MODULES[j]

                                        unset PROVIDES[j]

                                        break

                                fi

                        done

                        continue

                fi

                if [[ $( type -t ${umods[i]}_provides ) != function ]]; then

                        # If the module is one of our preferred modules, then

                        # ignore this error; whatever is available will be

                        # used instead.

                        (( i < ${#umods[@]} - npref )) || continue

                        eerror "${umods[i]} is not a valid module (missing provides)"

                        return 1

                fi

                # Ensure that the user specified module has its package installed

                if (( i < ${#umods[@]} - npref )); then

                        # $1==true causes check_installed to report its own errors

                        ${umods[i]}_check_installed true || return 1

                else

                        # If this happens on a preferred modules, ignore it;

                        # whatever is available will be used instead.

                        ${umods[i]}_check_installed false || continue

                fi

                mod=$( ${umods[i]}_provides )

                for (( j=0; j<nmods; j++ )); do

                        [[ -z ${MODULES[j]} ]] && continue

                        if [[ ${PROVIDES[j]} == ${mod} && ${umods[i]} != ${MODULES[j]} ]]; then

                                # We don't have a match - now ensure that we still provide an alternative.

                                # This is to handle our preferred modules.

                                for (( l=0; l<nmods; l++ )); do

                                        [[ ${l} -eq ${j} || -z ${MODULES[l]} ]] && continue

                                        if [[ ${PROVIDES[l]} == ${mod} ]]; then

                                                unset MODULES[j]

                                                unset PROVIDES[j]

                                                break

                                        fi

                                done

                        fi

                done

        done

        # Then we strip conflicting modules.

        # We only need to do this for 3rd party modules that conflict with

        # our own modules and the preferred list AND the user modules

        # list doesn't specify a preference.

        for (( i=0; i<nmods-1; i++ )); do

                [[ -z ${MODULES[i]} ]] && continue

                for (( j=i+1; j<nmods; j++)); do

                        [[ -z ${MODULES[j]} ]] && continue

                        [[ ${PROVIDES[i]} == ${PROVIDES[j]} ]] && unset MODULES[j] && unset PROVIDES[j]

                done

        done

        MODULES=( "${MODULES[@]}" )

        PROVIDES=( "${PROVIDES[@]}" )

        return 0

}

# void modules_sort(void)

modules_sort() {

        local -a modnums sort_history modafter modbefore

        local i j k p changed_something nmods=${#MODULES[@]}

        # Sort our modules

        # We do this by assigning numbers to each module

        # We also assign modbefore and modafter so we don't

        # shell out as much because it's expensive on CPU.

        modnums=()

        for (( i=0; i<nmods; i++ )); do

                modnums[i]=${i}

                [[ $( type -t ${MODULES[i]}_after ) == function ]] && modafter[i]=$( ${MODULES[i]}_after )

                [[ $( type -t ${MODULES[i]}_before ) == function ]] && modbefore[i]=$( ${MODULES[i]}_before )

        done

       # Then we swap numbers based on and after/before flags

        # until we don't swap anymore. The sort_history array prevents

        # the possibility of an infinite loop

        sort_history[0]="${modnums[*]}"

        for (( k=1; 1; k++ )); do

                changed_something=false

                for (( i=0; i<nmods; i++ )); do

                        for p in ${modafter[i]}; do

                                for (( j=0; j<nmods; j++ )); do

                                        [[ ${p} != ${MODULES[j]} && ${p} != ${PROVIDES[j]} ]] && continue

                                        if [[ ${modnums[i]} -lt ${modnums[j]} ]]; then

                                                tmp=${modnums[i]}

                                                modnums[i]=${modnums[j]}

                                                modnums[j]=${tmp}

                                                changed_something=true

                                        fi

                                done

                        done

                        for p in ${modbefore[i]}; do

                                for (( j=0; j<nmods; j++ )); do

                                        [[ ${p} != ${MODULES[j]} && ${p} != ${PROVIDES[j]} ]] && continue

                                        if [[ ${modnums[i]} -gt ${modnums[j]} ]]; then

                                                tmp=${modnums[i]}

                                                modnums[i]=${modnums[j]}

                                                modnums[j]=${tmp}

                                                changed_something=true

                                        fi

                                done

                        done

                done

                ${changed_something} || break

                # Make sure we aren't repeating a previous state

                # First time through, k=1, k/2=0

                sort_history[k]="${modnums[*]}"

                if [[ ${sort_history[k]} == ${sort_history[k/2]} ]]; then

                        eerror "Detected an infinite loop sorting modules; blundering ahead"

                     break

                fi

        done

         # Finally we sort our modules in number order

        um=""

        for (( i=0; i<nmods; i++ )); do

                um="${um}${modnums[i]} ${MODULES[i]} ${PROVIDES[i]}\n"

        done

        p=( $( echo -e "${um}" | sort -n | awk '{print $2,$3}' ) )

        MODULES=()

        PROVIDES=()

        j=0

        for (( i=0; i<${#p[@]}; i+=2 )); do

                MODULES[j]=${p[i]}

                PROVIDES[j]=${p[i+1]}

                (( j++ ))

        done

}

# bool modules_check_depends(bool showprovides)

modules_check_depends() {

        local showprovides=${1:-false} nmods=${#MODULES[@]} i j needmod

        local missingdeps p  interface=false

        for (( i=0; i<nmods; i++ )); do

                if [[ $( type -t ${MODULES[i]}_need ) == function ]]; then

                        for needmod in $( ${MODULES[i]}_need ); do

                                missingdeps=true

                                for (( j=0; j<nmods; j++ )); do

                                        if [[ ${needmod} == ${MODULES[j]} || ${needmod} == ${PROVIDES[j]} ]]; then

                                                missingdeps=false

                                                break

                                        fi

                                done

                                if ${missingdeps} ; then

                                        eerror "${MODULES[i]} needs ${needmod} (dependency failure)"

                                        return 1

                                fi

                        done

                fi

                ${MODULES[i]}_check_depends || return 1

                [[ ${PROVIDES[i]} == interface ]] && interface=true

              if ${showprovides} ; then

                        [[ ${PROVIDES[i]} != ${MODULES[i]} ]] && veinfo "${MODULES[i]} provides ${PROVIDES[i]}"

                fi

        done

        if ! ${interface} ; then

                eerror "no interface module has been loaded"

                return 1

        fi

        return 0

}

# bool modules_load(char *iface, bool starting)

#

# Loads the defined handler and modules for the interface

# Returns 0 on success, otherwise 1

modules_load()  {

        local iface=${1} starting=${2:-true} mod p=false i j unsetfuncs

        local -a x

        local RC_INDENTATION=${RC_INDENTATION}  # so it will reset after function

        local -a PROVIDES

        if [[ ${iface} == lo ]]; then

                # We force lo to only use these modules for a major speed boost

                modules_force=( "iproute2" "ifconfig" )

        else

                eval x=( \"\$\{modules_force_${iface}\[@\]\}\" )

                [[ -n ${x} ]] && modules_force=( "${x[@]}" )

                if [[ -n ${modules_force} ]]; then

                        ewarn "WARNING: You are forcing modules!"

                        ewarn "Do not complain or file bugs if things start breaking"

                        report=true

                fi

                veinfo "Loading networking modules for ${iface}"

        fi

        eindent

        if [[ -z ${modules_force} ]]; then

                modules_load_auto || return 1

        else

                j=${#modules_force[@]}

                for (( i=0; i<j; i++ )); do

                        module_load_minimum "${MODULES_DIR}/${modules_force[i]}" || return 1

                        ${modules_force[i]}_check_installed || unset modules_force[i]

                done

                MODULES=( "${modules_force[@]}" )

        fi

        # We now buffer the _provides functions for a big speed boost

        j=${#MODULES[@]}

        for (( i=0; i<j; i++ )); do

                PROVIDES[i]=$( ${MODULES[i]}_provides )

        done

        if [[ -z ${modules_force[@]} ]]; then

                if ${starting}; then

                        modules_check_user || return 1

                fi

                # We unset unloaded module functions here as so we can error

                # with a message informing the user to emerge the correct

                # package if it's in their modules

                [[ -n ${unsetfuncs} ]] && unset ${unsetfuncs}

                modules_sort

        fi

        # Setup class wrappers: interface_up -> iproute2_up, for example

        j=${#MODULES[@]}

        for (( i=0; i<j; i++ )); do

                module_class_wrap ${MODULES[i]} ${PROVIDES[i]}

        done

        modules_check_installed || return 1

        [[ ${iface} != lo ]] && veinfo "modules: ${MODULES[@]}"

        eindent

        [[ ${iface} != lo && ${starting} == true ]] && p=true

        modules_check_depends ${p} || return 1

        return 0

}

# bool iface_start(char *interface)

#

# iface_start is called from start.  It's expected to start the base

# interface (for example "eth0"), aliases (for example "eth0:1") and to start

# VLAN interfaces (for example eth0.0, eth0.1).  VLAN setup is accomplished by

# calling itself recursively.

iface_start() {

        local iface=${1} mod config_counter=-1 x warn=false config_worked=false

        local RC_INDENTATION=${RC_INDENTATION}  # so it will reset after function

        local -a config fallback fallback_route conf

        local ifvar=$( interface_variable ${iface} )

        # pre Start any modules with

        for mod in ${MODULES[@]}; do

                if [[ $( type -t ${mod}_pre_start ) == function ]]; then

                        ${mod}_pre_start ${iface} || { eend 1; return 1; }

                fi

        done

        # New style config - one variable fits all

        eval config=( \"\$\{config_${ifvar}\[@\]\}\" )

        eval fallback=( \"\$\{fallback_${ifvar}\[@\]\}\" )

        eval fallback_route=( \"\$\{fallback_route_${ifvar}\[@\]\}\" )

        # We must support old configs

        if [[ -z ${config} ]]; then

                interface_get_old_config ${iface} || return 1

        fi

        # Handle "noop" correctly

        if [[ ${config[0]} == "noop" ]]; then

                if interface_is_up ${iface} true ; then

                        einfo "Keeping current configuration for ${iface}"

                        eend 0

                        return 0

                fi

                # Remove noop from the config var

                config=( "${config[@]:1}" )

        fi

        # Provide a default of DHCP if no configuration is set

        if [[ -z ${config} ]]; then

                if [[ $( type -t dhcp_start ) == function ]]; then

                        config=( "dhcp" )

                        warn=true

                else

                        eerror "Cannot default to dhcp as there is no dhcp module loaded"

                        eerror "No configuration for ${iface}"

                        return 1

                fi

        fi

        einfo "Bringing up ${iface}"

        eindent

        for (( config_counter=0; config_counter<${#config[@]}; config_counter++ )); do

                # Handle null and noop correctly

                if [[ ${config[config_counter]} == "null" \

                || ${config[config_counter]} == "noop" ]]; then

                        eend 0

                        config_worked=true

                        continue

                fi

                if ${warn}; then

                        ewarn "Configuration not set for ${iface} - assuming dhcp"

                        warn=false

                fi

                # We convert it to an array - this has the added

                # bonus of trimming spaces!

                conf=( ${config[config_counter]} )

                einfo "${conf[0]}"

                # Do we have a function for our config?

                if [[ $( type -t ${conf[0]}_start ) == function ]]; then

                        # Check that the module is valid

                        x=false

                        for mod in ${MODULES[@]}; do

                                if [[ $( ${mod}_provides ) == ${conf[0]} ]]; then

                                        x=true

                                        break

                                fi

                        done

                        if ! ${x}; then

                                [[ $( type -t ${conf[0]}_check_installed == function ) ]] && ${conf[0]}_check_installed tru

e

                                eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"

                        else

                                eindent

                                ${conf[0]}_start ${iface} ; x=$?

                                eoutdent

                                [[ ${x} == 0 ]] && config_worked=true && continue

                        fi

                # We need to test to see if it's an IP address or a function

                # We do this by testing if the 1st character is a digit

                elif [[ ${conf[0]:0:1} == [[:digit:]] || ${conf[0]} == *:* ]]; then

                        x=0

#                       if [[ $(type -t address_exists ) == function ]]; then

#                               if address_exists ${iface} ${conf[0]} ; then

#                                       eerror "${conf[0]%%/*} already taken on ${iface}"

#                                       x=1

#                               fi

#                       fi

                        [[ ${x} == 0 ]] && interface_add_address ${iface} ${conf[@]} ; x=$?

                        eend ${x} && config_worked=true && continue

                else

                        eerror "No loaded modules provide \"${conf[0]}\" (${conf[0]}_start)"

                fi

                if [[ -n ${fallback[config_counter]} ]]; then

                        einfo "Trying fallback configuration"

                        config[config_counter]=${fallback[config_counter]}

                        fallback[config_counter]=''

                        # Do we have a fallback route?

                        if [[ -n ${fallback_route[config_counter]} ]]; then

                                eval "routes_${ifvar}=( "\"\$\{fallback_route\[${config_counter}\]\[@\]\}\"" )"

                                fallback_route[config_counter]='

                        fi

                        (( config_counter-- )) # since the loop will increment it

                        continue

                fi

        done

        eoutdent

        # We return failure if no configuration parameters worked

        ${config_worked} || return 1

        # Start any modules with _post_start

        for mod in ${MODULES[@]}; do

                if [[ function == $( type -t ${mod}_post_start ) ]]; then

                        ${mod}_post_start ${iface} || return 1

                fi

        done

        return 0

}

# bool iface_stop(char *interface)

#

# iface_stop: bring down an interface.  Don't trust information in

# /etc/conf.d/net since the configuration might have changed since

# iface_start ran.  Instead query for current configuration and bring

# down the interface.

#

# However, we are currently reliant on handler and modules specified

# in /etc/conf.d/net

iface_stop() {

        local iface=${1} i aliases need_begin=false mod

        local RC_INDENTATION=${RC_INDENTATION}  # so it will reset after function

        # pre Stop any modules

        for mod in ${MODULES[@]}; do

                [[ $( type -t ${mod}_pre_stop ) == function ]] && ${mod}_pre_stop ${iface}

        done

        einfo "Bringing down ${iface}"

        eindent

        # Collect list of aliases for this interface.

        # List will be in reverse order.

        aliases=$( interface_get_aliases_rev ${iface} )

        # Stop aliases before primary interface.

        # Note this must be done in reverse order, since ifconfig eth0:1 

        # will remove eth0:2, etc.  It might be sufficient to simply remove 

        # the base interface but we're being safe here.

        for i in ${aliases} ${iface}; do

                # Stop all our modules

                for mod in ${MODULES[@]}; do

                        [[ $( type -t ${mod}_stop ) == function ]] && ${mod}_stop ${i}

                done

                # A module may have removed the interface

                interface_exists ${iface} || { eend 0; continue; }

                # Delete all the addresses for this alias

                interface_del_addresses ${i}

                # Do final shut down of this alias

                ebegin "Shutting down ${i}"

                interface_iface_stop ${i}

                eend $?

        done

        # post Stop any modules

        for mod in ${MODULES[@]}; do

                # We have already taken down the interface, so no need to error

                [[ $( type -t ${mod}_post_stop ) == function ]] && ${mod}_post_stop ${iface}

        done

        return 0

}

# bool run_start(char *iface)

#

# Brings up ${IFACE}.  Calls preup, iface_start, then postup.

# Returns 0 (success) unless preup or iface_start returns 1 (failure).

# Ignores the return value from postup

# We cannot check that the device exists ourselves as modules like

# tuntap make create it.

run_start() {

        local iface=${1} ifvar x

        if [[ ${iface} == lo ]]; then

                ebegin "Bringing up ${iface}"

                interface_loopback_create

                eend $?

                return $?

        fi

        # We may not have a loaded module for ${iface}

        # Some users may have "alias natsemi eth0" in /etc/modules.d/foo

        # so we can work with this

        # However, if they do the same with eth1 and try to start it

        # but eth0 has not been loaded then the module gets loaded as

        # eth0.

        # Not much we can do about this  :Sad: 

        # Also, we cannot error here as some modules - such as bridge

        # create interfaces

        if ! interface_exists ${iface} ; then

                /sbin/modprobe ${iface} &>/dev/null

        fi

        # Setup variables for pre/post to use

        ifvar=$( interface_variable ${iface} )

        local IFACE=${iface} IFVAR=${ifvar}

        # Call user-defined preup function if it exists

        if [[ $( type -t preup ) == function ]]; then

                einfo "Running preup function"

                eindent

                preup ${iface} ; x=$?

                eoutdent

                if [[ ${x} != 0 ]]; then

                        eerror "preup ${iface} failed"

                        return 1

                fi

        fi

   # Don't let preup modify us

        iface=${1}

        local IFACE=${iface} IFVAR=${ifvar} config

        # If config is set to noop and the interface is up with an address

        # then we don't start it

        eval config=( \"\$\{config_${ifvar}\[@\]\}\" )

        if [[ ${config[0]} == "noop" ]] && interface_is_up ${iface} true ; then

                einfo "Keeping current configuration for ${iface}"

                eend 0

        else

                # Remove noop from the config var

                [[ ${config[0]} == "noop" ]] && eval "config_${ifvar}=( "\"\$\{config\[@\]:1\}\"" )"

                # There may be existing ip address info - so we strip it

                interface_del_addresses ${iface}

                # Start the interface

                if ! iface_start ${iface} ; then

                        interface_exists ${iface} && interface_down ${iface}

                        eend 1

                        return 1

                fi

        fi

        # Call user-defined postup function if it exists

        if [[ $( type -t postup ) == function ]]; then

                einfo "Running postup function"

                eindent

                postup ${iface}

                eoutdent

        fi

        return 0

}

# bool run_stop(char *iface) {

#

# Brings down ${iface}.  If predown call returns non-zero, then

# stop returns non-zero to indicate failure bringing down device.

# In all other cases stop returns 0 to indicate success.

run_stop() {

        local iface=${1} ifvar x

        # Don't run any special shutdown functions for lo

        if [[ ${iface} == lo ]]; then

                ebegin "Shutting down ${iface}"

                interface_iface_stop ${iface}

                eend $?

                return 0

        fi

        # Setup variables for pre/post to use

        ifvar=$( interface_variable ${iface} )

        local IFACE=${iface} IFVAR=${ifvar}

        # Call user-defined predown function if it exists

        if [[ $( type -t predown ) == function ]]; then

                einfo "Running predown function"

                eindent

                predown ${iface} ; x=$?

                eoutdent

                if [[ ${x} != 0 ]]; then

                        eend 1 "predown ${iface} failed"

                        return 1

                fi

        elif is_net_fs /; then

                eerror "root filesystem is network mounted -- can't stop ${iface}"

                return 1

        fi

        # Don't let predown modify us

        iface=${1}

        local IFACE=${iface} IFVAR=${ifvar}

        iface_stop ${iface} || return 1  # always succeeds, btw

        # Call user-defined postdown function if it exists

        if [[ $( type -t postdown ) == function ]]; then

                einfo "Running postdown function"

                eindent

                postdown ${iface}

                eoutdent

        fi

        return 0

}

# bool run(char *iface, char *cmd)

#

# Main start/stop entry point

# We load modules here and remove any functions that they

# added as we may be called inside the same shell scope for another interface

run() {

        local iface=${1} cmd=${2} r=1 RC_INDENTATION=${RC_INDENTATION}  # so it will reset after function

        local before starting=true

        local -a MODULES mods

        # We need to override the exit function as runscript.sh now checks

        # for it. We need it so we can mark the service as inactive ourselves.

        unset -f exit

        eindent

        unset_functions=${unset_functions:-false}

        ${unset_functions} && before="$( typeset -F )"

        [[ ${cmd} == "stop" ]] && starting=false

        if modules_load ${iface} ${starting} ; then

                if [[ ${cmd} == "stop" ]]; then

                        # Reverse the module list for stopping

                        mods=( "${MODULES[@]}" )

                        for ((i = 0; i < ${#mods[@]}; i++)); do

                                MODULES[i]=${mods[((${#mods[@]} - i - 1))]}

                        done

                        run_stop ${iface} && r=0

                else

                        run_start ${iface} && r=0

                fi

        fi

        # We need to remove added functions before we quit as other init

        # scripts may be launching afterwards

        # scripts may be launching afterwards

        ${unset_functions} && \

        unset $( diff -U0 <( echo "${before}" ) <( echo "$( typeset -F )" ) 2>/dev/null \

                | awk 'BEGIN { ORS = " "; } /+declare -f/ { print $3; }' ) 2>/dev/null

        return ${r}

}

# bool start(void)

#

# Start entry point so that we only have one function

# which localises variables and unsets functions

start() {

        einfo "Starting ${IFACE}"

        run ${IFACE} start

        return $?

}

# bool stop(void)

#

# Stop entry point so that we only have one function

# which localises variables and unsets functions

stop() {

        einfo "Stopping ${IFACE}"

        run ${IFACE} stop

        return $?

}

# bool restart(void)

#

# Restart entry point

# We do this so as we only have to remove functions when stopping

restart() {

        local unset_functions=true

        service_started "${myservice}" && svc_stop

        unset_functions=false

        svc_start

        return $?

}

# vim:ts=4

Je suppose que j'ai besoin d'un net.eth1... :Sad: 

----------

## boozo

ben c'est a toi de voir  :Shocked:  c'est toi qui as mis eth1 et pas eth0 dans ta config 

 *kangal wrote:*   

> root:/home/kangal >> cat /etc/conf.d/net
> 
> # /etc/conf.d/net:
> 
> # $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/conf.d/net,v 1.7 2002/11/18 19:39:22 azarah Exp $
> ...

 

alors j'en ai déduit que que tu devais vouloir plusieurs interfaces non ?

----------

## kangal

non pas du tout...Depuis le debut ma carte ethernet est eth1, sans trop de raison d'ailleur....

----------

## boozo

ben alors mets tout en eth0 partout (config, net.ethX et les liens qui pointes sur les bons fichiers) pour eviter les incohérences et les pbs  :Wink:  après tu testes et tu dis...

----------

## kangal

Ca me fais un peu peur... Il doit y avoir une raison au fait que mon ethernet soit en eth1...Je crois que mon firewire a pris automatiquement le eth0...

Tu voudrais que je modifi tout les script pour tout mettre en eth0??? Moi je veux bien mais c'est evident que je vais tout crasher:) 

Ca m'enerve, j'ai juste ce petit probleme...

----------

## boozo

ok ben tu fais tout pareil pour eth1 alors  :Wink:  comme çà tu ne touche a rien... tu dupliques ton net.ethx tu gardes ta config avec eth1 et tu fais tes liens en fonction le tout c'est d'avoir une cohérence globale  :Wink: 

[Edit]bon en résumé : 

```
un lien /etc/init.d/net.eth1 -> net.lo

et duplicate de /etc/conf.d/net -> net.dhcp et enfin le lien net.eth1 -> net.dhcp
```

----------

## kangal

ben je vasi voir alors... Et par contre  tu ne sais pas d'ou ca peut venir le : failed to set userfont et le bootmisc does not have start option??

Edit : 

un lien /etc/init.d/net.eth1 -> net.lo    : Alors je l'ai fait, mais le truc c'est que j'avai pas de net.eth1, j'ai donc renommer le eth0 en eth1

et duplicate de /etc/conf.d/net -> net.dhcp et enfin le lien net.eth1 -> net.dhcp   : Alors j'ai copier net en net.dhcp, par contre le lien:

root:/etc/conf.d >> ln /etc/init.d/net.eht1 net.dhcp 

ln: `net.dhcp': File exists

Je me gourre??

RE edit: Alors c'est incroyable, j'ai fais ce que tu m'as dit (enfin pas tout vu que un truc marchais pas)...J'ai redemarrer juste pour voir, et la, plus de message d'erreur, j'ai meme sshd qui se lance. Mais quand je fais un iconfig, je n'ai que lo, et pas de connection, si je veux faire un dhcpcd eth1, il me dit encore

****  dhcpcd: already running

****  dhcpcd: if not then delete /var/run/dhcpcd-eth1.pid file

et c'est seulement apres l'avoir effacer et refais un dhcpcd eth1 que ca marche, mais je comprend pas comment sshd peux se lancer et pourquoi ca semble marcher au boot8O

----------

