You are not logged in.

#1 2007-04-23 05:24:51

Moo-Crumpus
Member
From: Hessen / Germany
Registered: 2003-12-01
Posts: 1,488

Daemon to query for module, compile new if necessary [kind of solved]

An older version of the nvidia package included a daemon, that checked if the module was loaded. If not, it was compiled.
I would like to do the same for a raid adaptors module - as the raid adaptor services /home only, that'll be fine. But I have no idea how exactly to do that. Any advice is welcome.

Last edited by Moo-Crumpus (2007-05-26 03:09:36)


Frumpus addict
[mu'.krum.pus], [frum.pus]

Offline

#2 2007-05-25 21:30:27

Moo-Crumpus
Member
From: Hessen / Germany
Registered: 2003-12-01
Posts: 1,488

Re: Daemon to query for module, compile new if necessary [kind of solved]

It took some time to find the time to take the time to think about it and finally it is like this:

f.e. compile raid module if not loaded and load it (after kernel updates etc)

#!/bin/bash
# X-Trace, Verbose aktivieren
set -xv

MODULNAME='rr174x'
MODULSOURCE='/usr/src/rr174x/product/rr174x/linux/'

# Geladene Module auflisten, und nach dem Raid-Modul rr174x suchen
#    Rückgabewert 0 = True
#    Rückgabewert 1 = False

# Wenn das Raid-Modul nicht in der Liste der geladenen Module gefunden wurde
if [ ! `lsmod | grep $MODULNAME` ]; then
        # Rückmeldung ausgeben
        echo Raid-Modul $MODULNAME nicht geladen

        # Nachsehen, ob das Kernel-Modul überhaupt exisitiert - z.B. kann ein Kernel-Update es vernichtet haben.
        # ! -e <Dateiname>
        # entspricht
        # Rückgabewert für 'test -e <filename>' ist False
        # Siehe 'man test'
        if [ ! -e "/lib/modules/`uname -r`/kernel/drivers/scsi/$MODULNAME.ko" ]; then

            # Rückmeldung ausgeben
            echo Modul $MODULNAME nicht vorhanden

            # In den Sourcecode springen, Modul kompilieren, installieren, laden
            cd $MODULSOURCE
            make > /dev/null
            make install > /dev/null
            modprobe $MODULNAME > /dev/null
        else
            # Versuchen, das Modul zu laden
            modprobe $MODULNAME > /dev/null
        fi       
else
    # Wenn das Raid-Modul in der Liste der geladenen Module gefunden wurde
        echo Raid-Modul $MODULNAME geladen
fi

Thank you very much. A little step for the community, a big one for me. smile

Last edited by Moo-Crumpus (2007-05-26 09:19:49)


Frumpus addict
[mu'.krum.pus], [frum.pus]

Offline

Board footer

Powered by FluxBB