HOWTO Customize your Boot Image

How to do things, solutions, recipes, tutorials
Message
Author
User avatar
steve_s
Posts: 1595
Joined: Mon 26 May 2008, 13:29
Location: Austin, TX, USA
Contact:

Mofiications for Lupu 5.2.8

#21 Post by steve_s »

Well, it does seem that Puppy Linux 5.2.8, aka Lupu 5.2.8 is missing some of the stuff we need to do this.

So here is how we fix that.

First, install the pet file that I’ve attached to this post. It will install gif2lss, ppmtolss16 and lss16toppm to /usr/bin for you.

Next, follow all the instructions in the first post through #3.

Then proceed:

4. Modify the ppm image. Gimp can easily open up ppm images.

Code: Select all

cd /ISO/
gimp logo16.ppm
Now, do what you want to with gimp. Let's say you want to add some text. Click on the Text button in the tools menu (looks like a big "A") and put some text on the image.

All kinds of things you can do with gimp; search this forum and the internet. Gimp is my favorite graphics tool (in case you've never seen any of my other posts).

But whatever you do, remember the limitations: it has to be 640x480 (probably better at 640x388) and it has to be 16 colors.

Change the color index in Gimp: Image>Mode>Indexed and change the colors from 256 to 16 and click Convert.

Change the size in Gimp: Image>Scale Image and change it to the necessary size (you'll notice that the one that comes with Puppy 5.2.8 is 640x388, so it might be wise to have your new one the same size).

When you are all finished save it as a gif file.

5. Now let's do some reorganizing:

Code: Select all

mv logo.16 logo-old.16
And then convert the new gif image to the old format and name:

Code: Select all

gif2lss logo16.gif > logo.16
Now you have your new image ready to go. You can either move or delete the original logo.16 (now named logo-old.16) if you don't want it in the new iso image.

6. Create your new, now truly custom, iso file.

Code: Select all

cd / 
mkisofs -o newcustomiso.iso -l -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ISO/
Notice: that mkisofs command is one line, all the way to the end of ISO/.

Now you have your new iso (called newcustomiso.iso) in your / folder.

Enjoy!
**Note: I have used the attached tools in Lupu5.2.8 to modify and save the splash image. I have NOT yet gone through the whole process (essentially step #6) using 5.2.8 as I had with 4.2.1. So, please, feel free to try it for us and confirm whether or not it works.**
Attachments
lostsplashtools.pet
Tools to take the place of the ones lost in Lupu 5.2.8
(11.6 KiB) Downloaded 542 times

User avatar
RSH
Posts: 2397
Joined: Mon 05 Sep 2011, 14:21
Location: Germany

#22 Post by RSH »

Hello,

i have "fixed" the .pet because i think the file inside the pet should be named "ppmtoolss16". The name of the file inside the pet is "ppmtolss16". I have just created a link to it. Do not know if this is an original "fault" so it is compatible in this way.

RSH
Attachments
lostsplashtools.pet
(11.54 KiB) Downloaded 501 times
[b][url=http://lazy-puppy.weebly.com]LazY Puppy[/url][/b]
[b][url=http://rshs-dna.weebly.com]RSH's DNA[/url][/b]
[url=http://murga-linux.com/puppy/viewtopic.php?t=91422][b]SARA B.[/b][/url]

User avatar
steve_s
Posts: 1595
Joined: Mon 26 May 2008, 13:29
Location: Austin, TX, USA
Contact:

#23 Post by steve_s »

No, the name is ppmtolss16, but if it works better for anyone with that fix then thank you for that.:-)

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

Mofiications for Lupu 5.2.8

#24 Post by oldyeller »

Hi Steve S,

Sorry it took so long for me to get back on here, have already download the pet and will give it a try. As soon as I get me a new comp. Using my wife's and she loves windows. HA HA

Thanks well let you know in a couple of weeks.

User avatar
oldyeller
Posts: 889
Joined: Tue 15 Nov 2011, 14:26
Location: Alaska

#25 Post by oldyeller »

Hi Steve

The pet that you made did not work so I tried the one that RSH and it woked just fine. Thanks to you both for your help

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#26 Post by espertalhao04 »

hey guys
sorry for being "late" but i have found that if you open logo.16 with mtpaint, you can edit it (keep it at a size that is something like 640x <480, to give space for the output messages)...
there's no need to do all those things...
and you can even place another image, if you edit the first line of file boot.msg, and replace boot.16 for the name of the image (open with geany!!!)...
you can also translate boot.msg and help.msg (both with geany!!!!) for any language (that can have chars written in a console <-- need confirmation about charsets)...
you can even change the text colors!!!
just need to practice...
as soon as i can get something, i'll show you some results...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#27 Post by espertalhao04 »

to convert to lss16, just save as lss16 using mtpaint...
use also mtpaint to index it to 16...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#28 Post by espertalhao04 »

hey guys...
i've been successful in changing my boot splash!!!
this is what i've done:
1-http://bestfreewallpapers.net/mediagall ... 8163333326
2-download the image and save it (this is the one i've used)
3-open it with mtpaint:
a-go to "image" and choose "scale canvas"
a1-on new you choose 640 and you can put a value lower or equal to 480 (recommended: 388)
a2-you might need to unselect the option "fiz aspect ratio"
b-go to "image" and click on "convert to indexed"
b1-on "indexed color to use", you put 16
b2-on "palette", choose "pnn quantitize"
b3-on "dither", choose "dithered"
b4-click on the button "settings"
b5-on "colour space", choose "rgb"
c-go to "file" and choose "save as..."
c1-on "file format", choose "lss16"
c2-(this is not a must) name your file of "logo.16.lss" (to distinguish which file is the new image)
4-open the file "boot.msg" using geany (or any equivalent file editor that supports special chars):
a-in the first line, change "logo.16" to the name of the image (ex: "logo.16.lss")
b-you can change the text color by writing after char "SI" the number of the color. the number of the color can be taken from the image. the color value MUST BE IN HEX (ex:SI0a). the color code will match the color indexed in the image!!!

now you have your new splash configured and ready to use!!!
p.s.:
this was tested using mtpaint 3.31, geany 0.18 and done in puppy linux 4.3.1
the results where quite great!!!
i hope it works to you!!!
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#29 Post by espertalhao04 »

here is the result of my boot image (using kemu and the file boot.msg was changed):

Image
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

User avatar
steve_s
Posts: 1595
Joined: Mon 26 May 2008, 13:29
Location: Austin, TX, USA
Contact:

#30 Post by steve_s »

espertalhao04 wrote:here is the result of my boot image (using kemu and the file boot.msg was changed):
Nice! 8)

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#31 Post by espertalhao04 »

hey dude...
if you want to try my changes, i can provide you the iso (puppy linux 4.3.1) and a compressed file with my changes!!!
i am thinking about doing it to the part with the boot options, but i'm not sure of what i'd do...
any sugestion and how-to is really wellcome ...
i've tryed to insert the image as background but it didn't worked...

.tar.gz compressed file with changes!
https://hotfile.com/dl/156261134/b852e3 ... ar.gz.html

.iso bootable file (puppy linux 4.3.1)
https://hotfile.com/dl/156261449/391b7f ... d.iso.html

any sugestion, error, request, how-to or anything, you can ask to me...
i'll try as much as possible...
if something is wrong, tell me...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#32 Post by espertalhao04 »

if someone can make a better dithering with that image (to create a high quality color-gradient), please, tell me how to do it!!!
the dithering quality is quite poor and horrible...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

midmen
Posts: 4
Joined: Wed 20 Jun 2012, 18:25

#33 Post by midmen »

I am new to this so I appreciate your help and understanding. I was able to open my boot.msg file using Geany (see below). Once opened I was able to make the changes to my splash image. My question has to do with understanding what do the letters in the black boxes do? I believe I read that SI sets the color of the text. What do the others do and where could I find information that explains how to change certain code in my Puppy?

Thank you.

[/img]
Attachments
image-1.png
(30.8 KiB) Downloaded 613 times

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#34 Post by espertalhao04 »

i don't know what they exactly mean...
but the box CAN is for the image...
the box SI(hex value of 2 chars, from 00 to 0f) is the text color...
but the text color changes according to the colors in the image...
for example:
SI0a is one of the light gray...
with that logo.16 (the one i created)...
with the original, is orange...
to know the exact color, you open the logo.16 with mtpaint...
at left, you have the color pallete...
you choose what color you want...
and then write it in hex, next to SI...
this is how it is my boot.msg (i have different from the iso, i made it even more personal):

FF CANlogo.16.lss
SI08Wait SI0e5SI08 seconds to boot, press SI0e<F2>SI08 for options.SI08
SUB

note: all that is in uppercase, is the black chars in a box (except the F2)...
the boot.msg example is for puppy 4.3.1, and you must use slack or warry, cause you have the option to click on <F3>...
you can change the image name, but you must have an image in lss16...
in this topic i have a step by step explanation of how to convert any image to lss16 with mtpaint...
any help, or question, just ask...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#35 Post by espertalhao04 »

i don't know what they exactly mean...
but the box CAN is for the image...
the box SI(hex value of 2 chars, from 00 to 0f) is the text color...
but the text color changes according to the colors in the image...
for example:
SI0a is one of the light gray...
with that logo.16 (the one i created)...
with the original, is orange...
to know the exact color, you open the logo.16 with mtpaint...
at left, you have the color pallete...
you choose what color you want...
and then write it in hex, next to SI...
this is how it is my boot.msg (i have different from the iso, i made it even more personal):

FF CANlogo.16.lss
SI08Wait SI0e5SI08 seconds to boot, press SI0e<F2>SI08 for options.SI08
SUB

note: all that is in uppercase, is the black chars in a box (except the F2)...
the boot.msg example is for puppy 4.3.1, and you must use slack or warry, cause you have the option to click on <F3>...
you can change the image name, but you must have an image in lss16...
in this topic i have a step by step explanation of how to convert any image to lss16 with mtpaint...
any help, or question, just ask...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#36 Post by espertalhao04 »

by the way, all the other changes must be on the scripts itself...
and in some binaries...
for example:
if you use the puppy linux from a fat32 pendrive, it will load the isolinux.bin and the isolinux.sys first...
both of those are binaries that need to be changes with other programs...
there is a script (on puppy 4.3.1, inside pup-431.sfs), located at /etc/rc.d/rc.sysinit
this script is the one that is loaded when the main sfs file is found...
and it loads the modules and that...
i tried to change it, but i screwed everything and gave up...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

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

#37 Post by Karl Godt »

espertalhao04 wrote:by the way, all the other changes must be on the scripts itself...
and in some binaries...
for example:
if you use the puppy linux from a fat32 pendrive, it will load the isolinux.bin and the isolinux.sys first...
both of those are binaries that need to be changes with other programs...
there is a script (on puppy 4.3.1, inside pup-431.sfs), located at /etc/rc.d/rc.sysinit
this script is the one that is loaded when the main sfs file is found...
and it loads the modules and that...
i tried to change it, but i screwed everything and gave up...
rc.sysinit does not do much for the boot process to work with .sfs files .

The main boot work with .sfs files is done in initrd.gz's /init script (not /sbin/init ) .

rc.sysinit works on / already mounted by the kernel in full installations and mounted by /init for frugal installations . '/' meaning the sum of all .sfs and 3.fs layers OR in full installations the topmost directory level .

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#38 Post by espertalhao04 »

/etc/rc.d/rc.sysinit is the script executes as soon as the sfs file is loaded...
you have to see it...
you open it and search for it...
there will be a point where it says that has made a switch root...
and prints done in green...
i know this because i have tested it...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

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

#39 Post by Karl Godt »

Code: Select all

#!/bin/ash
#(c) copyright Barry Kauler 2008, puppylinux.com
#2008 Lesser GPL licence v2 (http://www.fsf.org/licensing/licenses/lgpl.html)
#v404 first release. rewritten from scratch, aiming for simplicity and speed.
#v405 fix for alsa.
#v406 load apm.ko if no acpi.
#v408 explicitly load battery, ac, thermal, fan modules.
#v409 gparted create ext3 part. failed, fixed by making /etc/mtab a symlink.
#v411 fix mouse detection logic.
#v411 can use old network wizard (from 403, based on 400)
#v411 return of 'puppyserialdetect', for usb/ps2 mouse detection only. now 'puppyinputdetect'.
#v411 extra 'sleep 1' as rerwin reports usb mouse may need it some hardware.
#v411 choosemousefunc().
#v412 /etc/DISTRO_SPECS, renamed pup_xxx.sfs, pup_save.2fs etc.
#v412 bugfix usb-storage wait loop.
#w001 ubuntu module-init-tools not configured to support gzipped modules.
#w004 LANG=C, faster. /bin/ash, even faster.
#w463 rerwin: special mwave modem handling.
#w463 mouse scrollwheel fix.
#w468 full-hd-install, write to PUPSTATE after remount r/w.
#w478 moved depmod code up above call to rc.update.
#w481 fix crappy depmod, 'out of memory' in first boot 64MB RAM (no swap).
#v423 k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid.
#v424 fix LAYERFS variable.
#v424 fix secondary uevent replay. now finds ssb devices.
#v431 secondary uevent replay, fix for old kernels < 2.6.24

########################################################################
#
# CHANGES by Karl Reimer Godt
# 00.0 : added function for fsckme.flg to boot further or stop booting
# 01.0 : added various debug echos and dumpe2fs to examine ext2 fs -> switched to ext3
# 02.0 : private part :
#   .1 : mount all none fs with   mount_none_fs_func
#   .2 : case have had booted a kernel with mnt/dev feature : mkmissing_tty_func
#   .3 : check_dev_root_func which sould create the link /dev/root -> rdev
#   .4 : check_frugal_full_func
#   .5 : mkmissing_blockdev_func
#   .6 : dev_maj_259_func
#   .7 : device_nodes_fork_func
#   .8 : mk_missing_var_dev_func
#   .9 : pupstate_prev_func
# 03.0 : multiple kernels part :
#   .1 : firmware_dep_func
#   .2 : lib_firmware_func
#   .3 : mondprobe_conf_func
# 04.0 : added additional /tmp/pup_event_skiplist.conf
#   .1 : parsing the content of /etc/[modprobe.d/]modprobe.conf to  /tmp/pup_event_modprobe.conf
# 05.0 : forced loading of uhci_hcd and ohci_hcd similar to ehci_hcd
# 06.0 : only load modules if initstate lesser than 25
#
# 07.0 : still experimenting with echo "SATADRIVES='${BLOCK_SATAD}'" >> /etc/rc.d/PUPSTATE
# 08.0 : force loading of acpi drivers battery , ac , fan
#
# 09.0 : fbcon_func
# 10.0 : echo nox if Xvesa server or in /proc/cmdline
# 11.0 : creating /etc/.fsckme.flg <- commented to shutdown i think
#
# 13.0 : code to sort the pup_event_backend_modprobe logfile
#
# /dev/sda5:
# LABEL="MacPup430_F3"
# UUID="07443de5-1fab-4656-a3ab-7b1c14ccc8c8"
# TYPE="ext3"
# DISTRO_VERSION=430#481#416#218#478#####changethisasrequired#####
# DISTRO_BINARY_COMPAT="puppy"#"ubuntu"#"puppy"#####changethisasrequired#####
# case$DISTRO_BINARY_COMPATin
# ubuntu)
# DISTRO_NAME="JauntyPuppy"
# DISTRO_FILE_PREFIX="upup"
# DISTRO_COMPAT_VERSION="jaunty"
# ;;
# debian)
# DISTRO_NAME="LennyPuppy"
# DISTRO_FILE_PREFIX="dpup"
# DISTRO_COMPAT_VERSION="lenny"
# ;;
# slackware)
# DISTRO_NAME="SlackPuppy"
# DISTRO_FILE_PREFIX="spup"
# DISTRO_COMPAT_VERSION="12.2"
# ;;
# arch)
# DISTRO_NAME="ArchPuppy"
# DISTRO_FILE_PREFIX="apup"
# DISTRO_COMPAT_VERSION="200904"
# ;;
# t2)
# DISTRO_NAME="T2Puppy"
# DISTRO_FILE_PREFIX="tpup"
# DISTRO_COMPAT_VERSION="puppy5"
# ;;
# puppy)#builtentirelyfromPuppyv2.xorv3.xor4.xpetpkgs.
# DISTRO_NAME="Puppy"
# DISTRO_FILE_PREFIX="pup"#"ppa"#"ppa4"#"pup2"#pup4###CHANGEASREQUIRED,recommendlimitfourcharacters###
# DISTRO_COMPAT_VERSION="4"#"2"#4###CHANGEASREQUIRED,recommendsingledigit5,4,3,or2###
# ;;
# esac
# PUPMODE=2
# KERNVER=2.6.30.6-KRG-i486
# ATADRIVES='sda'
# USB_SATAD=''
# PUP_HOME='/'
# Linuxpuppypc2.6.30.6-KRG-i486#1SMPSunJan220:32:12GMT-12011i686GNU/Linux
# Xserver=/usr/X11R7/bin/Xvesa_stripped_upx9
# $LANG=en_US
# today=MonOct2422:46:48CEST2011
# TODO1 : modaliases | sort -d
# TODO2 : /etc/modprobe.d/ in mult_kernels
#
#
#
########################################################################

##+++2012-05-08
Version='1.1 Macpup_F3-Puppy-Linux-430/2 KRG'
usage(){
MSG="
$0 [-V --version | -h --help ]
Bootupscript to load kernel drivers,
update,set network and drives,set locale
and much more . Without it,
the kernel does not do anything.
"
echo "$MSG"
exit $1
}
[ "`echo "$1" | grep -iE '\-V|version'`" ] && { echo -e "\n$0: Version '$Version'\nUse help parameter for more info\n";exit 0; }
[ "`echo "$1" | grep -iE '\-h|help'`" ] && usage 0
[ "$1" ] && usage 1
[ "$DISPLAY" ] && exit 1
##+++2012-05-08

file_system_state(){
echo -n "FILESYSTEM STATE $1: "
dumpe2fs `rdev` | grep -i 'state'
echo
}

load_average(){
echo "$1:`uptime`"
}

fsckme_func_0() {
FSCKME=`find / -maxdepth 3 -type f -iname "*fsckme*"`  ###KRG, for Advanced /sbin/init
echo $FSCKME  ###DBG
if [ -n "$FSCKME" ] ; then  ###KRG

modprobe ehci_hcd
modprobe ohci_hcd
modprobe uhci_hcd
modprobe usbhid

echo -e "\\033[1;31m"' ... '"$FSCKME"' still exists !'
echo
echo -e "\\033[0;31m"'Want to boot anyway [ B ],[ b ] and [ Enter ] ?'
echo -e "\\033[1;32m"'Reboot [ R ],[ r ] and [ Enter ] ?'
echo -e "\\033[0;32m"'Poweroff [ P ],[ p ] and [ Enter ] ?'
echo -e "\\033[1;34m"'Or simply exit rc.sysinit [ Enter ],[ any other key and Enter ] ?'
echo -e "\\033[1;33m"'         ( timeout 60 sec ... -> exit ) '
echo -e "\\033[7;39m"
echo -n '->'
read -t 60 K
echo -e "\\033[0;39m"
if [ "$K" = "R" -o "$K" = "r" ] ; then
echo 'Rebooting ...'
/bin/busybox umount -ar
/bin/busybox reboot
fi

if [ "$K" = "P" -o "$K" = "p" ] ; then
echo "Pow'ring off the computer ..."
/bin/busybox umount -ar
/bin/busybox poweroff
fi

if [ "$K" = "B" -o "$K" = "b" ] ; then
echo 'Continuing booting ...'
else
echo 'Exiting /etc/rc.d/rc.sysinit'
exit
fi
fi
}
fsckme_func_0

export LANG=C

. /etc/rc.d/functions4puppy4
. /etc/DISTRO_SPECS

file_system_state 1

status_func() {
 if [ $1 -eq 0 ];then
  /bin/echo -e "\\033[72G\\033[1;32mdone\\033[0;39m" >/dev/console #green [done] msg.
 else
  /bin/echo -e "\\033[70G\\033[1;31mfailed\\033[0;39m" >/dev/console #red [failed].
  STATUS=0
 fi
 return $1 #return with same status as entry param.
}

loadswap_func() { #w481 made into a function.
 [ "`grep -i 'noswap' /proc/cmdline`" ] && return 0
 echo "LOAD SWAP"
 echo -n "Activating swap partition(s) " >/dev/console
 SWAPS=`fdisk -l | grep ' Linux swap' | cut -f 1 -d ' '`
 if [ "$SWAPS" ];then
 #load a swap partition...
  for ONESWAP in $SWAPS
 do
  [ "`blkid $ONESWAP | grep -iE 'Resume|Hiber'`" ] && continue
  echo -n " $ONESWAP" >/dev/console
  swapon $ONESWAP
  SWAP_STATUS=$((SWAP_STATUS+$?))
  [ $SWAP_STATUS -eq 0 ] && SWAPON="yes"
 done
 status_func $SWAP_STATUS
 fi
 #if no go, try for a swap file...
 if [ "$SWAPON" != "yes" ];then
  SWAPFILE="/pupswap.swp"
  [ "$PSWAPFILE" ] && SWAPFILE="`echo -n "$PSWAPFILE" | cut -f 3 -d ','`"  #/etc/rc.d/PUPSTATE
  if [ -f /initrd${PUP_HOME}${SWAPFILE} ];then
   echo -n "Loading swap file ${SWAPFILE}..." >/dev/console
   swapon /initrd${PUP_HOME}${SWAPFILE}
   status_func $?
   [ $? -eq 0 ] && SWAPON="yes"
  fi
  if [ -f $SWAPFILE ];then
   echo -n "Loading swap file ${SWAPFILE}..." >/dev/console
   swapon $SWAPFILE
   status_func $?
   [ $? -eq 0 ] && SWAPON="yes"
  fi
 fi
 [ "$SWAPON" = 'yes' ] || echo -e "\\033[0;5;31m\n\t\t"'WARNING : NO SWAP could be activated'"\\033[0;39m" #>/dev/console
}

#if have just done a switch_root, output a 'done' message...
#[ -d /initrd ] && status_func 0 #note, /initrd does not exist when a full-hd installation.
[ "`rdev`" ] || status_func 0

###. /etc/rc.d/MODULESCONFIG #modules loading configuration.
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R7/bin
STATUS=0

##############MAKE FILESYSTEM USABLE################
#echo "MAKE FILESYSTEM USABLE"
echo -n "Making the filesystem usable..." >/dev/console #need this redirection!
busybox mount -t proc none /proc ;STATUS=$(($STATUS+$?))

#if [ ! -d /initrd ];then #w468
if [ "`rdev`" ];then
 busybox mount -o remount,rw /
 echo 'PUPMODE=2' > /etc/rc.d/PUPSTATE
fi

##+++2012-01-29
mkdir -p /dev/vc;rm -f /dev/vc/11;mknod /dev/vc/11 c 4 11
openvt -c 11 autologinroot
##+++2012-01-29

#w478 moved this code above call to rc.update...
KERNVER="`uname -r`"
KERNMAJ=`echo -n "$KERNVER" | cut -f 3 -d '.' | cut -f 1 -d '-'` #v431
echo 'KERNVER='$KERNVER >> /etc/rc.d/PUPSTATE
. /etc/rc.d/PUPSTATE #variables created at bootup by init script in initrd.
#file_system_state 2

#puppy boot parameters:
if [ "$PUPMODE" = '2' ];then
for item in `cat /proc/cmdline` ;do
case $item in
pfix=*)
    ITEMS=`echo "$item" |cut -f 2 -d '=' |tr ',' ' '`
        for item2 in $ITEMS;do
        case $item2 in
        nox)        echo 'nox' > /tmp/X.status;;
        xorgwizard) mv /etc/X11/xorg.conf /etc/X11/xorg.conf-"`date`";;
        noswap)     SWAPON=yes;;  #fake value,dunno why for now
        noalsa)     echo 'noalsa' >/tmp/pup_event_alsa_cnt ;;
        nofbcon)    NO_FBCON=1  ;;
        pupmode:*) PUPMODE=${item2#*:};sed -i "s/PUPMODE=.*/PUPMODE='$PUPMODE'/" /etc/rc.d/PUPSTATE;. /etc/rc.d/PUPSTATE;;
        fsck)  : ;;  #do filesystem check on lupusave (and host part. if ext2
        clean) : ;;  #file cleanup (simulate version upgrade)
        purge) : ;;  #more radical file cleanup (to fix broken system)
        rdsh)  : ;;  #for developers only (initramfs shell)
        copy)  : ;;  #copy lupu-511.sfs to RAM (slower boot, faster running)
