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:
# 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.
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):
#!/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.
Take note that you must use this scripts with warning because
/opt/bootlocal.sh file is launched as root user.
Enjoy. ;-)