Statut des scripts de demarrage

Résolu/Fermé
debianhunter - 22 déc. 2009 à 21:46
debianhunter Messages postés 119 Date d'inscription mardi 22 décembre 2009 Statut Membre Dernière intervention 11 juillet 2010 - 4 janv. 2010 à 20:48
Bonjour,

Ancien utilisateur de RedHat, j'ai la nostalgie du statut des script de demarrage (les fameux [OK] et [FAILED] entre crochets).

Shutting down interface eth0: Device eth0 has different MAC address than expected, ignoring. [FAILED]
Shutting down loopback interface: [ OK ]
Setting network parameters: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]

Aujourd'hui sous ma debian, les scripts networking et autres sont silencieux (pas de statut).
Savez-vous si cela est configurable ? Si oui, comment procede-t-on ?

Merci,

Nicolas
A voir également:

1 réponse

debianhunter Messages postés 119 Date d'inscription mardi 22 décembre 2009 Statut Membre Dernière intervention 11 juillet 2010 24
4 janv. 2010 à 20:48
Bonsoir,

Desole de me repondre a moi-meme ; mais ayant trouve la solution, je la partage au cas ou ca interesserait quelqu'un.

Ayant trouve une station RedHat au boulot, j'ai pu voir comment etait fait les scripts de demarrage: sous RedHat, on utilise la fonction success ou fail qui est definie dans /etc/init.d/functions.

Sous Debian, on peut faire quelque chose de similaire (avoir un joli [OK] ou [FAILED], voire meme [WARNING] de couleur, alignes sur une colonne) en editant le fichier:
/lib/lsb/init-functions
et en modifiant la fonction suivante (commenter ce qui est entoure par #commented et #endcommented et ajouter ce qui est entre #added:... et #endadded):

# int log_end_message (int exitstatus)
log_end_msg () {
    # If no arguments were passed, return
    if [ -z "${1:-}" ]; then
        return 1
    fi

    retval=$1

    log_end_msg_pre "$@"

    # Only do the fancy stuff if we have an appropriate terminal
    # and if /usr is already mounted
    if log_use_fancy_output; then
        RED=`$TPUT setaf 1`
        #added: support of green in case of support of log_use_fancy_output
        GREEN=`$TPUT setaf 2`
        #endadded
        YELLOW=`$TPUT setaf 3`
        NORMAL=`$TPUT op`
    else
        RED=''
        #added: support of green in case of non-support of log_use_fancy_output
        GREEN=''
        #endadded
        YELLOW=''
        NORMAL=''
    fi

    #added: goto column 60 and prints a [
    /bin/echo -ne "\\033[60G"
    /bin/echo -n "["
    #endadded
    if [ $1 -eq 0 ]; then
        #commented
        #echo "."
        #endcommented
        #added: prints OK in green color
        /bin/echo -ne "${GREEN}OK"
        #endadded
    elif [ $1 -eq 255 ]; then
        #commented
        #/bin/echo -e " ${YELLOW}(warning).${NORMAL}"
        #endcommented
        #added: prints WARNING in yellow color
        /bin/echo -ne "${YELLOW}WARNING"
        #endadded
    else
        #commented
        #/bin/echo -e " ${RED}failed!${NORMAL}"
        #endcommented
        #added: prints FAILED in red color
        /bin/echo -ne "${RED}FAILED"
        #endadded
    fi
    #added: restore normal color, prints ] and newline
    /bin/echo -e "${NORMAL}]"
    #endadded
    log_end_msg_post "$@"
    return $retval
}

En esperant que ca pourra aider qqu'un :o)

Cordialement,

Nicolas
0