/usr/sbin/bootmanager improvements

Under development: PCMCIA, wireless, etc.
Post Reply
Message
Author
User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

/usr/sbin/bootmanager improvements

#1 Post by Karl Godt »

Here i'll place my adjustments to bootmanager !

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
using basename i had for the loop_1 times :
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: :D

: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]

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

make bootmanager yeslist_func load the module(s)

#2 Post by Karl Godt »

Code: Select all

 #now also load the module
 for module in $ADDLIST
 do
 echo "'$module' '${module%%:*}' '${module#*:}'" >&2
 params="${module#*:}"
 params="${params//:/ }"
 echo $params >&2
 [ "$params" = "${module%%:*}" ] && params='';
 modprobe -v --first-time ${module%%:*} $params
 done
 dmesg | tail -n 10 >&2
 
} #end yeslist_func
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#3 Post by amigo »

Just a tip, 'modprobe -l' is not forward-compatible with modern kmod-based tools.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#4 Post by Karl Godt »

Yep, noticed this in current Slacko.
Hate many of the new *exciting* updates and upgrades .
Think or hope, they might implement it one day .
My experiments with altering the source code of the "old" modprobe.c file showed that
though all short and long options were already implemented since version 3.3.x ,
it needed version 3.12 that getopt would have parsed them all (correctly) .
Cannot believe that it took so long to fix this .
Even the Debian and Ubuntu patches never tried to fix this .
And modprobe is one of the most important Linux tools !!

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#5 Post by Karl Godt »

Ah, and before I forget : /bin/busybox modprobe supports the -l option , at least since version 1.17.4 .
But I configure busybox not with simplified modutils .
«Give me GUI or Death» -- I give you [[Xx]term[inal]] [[Cc]on[s][ole]] .
Macpup user since 2010 on full installations.
People who want problems with Puppy boot frugal :P

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#6 Post by Karl Godt »

About one of the ugly sides :

GTK and gtkdialog have some problems when starting other GUIs from their interfaces . These new GUIs block the sight on the first GUI and moving the new GUI with the mouse often rubs out the text in the GUI underneath .
If the new GUI does not need to update anything inside the first GUI, then it could be started as forked program :

Code: Select all

    <text><label>`gettext \"Click here to 'blacklist' a module:\"`</label></text>
     <button>
      <input file>/usr/local/lib/X11/pixmaps/module24.xpm</input>
-     <action>bootmanager blacklist</action>
+     <action>bootmanager blacklist &</action>
     </button>
   </hbox>
   <hbox>
    <text><label>$(gettext 'Click here to add a new module:')</label></text>
     <button>
      <input file>/usr/local/lib/X11/pixmaps/module24.xpm</input>
-     <action>bootmanager yeslist</action>
+     <action>bootmanager yeslist &</action>
     </button>
   </hbox>
   <hbox>
    <text><label>$(gettext 'Give preference to one module over another:')</label></text>
     <button>
      <input file>/usr/local/lib/X11/pixmaps/module24.xpm</input>
-     <action>bootmanager preflist</action>
+     <action>bootmanager preflist &</action>
     </button>
   </hbox>
  </frame>
@@ -577,11 +577,11 @@ export MAIN_DIALOG="
    <text><label>$(gettext 'Choose which system services to run at startup:')</label></text>
     <button>
      <input file>/usr/local/lib/X11/mini-icons/so.xpm</input>
-     <action>bootmanager sysdaemons</action>
+     <action>bootmanager sysdaemons &</action>
     </button>
   </hbox>
  </frame>
Attachments
shot-2013-08-21_15-32-47.jpg
(45.58 KiB) Downloaded 289 times

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#7 Post by amigo »

Actually, I think that behavior comes from rox or the WM.

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#8 Post by Karl Godt »

This behavior is present at any Windowmanager I used .
The above was e17 which does not use ROX-Filer pinboard , just as filemanager , and this below is openbox with rox pinboard .
Attachments
bootmanager_openbox_wm.jpg
(30.08 KiB) Downloaded 233 times

User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#9 Post by Keef »

This always happens with Puppy Package Manager (although I don't use it very often). Nice to know there is a specific reason.

Bootmanager just as bad, but hadn't noticed it before.

Post Reply