[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[debian-knoppix] [PATCH] Knoppix-Terminalserver with descriptions to cards



Hi,

attached patch displays the cards of the knoppix-terminalserver instead of 
"Kernel-Module".

I don't think you'll find a faster patch.

Anyway it is not that easy to understand so I'll explain it here:

I use the following format to allow whitespaces:

3c59x.o|"3Com 3c59x/3c9xx ethernet driver LK1.1.16 19 July 2001"|on

I then do:

IFS='|' which tells the bash to use | as field separator for lists.

$DIALOG ... $CARDLIST

unset IFS, which unsets IFS again. Thats just some trick, which is useful. If 
you know a better way tell me.

Because it takes much time to exec modinfo each time it is feeded all cards at 
once and because lookup also takes time it is feeded the whole path-names.

modinfo -d $(find /lib/modules/*/kernel/drivers/net -name \*.o)

Now we need that all descriptions are on one line. (There is one "bad module", 
which has a "\n" at the end of the description)

As each module has either "description" or <none> we can substitute "$ ($=end 
of line) and >$ with \n.

Then we echo -e the whole, that all linefeeds are removed and all \n's are 
substituted to linefeeds.

Now we have each description on one line and we can make two columsn out of it 
by pasting.

In $TMP we have all basenames of the modules

paste $TMP -, will give:

3c59x.o	"<description>"

that is sorted.

<none> is substituted with 'Kernel-Module' and the whole lot is reformatted to 
'|' as fieldseparator with awk. Also if it matches PXE-capable cards, on is 
writen, then off is writen for all cards.

This would give "on\noff" for the cards with PXE, so a last grep is done to 
find those lines without just "off".

If anyone knows how to make an if out of that pattern select or do an else 
with that pattern it could be more simplicated.

I read the manual, but did not find this.

On my machine it's almost as fast as it was before with the bash loop and I 
think to have the module-descriptions could be helpful to some.

cu

Fabian
--- /usr/sbin/knoppix-terminalserver	2002-12-10 22:07:35.000000000 +0100
+++ knoppix-terminalserver	2003-04-13 16:52:33.000000000 +0200
@@ -533,15 +533,13 @@
 echo "IPRANGE_FROM=\"$IPRANGE_FROM\"" >>"$CONFIG"
 echo "IPRANGE_TO=\"$IPRANGE_TO\"" >>"$CONFIG"
 
-CARDLIST=""
-for i in $(find /lib/modules/*/kernel/drivers/net -name \*.o | awk -F/ '{print $NF}' | sort); do
-ON="off"
-case "${i}" in 3c59x*|tulip*|eepro100*|sis900*) ON="on";; esac
-CARDLIST="$CARDLIST ${i} Kernel-Module ${ON}"
-done
+find /lib/modules/*/kernel/drivers/net -name \*.o | awk -F/ '{print $NF}' > $TMP
+CARDLIST=$(echo -e $(modinfo -d $(find /lib/modules/*/kernel/drivers/net -name \*.o) | sed 's/"$/"\\n/g; s/>$/>\\n/g') | paste $TMP - | sort | sed 's/<none>/Kernel-Module/g;' | awk -F"\t" '{printf("%s|%s|",$1,$2)}; /^3c59x|^tulip|^eepro100|^sis900/{ print "on|" }; { print "off|" }' | grep "\.o")
 rm -f "$TMP"
+IFS='|'
 $DIALOG --clear --backtitle "$BACKTITLE" --title "$TITLE_CARDS" --checklist "$MESSAGE_CARDS" 22 70 15 \
 $CARDLIST 2>"$TMP" || bailout 2
+unset IFS
 MODULES="$(sed 's,",,g;s,/, ,g' <$TMP)"
 echo "MODULES=\"$MODULES\"" >>"$CONFIG"
 

Reply to: