Tiny Core Linux
General TC => Programming & Scripting - Unofficial => Topic started by: jpeters on October 14, 2009, 04:59:17 AM
-
Loads extension list, "load.grp" in tce dir when "base" boot option is used.
Changes /opt/tce.dir path from /tmp to tce dir. (edit TCEPATH & sed )
Place script in /opt/bootlocal.sh to automatically load list when base option is used.
note: a script to add/remove the "base" option in /menu.list makes this all very fast
EDIT: I replaced this approach with symlinked groups documented later in this thread.
#!/bin/ash
###### load-grp script, jpeters
#
#### Loads extension group "load.grp" in tce dir.
#
#
### Edit path to default tce directory
TCEPATH="/mnt/hda1/tcZ2"
#### Change path to tce dir when loading BASE option
TCEDIR="$(cat /opt/.tce_dir)"
if [ $TCEDIR == "/tmp/tce/" ]; then
if [ -f ${TCEPATH}/load.grp ]; then
sed -i 's@/tmp/tce@/mnt/hda1/tcZ2@' /opt/.tce_dir
TCEDIR="$(cat /opt/.tce_dir)"
fi
cd ${TCEDIR}
######### Load default extensions
if [ -f load.grp ]; then
FILES="$(cat ./load.grp)"
echo "installing load.grp extensions.........."
for I in ${FILES}
do
tce-load -i ${I}
done
fi
fi
exit 0
"load" script for additional extensions as needed from tce dir. eg, "load gnumeric"
#!/bin/ash
TCEDIR="$(cat /opt/.tce_dir)"
cd ${TCEDIR}
if [ ! -f ${1}*.tcz -a ! -f ${1}*.tczl -a ! -f ${1}*.tczm ] ; then
echo "extention not present"
exit 1
fi
FILE="$(find ${1}* | busybox grep -v .dep | busybox grep -v .txt | busybox grep -v .list )"
[ -n ${FILE} ] && tce-load -i ${FILE}
echo "done!"
exit 0
Sample "base" script for adding/removing bootoption. (edit path and sed search words to suit).
#!/bin/ash
### Adds/Removes "base" bootoption
MENUPATH=/mnt/hda1/boot/grub
cd ${MENUPATH}
#### Show Bootoptions
echo "bootoptions: "
busybox grep -e "showapps" menu.lst
#### Prompt to add/remove "base"
echo ""
echo "Add/Remove 'base' (a/r)"
read RESPONSE
case ${RESPONSE} in
"a" ) sudo sed -i 's/showapps/showapps base/' ./menu.lst ;;
"r" ) sudo sed -i 's/showapps base/showapps/' ./menu.lst ;;
esac
exit 0
-
Edited load script to accommodate .list files in tce dir
-
If loading a new wm (jwm, etc), or to adjust flwm menus/icons (if loading from /opt/bootlocal):
1. <ctr-alt backspace> to prompt and then "start x"
OR
2. add "text" bootoption. Type "startx" at prompt
OR
3. remaster for secure login ( there's a "noautologin" script). Just login, no startx needed.
-
Traditional Boot option using /tce as database: (loads faster as of ver. 2.5 )
"make-grp" script for creating tce-group folder from the load.grp file (both are within /tce directory.
Bootcode then gets set to /tce/tce-group. "load" script then set to /tce for apps as needed.
note: tce-group consists of symlinks to tce_dir
#!/bin/ash
######## make-grp script #######
#creates /tce/tce-group from load.grp file
#Set path to main /tce dir
TCEDIR="/mnt/hda1/tcZ2/"
##################
cd ${TCEDIR}
if [ -f load.grp ]; then
FILES="$(cat ./load.grp)"
#Make tce-group directory
if [ -d ${TCEDIR}tce-group ]; then
sudo rm ${TCEDIR}tce-group/*
elif [ ! -d ${TCEDIR}tce-group ]; then
sudo mkdir ${TCEDIR}tce-group
fi
for I in ${FILES}
do
sudo ln -s ${TCEDIR}${I}* ${TCEDIR}tce-group 2>/dev/null
if [ -f ${TCEDIR}${I}.dep ]; then
for deps in `cat ${TCEDIR}${I}.dep`
do
sudo ln -s ${TCEDIR}${deps}* ${TCEDIR}tce-group 2>/dev/null
done
fi
done
fi
exit 0
sample menu.list script for loading tce-group: (set paths and sed search)
#!/bin/ash
### Set path:
MENUPATH=/mnt/hda1/boot/grub
###########
cd ${MENUPATH}
#### Show Bootoptions
echo "bootoptions: "
busybox grep -e "showapps" menu.lst
#### Prompt to add/remove "base"
echo ""
echo "Add/Remove 'tce-group' (a/r)"
read RESPONSE
case ${RESPONSE} in
"a" ) sudo sed -i 's@tce=hda1/tcZ2@tce=hda1/tcZ2/tce-group@' ./menu.lst ;;
"r" ) sudo sed -i 's@tce=hda1/tcZ2/tce-group@tce=hda1/tcZ2@' ./menu.lst ;;
esac
exit 0
load script; edit main /tce path to use as database for additional extensions as needed:
ex, "load gnumeric"
#!/bin/ash
## loads extensions into from main /tce directory (when group is loaded).
TCEDIR="/mnt/hda1/tcZ2"
cd ${TCEDIR}
FILE="$(ls | grep -e ${1}\.tcz[ml]*$)"
if [ ! ${FILE} ]; then
echo "extention not present"
exit 1
fi
tce-load -i ${FILE}
echo "done!"
exit 0
-
Since tce-group is just symlinks, I found it useful to keep /opt/.tce_dir listing the base dir so that scripts like "update" work (otherwise updates get installed to the group folder). Issue is solved with a sed script placed in /opt/bootlocal.sh (edit sed search to correct path)
#!/bin/ash
TCEDIR="$(cat /opt/.tce_dir)"
if [ `basename ${TCEDIR}` == "tce-group" ]; then
sed -i 's@/mnt/hda1/tcZ2/tce-group@/mnt/hda1/tcZ2@' /opt/.tce_dir
fi
exit 0
-
updated "load" script to accomodate tczml, tczlm extensions
-
Ah, I see that I have duplicated some of your efforts! I'll read up and try to figure out exactly how yours works.