Tiny Core Base > Micro Core

Adding dynamic TC Autorun feature

(1/3) > >>

AlejandroPadrino:
Hello to all,

related to this post http://forum.tinycorelinux.net/index.php/topic,26314.0.html, I made a autorun script feature for TC.  You can use it in your own way.

The script is useful for finding and loading .TCZ extensions across many device and folder locations, and only takes like valid location the last device and folder found.  In this script, all the specified devices are mounted, and same devices are dismounted if specified file was not found.  If the specified file is found in any specified folder, the device remains mounted after TC finished the boot process.  Code may be located in /opt/bootlocal.sh file and, if you want to load a .TCZ extension after, you can take the sample script opera12.sh file to modify as you like.

Code to add in /opt/bootlocal.sh file:

--- Code: ---# PsaCrypt AutoRun.Sh checking.
echo "${RED}Mounting TCE FileSystems ...${NORMAL}";
 tceAutoRun=;
 tceFolder=;
 tceFile=autorun.sh;

for zb00 in "hdd5" "hdd4" "hdd3" "hdd2" "hdd1" "hdc5" "hdc4" "hdc3" "hdc2" "hdc1" "hdb5" "hdb4" "hdb3" "hdb2" "hdb1" "hda5" "hda4" "hda3" "hda2" "hda1" "sdd5" "sdd4" "sdd3" "sdd2" "sdd1" "sdc5" "sdc4" "sdc3" "sdc2" "sdc1" "sdb5" "sdb4" "sdb3" "sdb2" "sdb1" "sda5" "sda4" "sda3" "sda2" "sda1";
do
 tmpDev=;
 tmpFolder=;
 sudo mount -w /dev/$zb00;

for zb01 in "cde" "tc" "tce" "TinyCoreLinux";
do
 if [ -f /mnt/$zb00/$zb01/$tceFile ]; then tmpFolder=/mnt/$zb00/$zb01; tmpDev=/mnt/$zb00/$zb01/$tceFile ; fi;
done;

 if [ -n "$tmpDev" ]; then tceFolder=$tmpFolder; tceAutoRun=$tmpDev ; echo $tmpDev ; fi;
 if [ ! -n "$tmpDev" ]; then sudo umount -f -r /dev/$zb00 ; fi;
done;

for zb00 in "sr3" "sr2" "sr1" "sr0";
do
 tmpDev=;
 tmpFolder=;
 sudo mount -r /dev/$zb00;

for zb01 in "cde" "tc" "tce" "TinyCoreLinux";
do
 if [ -f /mnt/$zb00/$zb01/$tceFile ]; then tmpFolder=/mnt/$zb00/$zb01; tmpDev=/mnt/$zb00/$zb01/$tceFile ; fi;
done;

 if [ -n "$tmpDev" ]; then tceFolder=$tmpFolder; tceAutoRun=$tmpDev ; echo $tmpDev ; fi;
 if [ ! -n "$tmpDev" ]; then sudo umount -f -r /dev/$zb00 ; fi;
done;

# Execute tceAutoRun file.
export tceAutoRun tceFolder;
if [ -f "$tceAutoRun" ]; then sudo nohup $tceAutoRun $tceFolder > /dev/null ; fi;
exit;

#end.

--- End code ---

After this code, the file autorun.sh is launched if it was found.  Then I made a custom .TCZ package, loaded in autorun.sh file, to load the script launchers (like opera12.sh sample) into TC filesystem, to call these launchers from console or another script file.

Sample loader for .TCZ extensions (opera12.sh):

--- Code: ---#!/bin/sh
# PsaCrypt loader for Opera 12 Web Browser.

echo "${RED}Finding for .TCZ Files ...${NORMAL}";
 tceFolder=;
 tceFile=opera-12.tcz;

