Today i decided 50 to 80 seconds had been too long on dual core 2,6GHz to build the addlist/yeslist database for the kernel modules .
Here's my yeslist function untidy, renamed to addlist() :
Code: Select all
addlist_func() {
#choose extra modules to load at bootup.
TTY=`tty`
TMP_DIR=/tmp/bootmanager;mkdir -p $TMP_DIR
echo "Create db :`date`" 1>>$TTY
#ALLMODULES="`cat /lib/modules/$KERNVER/modules.dep | cut -f 1 -d ':' | grep -o '[a-zA-Z0-9_-]*\.ko' | tr '\-' '_' | sort -u`"
ALLMODULES=`modprobe -l |rev|cut -f 1 -d '/'|rev |sed 's|\.ko$||;s|\.ko\..*$||;s|-|_|g'|sort`
echo "$ALLMODULES" > $TMP_DIR/ALLMODULES.lst
HOW_MANY=`echo "$ALLMODULES" |wc -l`
yaf-splash -font "8x16" -outline 0 -margin 4 -bg orange -text "Please wait, processing $HOW_MANY modules ..." &
X1PID=$!
. /etc/rc.d/MODULESCONFIG
MODLIST=""
#note, lsmod will show all modules with '-' as '_'...
#LOADEDMODULES=" `lsmod | grep -v '^Module' | cut -f 1 -d ' ' | tr '\n' ' '`"
LOADEDMODULES="`lsmod | grep -v '^Module' | cut -f 1 -d ' ' |sort`"
echo "$LOADEDMODULES" > $TMP_DIR/LOADEDMODULES.lst
grep -v -w -f $TMP_DIR/LOADEDMODULES.lst $TMP_DIR/ALLMODULES.lst > $TMP_DIR/FILTERED_MODULES.1.lst
echo "$ADDLIST" |tr ' ' '\n ' |sed '/^$/d;s|\:.*||' |sort > $TMP_DIR/ADDLIST.lst
grep -v -w -f $TMP_DIR/ADDLIST.lst $TMP_DIR/FILTERED_MODULES.1.lst > $TMP_DIR/FILTERED_MODULES.2.lst
loop_1(){ #creates "off" list
echo "First loop :`date`" 1>>$TTY
for ONEMOD in $ALLMODULES
do
#NAMEONLY="`basename $ONEMOD .ko`"
#NAMEONLY=${ONEMOD##*/};
#NAMEONLY=${NAMEONLY//\.ko*/}
#NAMEONLY=${ONEMOD//\.ko*/}
NAMEONLY="$ONEMOD"
MODPATTERN=" $NAMEONLY "
#leave off list if already loaded...
[ "`echo "$LOADEDMODULES" | grep "$MODPATTERN"`" ] && continue
MODPATTERN=' '"$NAMEONLY"'[ :]'
#leave off left pane if already on right pane...
[ "`echo "$ADDLIST" | grep "$MODPATTERN"`" ] && continue
MODLIST="$MODLIST $NAMEONLY $NAMEONLY off"
done
echo "First loop :`date`" 1>>$TTY
}
cat $TMP_DIR/FILTERED_MODULES.2.lst | sed 's|\(.*\)|\1 \1 off|' > $TMP_DIR/OFFLIST.lst
cat $TMP_DIR/ADDLIST.lst | sed 's|\(.*\)|\1 \1 on|' > $TMP_DIR/ONLIST.lst
loop_2(){ ##creates "on" list
echo "Second loop :`date`" 1>>$TTY
#check for parameters
for ONEMOD in $ADDLIST
do
NAMEONLY="$ONEMOD"
xONEMOD="$ONEMOD"
if [ `echo -n "$ONEMOD" | tr ':' ' ' | wc -w` -gt 1 ];then
MPARAMS="`echo -n "$ONEMOD" | cut -f 2-9 -d ':' | tr ':' ' '`"
NAMEONLY="`echo -n "$ONEMOD" | cut -f 1 -d ':'`"
xONEMOD="$NAMEONLY $MPARAMS"
fi
MODPATTERN=" $NAMEOLY "
#leave off list if already loaded...
[ "`echo "$LOADEDMODULES" | grep "$MODPATTERN"`" != "" ] && continue
MODLIST="$MODLIST $ONEMOD \"$xONEMOD\" on"
done
echo "Second loop :`date`" 1>>$TTY
}
MODLIST="`cat $TMP_DIR/ONLIST.lst |tr '\n' ' '` `cat $TMP_DIR/OFFLIST.lst |tr '\n' ' '`"
kill $X1PID
echo "Create db :`date`" 1>>$TTY
echo "Xdialog: `date`" 1>>$TTY
#gui
EXECME="Xdialog --wmclass \"module16\" --title \"BootManager: Module add-list manager\" --left --stdout --separator \" \" --buildlist \"On the left pane is the complete list of modules available to be\nused by Puppy (and not currently loaded).\nOn the right pane are modules that you have explicitly chosen to\nbe loaded at bootup (not auto-loaded by default).\nIf you want to force a module to load, move it to the right pane,\nclick OK button, then reboot Puppy.\nNote, if you want to find out further information about any module,\nrun PupScan (look in the System menu)\" 0 0 8 $MODLIST >$TMP_DIR/yesrettags.txt"
eval $EXECME
RETVAL=$?
echo "Xdialog: `date`" 1>>$TTY
[ $RETVAL -eq 0 ] || return 1
cat $TMP_DIR/yesrettags.txt | tr ' ' '\n' | tr ':' ' ' > $TMP_DIR/modules_addlist_edit #v411
Xdialog --backtitle "If you wish, add any required parameters to these modules\nExample: mmc_block major=179\nIf you don't know what this means, just click 'OK' button" --wmclass "module16" --title "BootManager: Edit module addlist" --left --stdout --no-cancel --editbox $TMP_DIR/modules_addlist_edit 0 0 > $TMP_DIR/modules_addlist_edit_out
[ $? -ne 0 ] && return 1
ADDLIST="`cat $TMP_DIR/modules_addlist_edit_out`"
ADDLIST=' '"`echo "$ADDLIST" | tr ' ' ':' | tr '\n' ' ' | tr -s ' '`"
#ADDLIST=" `cat /tmp/yesrettags.txt | tr '\n' ' '`"
#now update /etc/rc.d/MODULESCONFIG...
grep -v '^ADDLIST' /etc/rc.d/MODULESCONFIG > /tmp/MODULESCONFIG
mv -f /tmp/MODULESCONFIG /etc/rc.d/MODULESCONFIG
echo "ADDLIST='${ADDLIST}'" >> /etc/rc.d/MODULESCONFIG
} #end addlist_func
First loop :Fr 15. Jun 23:08:59 GMT+1 2012
First loop :Fr 15. Jun 23:10:12 GMT+1 2012
1min 13 sec .
using shell substitution for loop_1
First loop :Fr 15. Jun 23:27:25 GMT+1 2012
First loop :Fr 15. Jun 23:28:20 GMT+1 2012
55 sec .
using ^heavy^ grep and sed :
Create db :Sa 16. Jun 00:14:08 GMT+1 2012
Create db :Sa 16. Jun 00:14:09 GMT+1 2012
1 sec.
:SHOCK:
:NOTE: it is 4.3.1 bootmanager in this post !
[update 2012-06-20]
added two times -w option to grep
grep -v -f $TMP_DIR/*.lst would accidentally filter all acpi modules for exemple if 'ac' module is currently loaded
[/update 2012-06-20]