#racy 522
        nocopy) : ;; #do not copy .sfs files to RAM (faster boot, slower running), #racy 522

        pdev1:*) : ;; #The boot partition.
        psubdir:*) : ;; #psubdir=puppies/wary501 Path in which Puppy is installed.

        psavemark:*) : ;; # =2 Partition no. (in boot drive) to save session to.

        pmedia:*) : ;; #Type of media booting from. Choose one of these:
             # usbflash usbhd usbcd ataflash atahd atacd atazip scsihd scsicd cd

        pupsfs:*) : ;; # =sdc1:/puppies/wary501/puppy.sfs Override auto search.
        zdrv:*) : ;;   # =sdc1:/puppies/wary501/zdrv.sfs  Override auto search.
#racy 522
        [0-9]) : ;;  #number of saved sessions to ignore (multisession-CD)
        esac;done
    ;;
*)
[ "`echo "$item" | grep '='`" ] || item="${item}=1"
item=${item//\./XXX}
kp=${item%=*};echo -n "${kp},"
eval $item
export $kp
;;
esac;done
echo
fi

[ $loglevel ] && LOGLEVEL=$loglevel #boot param.
[ $pmedia ] && PMEDIA=$pmedia #boot parameter, broad category of boot media. ex: cd.
[ $pdev1 ] && PDEV1=$pdev1    #boot parameter, partition have booted off. ex: hda3

#redirect all output to a log file (must do after remount rw)...
#[ "$LOGLEVEL" ] ||
exec 1>/tmp/bootsysinit.log 2>&1

load_average '0x00'

alias modprobe='modprobe -b' ##+++2012-02-03

#v409 mount/umount scripts no longer write to /etc/mtab, as gparted failed to create a
#ext3 partition -- dunno why. Instead, now have /etc/mtab a symlink to /proc/mounts...
rm -f /etc/mtab
ln -s /proc/mounts /etc/mtab


mkdir -p /dev/pts
busybox mount /dev/pts ;STATUS=$(($STATUS+$?))
mkdir -p /sys
busybox mount -t sysfs none /sys ;STATUS=$(($STATUS+$?))

##v2.20 some apps need shm (shared memory) (ex: xfdiff)...
FREERAM=`free | grep 'Mem:' | tr -s ' ' | cut -f 4 -d ' '` #w481
#if [ ! -d /initrd ];then #weird, only full-hd install needs this for xfdiff.
if [ "`rdev`" ];then
 QTRFREERAM=`expr $FREERAM \/ 4`
 mkdir -p /dev/shm
 mount -t tmpfs -o size=${QTRFREERAM}k shmfs /dev/shm ;STATUS=$(($STATUS+$?))
fi

load_average '0x01'

MY_ADDITIONAL_PART(){

modprobe_conf_func() {

mkdir -p /etc/mult_kernels

if test -f /etc/mult_kernels/modprobe.conf.$KERNVER ; then
cp -f --remove-destination /etc/mult_kernels/modprobe.conf.$KERNVER /etc/modprobe.conf
else
if test -f /etc/modprobe.conf ;then
[ -f /etc/mult_kernels/modprobe.conf.$KERNVER ] || cp /etc/modprobe.conf /etc/mult_kernels/modprobe.conf.$KERNVER
fi
fi

if test -d /etc/mult_kernels/modprobe.d.$KERNVER ; then
rm -f -r /etc/modprobe.d
cp -f -r /etc/mult_kernels/modprobe.d.$KERNVER /etc/modprobe.d
else
if test -d /etc/modprobe.d ; then
[ -d /etc/mult_kernels/modprobe.d.$KERNVER ] || cp -r /etc/modprobe.d /etc/mult_kernels/modprobe.d.$KERNVER
fi
fi

[ -d /etc/mult_kernels/rc.d ] || mkdir /etc/mult_kernels/rc.d
if [ ! -f /etc/mult_kernels/rc.d/MODULESCONFIG.$KERNVER ] ; then
cp /etc/rc.d/MODULESCONFIG /etc/mult_kernels/rc.d/MODULESCONFIG.$KERNVER
else
cp -f /etc/mult_kernels/rc.d/MODULESCONFIG.$KERNVER /etc/rc.d/MODULESCONFIG
fi; }; modprobe_conf_func & ##-2011-11-07 just to be done in /sbin/init ##2012-01-13 not implemented there yet
load_average '1x0a'
#file_system_state 3
etc_firmware_dep_func() {
if test ! -f /etc/modules/firmware.dep.$KERNVER; then
echo "copying firmware.dep" > /dev/console
FWF=`find /etc/modules -type f -name "firmware.dep.*" | head -n 1`
cp "$FWF" /etc/modules/firmware.dep.$KERNVER
fi; } ; etc_firmware_dep_func &
load_average '1x0b'
#file_system_state 4
lib_firmware_func() {
FWD=`find /lib/modules/$KERNVER/ -maxdepth 2 -type d -name "firmware*" | head -n 1`
if test "$FWD" != "" ; then
[ -d /lib/firmware ] && rm -f /lib/firmware/firmware* ##+++2012-04-11
BN=`basename $FWD`
SN=${BN:0:8}
cp -f -r "$FWD"/* /lib/$SN ##+++2012-04-11 to preserve alredy installed special firmware from all-modules directory #+2012-04-21 added /* to "$FWD" --happened before several times
fi
}
lib_firmware_func
load_average '1x0c'
#file_system_state 5

mount_none_fs_func(){
NFS=`cat /proc/filesystems | grep 'nodev' | tr  '\t' ' ' | cut -f 2 -d ' '`
NODEV=`echo "$NFS" | grep -v -E 'pipe|sock|bdev|anon|inotify|aufs|fuse'`

for i in $NODEV ; do
echo
echo "$i"
DIR=`echo "$i" | sed 's#fs$##'`
if [ -z "`busybox mount | grep "$i"`" ] ; then

[ -d /dev/fs/$DIR ] || mkdir -p /dev/fs/$DIR
mount-FULL -v -t $i none /dev/fs/$DIR  ##+-2012-01-11 changed nodev to none

fi
done
};mount_none_fs_func
load_average '1x0d'
mkmissing_tty_func() {
[ -c /dev/tty ] || mknod /dev/tty c 5 0
[ -d /dev/vc ] || mkdir /dev/vc

VTInittab=`cat /etc/inittab | grep -E 'tty|vc' | grep -v -E '^#|^[[:blank:]]*#|^\t*#' | tr -s ' ' | sort -u | grep -o -w -E 'tty[0-9]*$|vc[0-9].*' | grep -o '[0-9]*$'`
for i in $VTInittab ; do
[ -c /dev/vc/$i ] || { rm -f /dev/vc/$i ; mknod /dev/vc/$i c 4 $i ; }
[ -c /dev/tty$i ] || { rm -f /dev/tty$i ; mknod /dev/tty$i c 4 $i ; }
done

[ -c /dev/console ] || { rm -f /dev/console ; mknod /dev/console c 5 1 ; }
[ -c /dev/zero ] || { rm -f /dev/zero ; mknod /dev/zero c 1 5 ; }
[ -c /dev/null ] || { rm -f /dev/null ; mknod /dev/null c 1 3 ; }

[ -d /dev/pts ] || { rm -f /dev/pts;mkdir /dev/pts; }
[ -c /dev/ptmx ] || { rm -f /dev/ptmx;mknod /dev/ptmx c 5 2; }

for i in $(seq 0 4); do
[ -c /dev/ptyp$i ] || { rm -f /dev/ptyp$i;mknod /dev/ptyp$i c 2 $i; }
done

[ -d /dev/fb ] || mkdir /dev/fb
for i in `seq 0 11` ; do
[ -c /dev/fb$i ] || mknod /dev/fb$i c 29 $i
[ -L /dev/fb/$i ] || ln -s ../fb$i /dev/fb/$i
done
};mkmissing_tty_func

#file_system_state 6
load_average '1x0e'
check_dev_root_func() {
RootDevBlockNrs=`dmesg | grep 'Mounted root'| grep -o 'device.*' | tr -d '.' | cut -f 2 -d ' '`

if test -n "$RootDevBlockNrs"; then
MAJ=`echo $RootDevBlockNrs | cut -f 1 -d ':'`
Min=`echo $RootDevBlockNrs | cut -f 2 -d ':'`

RootDevice=`LC_ALL=C ls -l /dev/ | grep -E 'hd|sd' |tr -s ' '| cut -f 5,6,10 -d ' ' | grep -w "^$MAJ" | grep -w "$Min" | tr -s ' ' | cut -f 3,4 -d ' '`  ##BUG : added tr -s ' ' after grep -E 'hd|sd'
#LC_ALL=C ls -l /dev/sda2
#brw-r--r-- 1 root root 8, 2 Jun 12 11:33 /dev/sda2
#LANG=C ls -l /dev/sda2
#brw-r--r-- 1 root root 8, 2 2012-06-12 11:33 /dev/sda2

#LANG=C ls -l /dev/root
#lrwxrwxrwx 1 root root 4 2012-06-15 17:16 /dev/root -> sda2
#LANG=en_US ls -l /dev/root
#lrwxrwxrwx 1 root root 4 2012-06-15 17:16 /dev/root -> sda2

if [ -b /dev/"$RootDevice" ];then
ROOTDEVICE=$RootDevice
else
ROOTDEVICE=NOT_FOUND_BY_SYSINIT
fi
ln -sf $ROOTDEVICE /dev/root
fi
}
check_dev_root_func
load_average '1x0f'
check_frugal_full_func() {
CatProcPart=`cat /proc/partitions | tr -s ' ' | sed '1,2 d'`
RootDiskFreeFrugal=`df | grep -w '/' | grep 'rootfs'`
[ "$PUPMODE" = 12 ] && MountFrugal=`mount | grep '/initrd/mnt/dev_save' | cut -f 1 -d ' '`
RootDiskReadlinkDevRoot=`readlink /dev/root`
RootDiskFreeFullInstall=`df | grep -w '/' | tr -s ' ' | cut -f 1 -d ' '`
MountFull=`mount | grep -w '/' | grep '/dev/' | tr -s ' ' | cut -f 1 -d ' '`
BBrdev=`busybox rdev`

if test -n "$RootDiskFreeFrugal" -a -n "$MountFrugal" -a -z "$BBrdev" ; then ## frugal install
SimpleDeviceName=`echo $MountFrugal | sed 's#/dev/##'`
MainDriveName=${SimpleDeviceName:0:3}
RootDevice=`echo "$CatProcPart" | grep -w $SimpleDeviceName`
MainDevice=`echo "$CatProcPart" | grep -w $MainDriveName`
else
if test -n "$RootDiskFreeFullInstall" -a -n "$MountFull" -a -n "$BBrdev" ; then ## full install
SimpleDeviceName=`echo $MountFull | sed 's#/dev/##'`
MainDriveName=${SimpleDeviceName:0:3}

RootDevice=`echo "$CatProcPart" | grep -w $SimpleDeviceName`
if [ -z "$RootDevice" ] ; then  ###KRG&& SimpleDeviceName=`basename "$(busybox rdev)" | tr -d '/'`
SimpleDeviceName=`basename "$(busybox rdev | sed 's#/$## ; s#[[:blank:]]*$##')" | tr -d '/'`
RootDevice=`echo "$CatProcPart" | grep -w $SimpleDeviceName`
fi

MainDevice=`echo "$CatProcPart" | grep -w $MainDriveName`
if [ -z "$MainDevice" ] ; then
MainDriveName=`basename "$(busybox rdev | sed 's#/$## ; s#[[:blank:]]*$##')" | tr -d '/' | cut -b 1-3`
MainDevice=`echo "$CatProcPart" | grep -w $MainDriveName`
fi

fi

fi
};check_frugal_full_func

load_average '1x1a'
#file_system_state 7

mk_missing_var_dev_func() {

if test -d /var/db/$KERNVER/dev ; then
cp -a /var/db/$KERNVER/dev / 2>/dev/null

else
if test -f /var/db/boot/dev_nodes.lst; then
DDB="`cat /var/db/boot/dev_nodes.lst`"
cat /var/db/boot/dev_nodes.lst| while read PERM N O G MAY Min M D T DEV; do
[ -z "$DEV" ] && DEV=$T
KIND=${PERM:0:1}
MAJ=`echo $MAY | tr -d ','`
DN=`dirname $DEV`
[ -d $DN ] || mkdir $DN
[ -$KIND $DEV ] || { echo "making $DEV";mknod $DEV $KIND $MAJ $Min; }
done
fi
fi
}
mk_missing_var_dev_func
load_average '1x1b'
#file_system_state 8

} #MY_ADDITIONAL_PART
##MULTI-CORE +++2012-05-08
echo `date`
PROCESSORS=`grep ^processor /proc/cpuinfo |wc -l`
[ "$PROCESSORS" -gt '1' ] && { echo "'$PROCESSORS' processors detected";M_CORE=$PROCESSORS; }
if [ "$M_CORE" ];then
echo "Forking MY_ADDITIONAL_PART"
MY_ADDITIONAL_PART &
else
echo "Not forking MY_ADDITIONAL_PART"
MY_ADDITIONAL_PART
fi
echo `date`
##MULTI-CORE +++2012-05-08
load_average '1x00'
#file_system_state 9

pupstate_prev_func() {
if test "`grep -x KERNVER /etc/rc.d/PUPSTATE.prev | cut -f2 -d=`" != "$KERNVER" ; then
if test ! -f /lib/modules/$KERNVER/modules.dep -o ! -f /lib/modules/$KERNVER/modules.symbols -o ! -f /lib/modules/$KERNVER/modules.alias ; then
echo "Detected booting other kernel than last time" >> /dev/console
echo "Have to run depmod, please wait some 10 seconds" >> /dev/console
depmod
depmod-FULL
fi
fi
}; #pupstate_prev_func

#w469 may need to run 'depmod'...
#live-cd may have been built without the modules.* files.
#initrd init script copied modules to /lib/modules/<kernver>/initrd/.
if [ ! -f /lib/modules/${KERNVER}/modules.dep ];then
 NEEDDEPMOD="yes" #w469 files may not be there to save space.
 [ -d /lib/modules/${KERNVER}/initrd ] && NEEDGUNZIP="yes"
else
 if [ -d /lib/modules/${KERNVER}/initrd ];then
  if [ "`grep '/initrd/' /lib/modules/${KERNVER}/modules.dep`" = "" ];then
   NEEDDEPMOD="yes" #w469 files may not be there to save space.
   NEEDGUNZIP="yes"
  fi
 fi
fi
if [ "$NEEDGUNZIP" = "yes" ];then
 #w001 ubuntu module-init-tools not configured to support gzipped modules...
 #for ONEMOD in `find /lib/modules/${KERNVER}/initrd/* -type f -name *.gz | tr '\n' ' '`
 #do
 # gunzip $ONEMOD
 #done
 gunzip -f -r /lib/modules/${KERNVER}/initrd #w482 shinobar.
fi

#w481 now building with busybox depmod, in module-init-tools have depmod-FULL, so comment out...
##w481 workaround for crappy depmod. First boot 64MB ram no swap, only 14660 free ram, due to
##tmpfs top layer (about 26MB). depmod gives 'out of memory'. so delay until after swap loaded...

if [ "$NEEDDEPMOD" = "yes" ];then
 echo -n ' depmod' >/dev/console
 depmod
fi

[ $layerfs ] && LAYERFS=$layerfs #boot param.
[ $LAYERFS ] || LAYERFS=aufs #aufs or unionfs
[ "`modinfo aufs 2>/dev/null`" ] || LAYERFS=unionfs #precaution.

status_func $STATUS
load_average '1xff'
#file_system_state 13
#######################VERSION UPDATE##########################
echo "VERSION UPDATE"
#force update when new version of ${DISTRO_NAME}...
echo -n "Updating..." >/dev/console

/etc/rc.d/rc.update $PUPMODE
sync
status_func $STATUS
load_average '2xff'
#file_system_state 14
#################LOAD KERNEL MODULES################
echo "LOAD KERNEL MODULES"
. /etc/rc.d/MODULESCONFIG
echo `date`
#alias modprobe='modprobe -s' #-s regular modprobe+bb_v1.17 ;-L my modprobe
echo -n "Loading kernel modules..." >/dev/console

MODALIASES="`ls /sys/bus/*/devices/*/modalias`"

BLACKLISTVARS="`echo "$SKIPLIST" | tr '\-' '_' | tr ' ' '\n' | sed -e 's/^/blacklist /' | grep -v ' $'`"
echo "$BLACKLISTVARS" > /tmp/pup_event_modprobe.conf
echo "$BLACKLISTVARS" > /tmp/pup_event_skiplist.conf
[ -f /etc/modprobe.conf ] && cat /etc/modprobe.conf >> /tmp/pup_event_modprobe.conf
if [ -d /etc/modprobe.d ] ; then
for i in /etc/modprobe.d/* ; do
cat $i >> /tmp/pup_event_modprobe.conf
done
fi

#...read in /sbin/pup_event_backend_d, and pup_event_backend_modprobe (for udevd).

#if [ ! -d /initrd ];then #v423 full hd install.
if [ "`rdev`" ];then
 #v423 have this in 'init', probably need here too...
 if [ "`echo "$MODALIASES" | grep 'bc0Csc03i10'`" != "" ];then
  modprobe --config /tmp/pup_event_modprobe.conf yenta-socket
  [ $? -eq 0 ] && sleep 2
 fi
 #v423 k2.6.29.6 dmesg has warning that ehci-hcd should load before uhci-hcd and ohci-hid
 # this is contrary to my understanding all these years, but oh well, let's do it...
 ELSPCI="`elspci -l`" #jesses great little utility.
 [ "`echo "$ELSPCI" | grep '0C0320'`" != "" ] && modprobe --config /tmp/pup_event_modprobe.conf ehci-hcd
 #...perhaps a udev rule could have done this?
 [ "`echo "$ELSPCI" | grep '0C0310'`" != "" ] && modprobe --config /tmp/pup_event_modprobe.conf ohci-hcd
 [ "`echo "$ELSPCI" | grep '0C0300'`" != "" ] && modprobe --config /tmp/pup_event_modprobe.conf uhci-hcd
fi
[ -n "`lsmod | grep -E 'uhci|ohci|ehci'`" ] && modprobe usbhid

#v405 udevd calls /sbin/pup_event_backend_modprobe, which needs this...#my intention is for puppy to work with either of these...
if [ -x /sbin/udevd ];then  ##2011_10_27 changed -f to -x
 [ "$LOGLEVEL" ] || LOGLEVEL=7
[ -z "`pidof udevd`" ] && UDEV_LOG=$LOGLEVEL /sbin/udevd --daemon
else
[ -z "`pidof pup_event_backend_d`" ] &&  pup_event_backend_d >/tmp/pup_event_backend_errors 2>&1 & #hotplug daemon. my homebrew replacement for udevd.
fi
sleep 0.1

INITSTATE=`find /sys -name "initstate"`
INITSTATEwc_l=`echo "$INITSTATE" | wc -l`
echo 'INITSTATEwc_l='"$INITSTATEwc_l"
load_average '3x0a'
if [ -z "$MODALIASES" ] ; then #1

echo -e "\e[1;5;31m"'WARNING : '"\e[0;31m"'No modaliases found !'"\e[39m" >/dev/console
echo -e "\e[39m"'Either the kernel detected no HW automatically'"\e[39m" >/dev/console
echo -e "\e[39m"'or something else went wrong'"\e[39m" >/dev/console

else #1

[ -f /tmp/pup_event_alsa_cnt ] || echo -n '0' > /tmp/pup_event_alsa_cnt

if [ "$INITSTATEwc_l" -lt 25 ] ; then  #initrd.gz loads 10 modules plus some extra #2
echo 'Running the modaliases add by rc.sysinit '$0
echo >> /tmp/pup_event_module_devpath_log
echo 'Running the modaliases add by rc.sysinit '$0 >> /tmp/pup_event_module_devpath_log

MODULECNT=0
#replay uevents from /sys...
for ONEMODALIAS in $MODALIASES
do
 ONEPATH="`dirname $ONEMODALIAS`"
 if [ -e ${ONEPATH}/uevent ];then
  echo 'added '"${ONEPATH}" >> /tmp/bootmodules.txt
  echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
  sleep 0.02
  #echo -n '.' >/dev/console
  echo -ne "\r$MODULECNT" >/dev/console
  MODULECNT=$((MODULECNT+1))
 fi
done
echo >> /tmp/bootmodules.txt

else #2
echo 'Skipping uevent part , more than 25 modules already loaded ...'

fi
fi

load_average '3x0b'
#if [ ! -d /initrd ];then #full hd installation.
if [ "`rdev`" ];then
 modprobe nls_cp437 #these needed by vfat/ntfs/ext2 f.s.'s.
 modprobe nls_iso8859-1 # "
 modprobe fuse
 modprobe $LAYERFS #unionfs or aufs.
 modprobe squashfs
 #we can determine ide/sata drives at this point (drivers builtin to kernel)...
 #ATADRIVES="`ls -1 /sys/block | grep '^sd' | tr '\n' ' '`"
 #ATADRIVES="`cat /proc/partitions | grep "sd[a-z]$" | tr -s " " | cut -f 5 -d " " | tr "\n" " "`"
 SATADRIVES="`ls -1 /sys/block | grep '^sd' | tr '\n' ' '`"
 for i in $SATADRIVES; do
 LinkTarget=`readlink -f /sys/block/$i`
 if test "`echo $LinkTarget | grep 'usb'`" != ""; then
 USB_SATAD="$USB_SATAD $i"
 else
 BLOCK_SATAD="$BLOCK_SATAD $i"
 fi
 done
 if [ -e /proc/ide ];then
  echo "SATADRIVES='${BLOCK_SATAD}'" >> /etc/rc.d/PUPSTATE #kernel supports /dev/hd*.
 else
  echo "ATADRIVES='${BLOCK_SATAD}'" >> /etc/rc.d/PUPSTATE
 fi
 echo "USB_SATAD='${USB_SATAD}'" >> /etc/rc.d/PUPSTATE
fi

if [ -z "`lsmod | grep 'usb_storage'`" ]; then
modprobe usb_storage
fi

[ -d /proc/acpi ] || modprobe apm #v406

status_func 0
load_average '3xff'
#file_system_state 15
######################LOAD SWAP#####################
[ "$SWAPON" != "yes" ] && loadswap_func

file_system_state 16
#################MISC. SYSTEM SETUP#################
echo "MISC. SYSTEM SETUP"
syslogd -m 0
klogd
syslogd -O /var/log/syslog.7 -l 7 -s 1024 -b 99

echo -e "${DISTRO_NAME} Linux\n`uname -s` `uname -r` [`uname -m` arch]\n\n" > /etc/issue
echo "1" > /proc/sys/net/ipv4/ip_dynaddr
hostname -F /etc/hostname

rm -f /mnt/home
#if [ ! -d /initrd ];then
if [ "`rdev`" ];then
 PUP_HOME='/'
 echo "PUP_HOME='/'" >> /etc/rc.d/PUPSTATE
 ln -s / /mnt/home
else
 if [ "$PUP_HOME" ];then #see /etc/rc.d/PUPSTATE
  if [ "$PUP_HOME" = "/pup_ro1" -o "$PUP_HOME" = "/pup_rw" ];then
   #note, PUPMODE=6 will have PUP_HOME=/pup_rw.
   #in the case of the persistent storage being the partition itself, this will be mounted
   #on /initrd/pup_ro1 (tmpfs on pup_rw for restricted writes) or directly on /initrd/pup_rw
   #and we do not really want users to access it as it is a unionfs layer. Instead, they are
   #already accessing it as "/".
   ln -s / /mnt/home
  else
   ln -s /initrd${PUP_HOME} /mnt/home
  fi
 fi
fi
load_average '4xff'
#file_system_state 17
################WAIT MODULES LOADED##################
echo "WAIT MODULES LOADED"
#previous module loading may not have completed...
echo -n "Waiting for modules to complete loading..." >/dev/console
WAITCNT=0
PCIPCMCIA="`elspci -l | grep -o '060700'`"
PCIUSB="`elspci -l | grep -o -E '0C0300|0C0310|0C0320'`"
if [ "$PCIPCMCIA" != "" ];then #this may be slow to respond.
 echo -n " pcmcia"  >/dev/console
 while [ $WAITCNT -lt 10 ];do
  [ "`lsmod | grep -E '^yenta_socket |^tcic |^i82092 |^i82365 |^pd6729 '`" != "" ] && break
  WAITCNT=`expr $WAITCNT + 1`
  sleep 1
  echo -n " $WAITCNT" >/dev/console
 done
fi
#note, if initrd then usb-storage will have already loaded...
if [ "$PCIUSB" != "" ];then #this may be slow to respond.
 echo -n " usb"  >/dev/console
 PCIUSBNUM=`echo "$PCIUSB" | sort -u | wc -l`
 while [ $WAITCNT -lt 10 ];do
  [ `lsmod | grep -o -E '^uhci_hcd|^ohci_hcd|^ehci_hcd' | wc -l` -ge $PCIUSBNUM ] && break
  WAITCNT=`expr $WAITCNT + 1`
  sleep 1
  echo -n " $WAITCNT" >/dev/console
 done
fi

#replay uevents from /sys (more interfaces as a consequence of above drivers loaded)...
#note, this also a workaround for kernel 'bug' where entries appear in /sys but no uevent
#gets generated (yes it happens in 2.6.25.x kernel!)

if [ $KERNMAJ -lt 24 ];then #v431
 [ -e /sys/bus/pcmcia/devices ] && NEWPCMCIA="`ls /sys/bus/pcmcia/devices/*/modalias | tr '\n' ' '`"
 [ -e /sys/bus/usb/devices ] && NEWUSB="`ls /sys/bus/usb/devices/*/modalias | tr '\n' ' '`"
 echo KERNELMAJ=$KERNMAJ >> /tmp/bootmodules.txt
 for ONEMODALIAS in ${NEWPCMCIA}${NEWUSB}
 do
  ONEPATH="`dirname $ONEMODALIAS`"
  if [ -e ${ONEPATH}/uevent ];then
   echo 'added '"${ONEPATH}" >> /tmp/bootmodules.txt
   echo add > ${ONEPATH}/uevent #generates an 'add' uevent.
   sleep 0.02
  fi
 done
else
echo KERNELMAJ=$KERNMAJ >> /tmp/bootmodules.txt
 #v424 try it a different way, this also fixes ssb devices (such as b43.ko)...
 [ -e /sys/bus/pcmcia/devices ] && NEWPCMCIA="`ls /sys/bus/pcmcia/devices/*/uevent 2>/dev/null | tr '\n' ' '`"
 [ -e /sys/bus/usb/devices ] && NEWUSB="`ls /sys/bus/usb/devices/*/uevent 2>/dev/null | tr '\n' ' '`"
 [ -e /sys/bus/ssb/devices ] && NEWSSB="`ls /sys/bus/ssb/devices/*/uevent 2>/dev/null | tr '\n' ' '`"
 for ONEUEVENT in ${NEWPCMCIA}${NEWUSB}${NEWSSB}
 do
  ONEPATH="`dirname $ONEUEVENT`"
  #the check for 'modalias' file is maybe needed for old kernel?...
  [ ! -e ${ONEPATH}/modalias ] && [ "`grep 'MODALIAS' $ONEUEVENT`" = "" ] && continue
  echo 'added '"${ONEUEVENT}" >> /tmp/bootmodules.txt
  echo add > $ONEUEVENT
  sleep 0.02
 done
fi

#wait for usb-storage drives to become available...(already done if initrd)
#note, pup_event_backend_d and udevd both log to this file when load modules
# (the latter via udev handler script /sbin/pup_event_backend_modprobe)...
if [ "`grep 'usb_storage' /tmp/pup_event_module_devpath_log`" != "" ];then #see pup_event_backend_d
 echo -n " usb-storage"  >/dev/console
 while [ $WAITCNT -lt 15 ];do
  [ "`dmesg | grep 'usb-storage: device scan complete'`" != "" ] && break
  sleep 1
  WAITCNT=`expr $WAITCNT + 1`
  echo -n " $WAITCNT" >/dev/console
 done
 #precaution, make sure have got them all... v412 need sort -u...
 USBSTORAGES=`/bin/dmesg | grep "usb-storage: device found at" | sort -u | wc -l`
 while [ $WAITCNT -lt 15 ];do
  AVAILABLEUSBSTORAGES=`/bin/dmesg | grep "usb-storage: device scan complete" | wc -l`
  [ $AVAILABLEUSBSTORAGES -ge $USBSTORAGES ] && break
  sleep 1
  WAITCNT=`expr $WAITCNT + 1`
  echo -n " $WAITCNT" >/dev/console
 done
fi

sleep 1 #v411 a bit extra. rerwin reports usb mouse detection problem some hardware.
        #(delay before usb mouse info appears in /proc/bus/input/devices)

status_func 0
load_average '5xff'
#file_system_state 18
##############USER SELECTED MODULES##################
echo "USER SELECTED MODULES"
#the user can select extra modules to load in the BootManager...
if [ "$ADDLIST" != "" ];then #variable is in /etc/rc.d/MODULESCONFIG
 echo -n "Loading user-selected modules..." >/dev/console
 for MODULE in $ADDLIST
 do
  MPARAMS=""
  if [ `echo -n "$MODULE" | tr ':' ' ' | wc -w` -gt 1 ];then
   MPARAMS="`echo -n "$MODULE" | cut -f 2-9 -d ':' | tr ':' ' '`"
   MODULE="`echo -n "$MODULE" | cut -f 1 -d ':'`"
  fi
  MODULE=`echo "$MODULE" | tr '-' '_'`
  echo -n " $MODULE" >/dev/console
  echo "Loading module $MODULE $MPARAMS"
  firmware_module_func #install firmware tarball. see functions4puppy4.
  #w463 for mwave.ko (modem), do not load module, just the firmware, which has script that correctly loads mwave.ko.
  #if [ -z "`lsmod | grep "$MODULE"`" ] ; then
  [ "$MODULE" != "mwave" ] && modprobe $MODULE $MPARAMS
  #fi
 done
 status_func 0
fi

fbcon_func() {
if [ -n "`modprobe -l | grep 'fbcon'`" ]; then
if [ "`cat /proc/cmdline | grep -E 'vga=ask|vga=0x3[0-9a-fA-F][0-9a-fA-F]|vga=[7-8][0-9][0-9]'`" != "" ]; then
if [ ! "`grep 'fbcon' /tmp/pup_event_modprobe.conf |grep -vEe '^#|^[[:blank:]]*#' |tail -n1 |grep 'blacklist'`" ];then
if [ ! "$NO_FBCON" ];then
echo >> /dev/console
modinfo fbcon > /dev/console
sleep 1
modprobe fbcon
fi;fi;fi ##+++2012-01-11 added check for blacklisting above
fi
}
fbcon_func
load_average '6xff'
##file_system_state 19
###################SETUP SERVICES################
echo "SETUP SERVICES"
echo -n "Setting up services (network, printing, etc.)..." >/dev/console
if [ -h /dev/modem ];then
 DEVM="`readlink /dev/modem`"
 case $DEVM in
  modem) #error, circular link.
   rm -f /dev/modem
   DEVM=""
  ;;
  /dev/*) #wrong format.
   DEVM="`echo -n "$DEVM" | cut -f 3,4 -d '/'`"
   ln -snf $DEVM /dev/modem
  ;;
 esac
 case $DEVM in
  ttyS[0-9]) #apparently setserial can crash with other modems.
   setserial -v -b /dev/modem auto_irq skip_test autoconfig
  ;;
 esac
fi

#had hoped to retire this, but HardInfo needs it...
[ "`lsmod | grep '^usbcore'`" != "" ] && busybox mount -t usbfs none /proc/bus/usb

#v408 only needed for 2.6.21.7, as 2.6.25.x loads these automatically...
#v408 kirk: Check for laptop battery...
modprobe battery
#if [ -d /proc/acpi/battery ]; then
 results="`find /proc/acpi/battery -mindepth 1 -type d`"
# if [ ! -z "$results" ]; then
  modprobe ac
#  modprobe thermal
  modprobe fan
# else
#  rmmod battery
# fi
#fi

#v411 can use old network wizard (from 403, based on 400)...
CHECKOLDWIZ="`ls -1 /etc/*[0-9]mode 2>/dev/null`" #ex: eth0mode, wlan0mode.
if [ "$CHECKOLDWIZ" != "" -a -d /usr/local/net_setup ];then
 #note, old wizard is located in /usr/local/net_setup.
 /usr/local/net_setup/etc/rc.d/rc.network &
else
 /etc/rc.d/rc.network &
fi

/etc/rc.d/rc.services & #run scripts in /etc/rc.d/init.d

echo -e "\\033[62G\\033[1;33m[backgrounded]\\033[0;39m" >/dev/console #column 62, yellow.
load_average '7xff'
#file_system_state 20
############RECOGNISE MEDIA DEVICES################
echo "RECOGNISE MEDIA DEVICES"
echo -n "Recognising media devices..." >/dev/console
#recognise optical drives...
echo -n ' optical' >/dev/console
OPTCNT=1;CDTYPE="";DVDTYPE="";CDBURNERTYPE=""
OPTICALS="`grep '^drive name:' /proc/sys/dev/cdrom/info | grep -o -E 'sr.*|hd.*' | tr '\t' ' '`"
[ -L /dev/cdrom ] && CDTYPE="`readlink /dev/cdrom | cut -f 3 -d '/'`"
[ -L /dev/dvd ] && DVDTYPE="`readlink /dev/dvd | cut -f 3 -d '/'`"
[ -f /etc/cdburnerdevice ] && CDBURNERTYPE="`cat /etc/cdburnerdevice`"
[ "`echo "$OPTICALS" | grep "$CDTYPE"`" = "" ] && CDTYPE="" #no longer exists.
[ "`echo "$OPTICALS" | grep "$DVDTYPE"`" = "" ] && DVDTYPE="" #no longer exists.
[ "`echo "$OPTICALS" | grep "$CDBURNERTYPE"`" = "" ] && CDBURNERTYPE="" #no longer exists.
for ONEOPTICAL in $OPTICALS
do
 ONENUM="`echo -n "$ONEOPTICAL" | cut -c 3`"
 [ "$CDTYPE" = "" ] && CDTYPE="$ONEOPTICAL"
 [ "$DVDTYPE" = "" ] && [ "`grep '^Can read DVD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01]' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && DVDTYPE="$ONEOPTICAL"
 [ "$CDBURNERTYPE" = "" ] && [ "`grep '^Can write CD' /proc/sys/dev/cdrom/info | head -n 1 | grep -o '[01]' | sed -e 's/[^01]//g' | cut -c $OPTCNT`" = "1" ] && CDBURNERTYPE="$ONEOPTICAL"
 OPTCNT=`expr $OPTCNT + 1`
done
rm -f /dev/cdrom; rm -f /dev/dvd; rm -f /etc/cdburnerdevice
[ "$CDTYPE" ] && ln -sf /dev/$CDTYPE /dev/cdrom
[ "$DVDTYPE" ] && ln -sf /dev/$DVDTYPE /dev/dvd
[ "$CDBURNERTYPE" ] && echo -n "$CDBURNERTYPE" > /etc/cdburnerdevice
[ "$DVDTYPE" ] && hdparm -d1 /dev/$DVDTYPE >/dev/null 2>&1

#w468 simplify...
##w463 i think time has come to dump the old 'psaux'. use /dev/input/mice for both usb
##and ps/2 mice...
##recognise mouse... v411...
##note, if wanted to detect serial mouse here, k2.6.25.16 has module 'sermouse' that must be loaded (currently in xwin).

#TODO: simplify above, use 'input/mice' for ps2 mouse also, but may need to modify Xorg/Xvesa/Input Wizards.
#      (may also have to remove builtin psaux driver from kernel).
if [ -f /etc/mousedevice ];then
 [ "`cat /etc/mousedevice`" = "psaux" ] && echo -n "input/mice" > /etc/mousedevice
else
 echo -n "input/mice" > /etc/mousedevice
 ln -snf input/mice /dev/mouse
fi

#recognise keyboard...
#echo -n ' keyboard' >/dev/console
/etc/rc.d/rc.country ;STATUS=$(( $STATUS + $? )) #this asks for keyboard layout.

status_func $STATUS
load_average '8xff'
#file_system_state 21
############MISC DESKTOP STUFF##################
echo "MISC. DESKTOP STUFF"
if [ "$PUPMODE" = "77" ];then #77=multisession cd/dvd.
 if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep "savesession"`" = "" ];then
  echo '<icon x="768" y="128" label="save">/usr/sbin/savesession-dvd</icon>' >> /root/Choices/ROX-Filer/PuppyPin
  cat /root/Choices/ROX-Filer/PuppyPin | grep -v '/pinboard' > /tmp/PuppyPin-CPY
  sync
  cp -f /tmp/PuppyPin-CPY /root/Choices/ROX-Filer/PuppyPin
  echo '</pinboard>' >> /root/Choices/ROX-Filer/PuppyPin
 fi
fi

#save button on desktop when booted from flash drive...
if [ $PUPMODE -eq 3 -o $PUPMODE -eq 7 -o $PUPMODE -eq 13 ];then #pup_rw is tmpfs. frugal flash to part internal, *external, save-file external
 if [ "`cat /root/Choices/ROX-Filer/PuppyPin | grep "save2flash"`" = "" ];then
  echo '<icon x="768" y="128" label="save">/usr/sbin/save2flash</icon>' >> /root/Choices/ROX-Filer/PuppyPin
  cat /root/Choices/ROX-Filer/PuppyPin | grep -v '/pinboard' > /tmp/PuppyPin-CPY
  sync
  cp -f /tmp/PuppyPin-CPY /root/Choices/ROX-Filer/PuppyPin
  echo '</pinboard>' >> /root/Choices/ROX-Filer/PuppyPin
 fi
fi

#file_system_state 22
###################PERSONAL BOOT SCRIPT######################
echo "PERSONAL BOOT SCRIPT"
#personal boot script here...
if [ -f /etc/rc.d/rc.local ];then
 :
else
 echo '#this file called from rc.sysinit' > /etc/rc.d/rc.local
 echo '#you can edit this file' >> /etc/rc.d/rc.local
 echo '#When firewall is installed, will append lines to this file...' >> /etc/rc.d/rc.local
fi
. /etc/rc.d/rc.local
###################PERSONAL BOOT SCRIPT######################

dmesg > /tmp/bootkernel.log
load_average '9xff'
###NOX SUPPORT###
if [ ! -f /tmp/X.status ];then
#Xvesa does not work anymore ..?
if [ "`basename $(readlink -e $(which X))`" != "Xorg" ]; then ##+++2012-05-02 changed readlik -f to -e
echo 'nox' > /tmp/X.status
elif [ -n "`cat /proc/cmdline | grep -i 'nox'`" ]; then
echo 'nox' > /tmp/X.status
else
echo 'X' > /tmp/X.status
fi;fi
###NOX SUPPORT###

### FSCKME ###
if [[ $PUPMODE == 2 ]] ; then
RD=`basename $(rdev | cut -f 1 -d ' ') 2>/dev/null`
FS=`mount | grep '^/dev/root' | cut -f 5 -d ' '`
echo "$RD"','"$FS"',' > /etc/.fsckme.flg
echo "PDEV1='$RD'" >> /etc/rc.d/PUPSTATE
fi
### FSCKME ###

### MKNODs ###
[ -c /dev/ppp ] || mknod /dev/ppp c 108 0
[ -L /dev/mouse ] || ln -s /dev/input/mice /dev/mouse
[ -c /dev/mem ] || mknod /dev/mem c 1 1
[ -L /dev/modem ] || { MODEM=`dmesg | grep -i 'MODEM' |grep 'attached' |head -n1 |rev |awk '{print $1}' |rev`;[ "$MODEM" ] && ln -s $MODEM /dev/modem; }
### MKNODs ###

#file_system_state 23

### sort logs ###
pup_eve_bac_mod_func(){
FILE='/tmp/pup_eve_bac_mod.log'
[ -f "$FILE" ] || FILE='/tmp/pup_event_backend_modprobe.log'
while [ "`pidof rc.services`" -o "`pidof pup_event_backend_modprobe`" ];do sleep 2;done
sleep 5s  ## 120s ##5s
echo 'Sorting now this log file by '$0 >> $FILE
cat $FILE | sort -g -k 1,3 -t ' ' >$FILE.sorted
PIDS=`cat $FILE.sorted | cut -f 1 -d ' ' | sort -u | sort -g`
for i in $PIDS ; do
#echo PID  "$i"
Line=`grep -n -w "^$i" $FILE.sorted | tail -n 1 | cut -f 1 -d ':'`
#echo Line "$Line"
sed -i "$Line a\ " $FILE.sorted
done
}
pup_eve_bac_mod_func &
### sort logs ###

### capture bootscreen ###
[ -e /dev/vcs1 ] || { mknod /dev/vcs1 c 7 1;sleep 1; }
cat /dev/vcs1 >/tmp/vcs1.txt
echo -e "\n\n" >>/tmp/vcs1.txt
echo -e "`cat /tmp/vcs1.txt |sed -e 's,\(.\{80\}\),\1\\n,g'`" >>/tmp/vcs1.txt
### capture bootscreen ###

load_average 'FxFF'

#that's it. next stop is /etc/profile...
###END###
You mean dis ?

espertalhao04
Posts: 70
Joined: Sat 12 May 2012, 00:49

#40 Post by espertalhao04 »

exactly, that is the script file...
if you read, from the end of the initial load of comments, you will see another comments saying what for is the script...
that is another script you might want to change, but be careful:
you don't do it on your own system file!!!
you can extract the content from the sfs file to a folder (click on the file, and it is mounted...
then you copy ALL the files from it to another place (it must be a ext* (2,3 or 4) partition)...
then you edit the file /etc/rc.d/rc.sysinit (the / is being count as the dir where you put all the files)...
use the command "dir2sfs" and then wait...
create a new iso, (using iso isomaster), with base of your original iso file, and save with A DIFFERENT NAME!
then you get qemu-puppy, and edit the puppy.sh file, to be runned using the new iso file...
open the script and you have in there a way to test it without reboot...
any questions, just ask...
asus a6000: intel m 1.6ghz, 2gb ram ddr, no hdd, usb 2.0 pendrive running puppy linux 4.3.1

Post Reply