for zb00 in "hdd5" "hdd4" "hdd3" "hdd2" "hdd1" "hdc5" "hdc4" "hdc3" "hdc2" "hdc1" "hdb5" "hdb4" "hdb3" "hdb2" "hdb1" "hda5" "hda4" "hda3" "hda2" "hda1" "sdd5" "sdd4" "sdd3" "sdd2" "sdd1" "sdc5" "sdc4" "sdc3" "sdc2" "sdc1" "sdb5" "sdb4" "sdb3" "sdb2" "sdb1" "sda5" "sda4" "sda3" "sda2" "sda1";
do
 tmpFolder=;

for zb01 in "cde" "tc" "tce" "TinyCoreLinux";
do
 if [ -f /mnt/$zb00/$zb01/tce-autoload/$tceFile ]; then tmpFolder=/mnt/$zb00/$zb01/tce-autoload ; fi;
done;

 if [ -n "$tmpFolder" ]; then tceFolder=$tmpFolder; echo Folder: $tmpFolder ; fi;
done;

for zb00 in "sr3" "sr2" "sr1" "sr0";
do
 tmpFolder=;

for zb01 in "cde" "tc" "tce" "TinyCoreLinux";
do
 if [ -f /mnt/$zb00/$zb01/tce-autoload/$tceFile ]; then tmpFolder=/mnt/$zb00/$zb01/tce-autoload ; fi;
done;

 if [ -n "$tmpFolder" ]; then tceFolder=$tmpFolder; echo Folder: $tmpFolder ; fi;
done;

# Execute loader file.
if [ -f "$tceFolder/$tceFile" ]; then su tc -c "chdir $tceFolder/ && tce-load -i $tceFolder/$tceFile && echo Done."; fi;
if [ ! -f "$tceFolder/$tceFile" ]; then echo Error: Opera .TCZ files not found.; fi;
exit;

#end.

--- End code ---

Take note that you must use this scripts with warning because /opt/bootlocal.sh file is launched as root user.

Enjoy.   ;-)

jazzbiker:
Hi AlejandroPadrino,

Nice that You share Your improvements for TinyCore!
Sorry, I am too dumb and can't understand what are the advantages of Your approach against f.e. onboot.lst (my_special.lst, ... )? Where the dependences will be looked for? Of course You may answer that the script is on my screen and I can grok it by myself, but I will be grateful for help.

Thanks in advance.

AlejandroPadrino:
Since I know TinyCore Linux (TC4), I found some problems in onboot.lst feature when loading TC from DVD.  I remastered the core, but it haves a limitation near 341mb.  Growing my few knowledge in Linux scripting I found this way to build a better TC working for me.

The script works locating all devices and folders specified finding for a file.  If the file is found, the device who contains the file remains mounted after TC boot.  If you compare code in /opt/bootlocal.sh and opera12.sh, you can see the same code structure, but in opera12.sh launcher there is no mount/umount commands.

To load extension dependencies, it was automatically, same as onboot.lst file.  You simply must copy .TCZ extensions and dependencies into the right folder specified to tce-load command.  Do you understand now?

Best.  :-)

jazzbiker:
Thanks for explanations!

But I still have questions ( Isn't it too boring?
1) This is TC4 specific issue?
2) It is necessary for loading from DVD only (I use USB flash drives)?
3) The size limitation of 341 MB? Never knew about it. What is the cause of this limit?

Have a nice Core!

Rich:
Hi jazzbiker

--- Quote from: AlejandroPadrino on July 14, 2023, 05:16:44 AM --- ... I remastered the core, but it haves a limitation near 341mb. ...
--- End quote ---

--- Quote from: jazzbiker on July 14, 2023, 11:25:41 AM --- ... 3) The size limitation of 341 MB? Never knew about it. What is the cause of this limit?
--- End quote ---
As far as I know, there is no limit on the size of the initrd (core.gz) per se.
However, the initrd contains the root filesystem (compressed) which gets
unpacked/uncompressed and resides in RAM:
http://distro.ibiblio.org/tinycorelinux/architecture.html
So depending on how much RAM you have, and how much you add to the
initrd, you may find yourself running short on RAM.

Searching for  maximum initrd size  will return some sites suggesting a limit
on the maximum address in RAM a bootloader will write to exists.

Navigation

[0] Message Index

[#] Next page

Go to full version