As some folks have boxes that are wireless only or require funky firmware to reach the network, they may need a basic set of extensions installed before they are able to configure a network connection with the standard TC iso boot so as to allow appbrowser access. So here is a script that allows the easy setting up of a tce directory from within another running distro that is network enabled.
The script is to be run without arguments. Asks for 3 things. It prompts for a desired mounted partition where the tce directory will be created. Then you specify for either 32 or 64 bit Tinycore. And then prompts for an extension to download, which will download the extension plus dependencies, entering the main extension into the onboot.lst file, and then prompting if another extension download is desired. It stays simple, sticks with the name tce for the tce directory, and onboot.lst is populated to boot the selections and their deps. Once booted into the perhaps graphical TC with extensions and then a network connection established, the standard TC tools are to be used to manage the tce directory installation.
This script simply requires that GNU wget is installed.
EDIT: Removed use of zsync as Debian stable's version is too old to work with our zsync files.
But do not use it on a running tce directory that is in use.
Example use, answers are in bold:
-----------------------
(Make sure and run as root)
root@box:# ./filltcedir
Enter mounted partition you would like your tce directory to reside on. Example: /mnt/hda2 /mnt/hdb1
Enter the name of the extension you would like to download the your tce directory, deps will be included. file.tcz
Fetching file.tcz...
Would you like to fetch more extensions? n
root@box:#
--------------------------
Script:
#!/bin/sh
[ -f /tmp/.TCEDIR ] && rm /tmp/.TCEDIR
if uname -a | grep "Cygwin" > /dev/null 2>&1; then
export PATH=$PATH:/cygdrive/c/Program\ Files/GnuWin32/bin/
fi
MIRROR="http://distro.ibiblio.org/pub/linux/distributions/tinycorelinux"
readpartition() {
if [ ! -f /tmp/.TCEDIR ]; then
echo " "
read -p "Enter mounted partition you would like your tce directory to \
reside on. Example: / for the mounted root directory, or /mnt/hda2 for hda2: " PARTITION
if [ -z "$PARTITION" ]; then
echo " "
echo "Enter a partition mount."
readpartition
fi
if ! uname -a | grep "Cygwin" > /dev/null 2>&1; then
if ! mount | grep -w "$PARTITION" > /dev/null 2>&1; then
echo " "
echo "Partition is not mounted, try another one."
readpartition
fi
fi
if [ ! -d "$PARTITION" ]; then
echo " "
echo "Partition mount point directory does not exist, try another one."
readpartition
fi
echo "$PARTITION" > /tmp/.TCEDIR
fi
}
PARTITION=`cat /tmp/.TCEDIR`
mkstructure() {
[ -d "$PARTITION"/tce ] || mkdir -p "$PARTITION"/tce
[ -d "$PARTITION"/tce/optional ] || mkdir -p "$PARTITION"/tce/optional
cd "$PARTITION"/tce/optional
if [ $(basename `pwd`) == "optional" ]; then
[ -f ../onboot.lst ] || touch ../onboot.lst
else
echo "Something went wrong."
exit 1
fi
}
recursive_fetch() {
KVER=`cat /tmp/.KVER`
echo ${1} >> /tmp/.recdepfilelist
[ -f "$1".dep ] && rm "$1".dep
wget -q "$MIRROR"/3.x/tcz/"$1".dep . > /dev/null 2>&1
[ -f "$1".dep ] && sed -i "s:KERNEL:$KVER:g" "$1".dep
deps=""
if [ -f ${1}.dep ]; then
deps=`cat ${1}.dep`
for d in $deps; do
grep -x "$d" /tmp/.recdepfilelist >/dev/null || recursive_fetch "$d"
done
fi
}
fetchnew() {
echo " "
rm -f "$I"
rm -f "$I".md5.txt
echo "Fetching "$I"..."
wget -q "$MIRROR"/3.x/tcz/"$I" || echo "Encountered issues downloading "$I", please try again later."
wget -q "$MIRROR"/3.x/tcz/"$I".md5.txt || echo "Encountered issues downloading "$I", please try again later."
echo "MD5SUM check: `md5sum -c "$I".md5.txt`"
echo " "
}
fetchversion() {
if [ ! -f /tmp/.KVER ]; then
while true; do
echo " "
read -p "Specify the kernel version of Tinycore extensions you will be using. Enter 32 for the standard \
32 bit version or enter 64 for the 64 bit version " MYVERSION
case $MYVERSION in
64) echo "2.6.33.3-tinycore64" > /tmp/.KVER; break;;
32) echo "2.6.33.3-tinycore" > /tmp/.KVER; break;;
* ) echo " "; echo "Please answer 32 or 64."; echo " ";;
esac
done
fi
}
fetch() {
while true; do
[ -f /tmp/.recdepfilelist ] && rm /tmp/.recdepfilelist
echo " "
read -p "Enter the name of the extension you would like to download the your tce directory, deps will be included. " MYEXTENSION
if [ -z "$MYEXTENSION" ]; then
echo " "
fetch
fi
if wget --spider "$MIRROR"/3.x/tcz/"$MYEXTENSION" > /dev/null 2>&1; then
recursive_fetch "$MYEXTENSION"
echo " "
grep "$MYEXTENSION" ../onboot.lst > /dev/null 2>&1 || echo "$MYEXTENSION" >> ../onboot.lst
for I in `cat /tmp/.recdepfilelist`; do
if [ -f "$I" ] && [ ! -f "$I".md5.txt ]; then
while true; do
read -p ""$I" has no md5.txt file. \
Enter yes to fetch a known good extension file from the repo, and no to \
keep the current one at your own risk. " yn
case $yn in
[Yy]* ) fetchnew; break;;
[Nn]* ) echo " "; break;;
* ) echo " "; echo "Please answer yes or no."; echo " ";;
esac
done
fi
if [ -f "$I" ] && [ -f "$I".md5.txt ]; then
if md5sum -c "$I".md5.txt > /dev/null 2>&1; then
wget -q -O ."$I".md5.txt "$MIRROR"/3.x/tcz/"$I".md5.txt
if md5sum -c ."$I".md5.txt > /dev/null 2>&1; then
echo ""$I" is already downloaded."
echo "MD5SUM check: `md5sum -c "$I".md5.txt`"
echo " "
else
while true; do
read -p "It appears there is a newer version of "$I" in the repo. \
Enter yes to fetch the newer version, and no to keep the current one. " yn
case $yn in
[Yy]* ) fetchnew; break;;
[Nn]* ) echo " "; break;;
* ) echo " "; echo "Please answer yes or no."; echo " ";;
esac
done
fi
rm ."$I".md5.txt
else
while true; do
read -p "It appears "$I" is a corrupt extension file due to md5 mismatch. \
Enter yes to fetch the current known good version from the repo, and no to keep the current one if you believe \
the extension is good but an md5sum was created with error. Answering no will delete the bad md5.txt file and keep \
the .tcz extension. " yn
case $yn in
[Yy]* ) fetchnew; break;;
[Nn]* ) rm "$I".md5.txt; echo " "; break;;
* ) echo " "; echo "Please answer yes or no."; echo " ";;
esac
done
fi
fi
if [ ! -f "$I" ]; then
fetchnew
fi
done
else
echo " "
echo ""$MYEXTENSION" does not exist as an extension in the repo, try again."
echo " "
fi
while true; do
read -p "Would you like to fetch more extensions? " yn
case $yn in
[Yy]* ) fetch; echo " ";;
[Nn]* ) exit 1;;
* ) echo " "; echo "Please answer yes or no."; echo " ";;
esac
done
done
}
if ! wget --version > /dev/null 2>&1; then
echo "Please install GNU wget, or in the case of Cygwin, make sure it is in your path."
exit 1
fi
readpartition
mkstructure
fetchversion
fetch
chgrp -R staff "$PARTITION"/tce
chmod -R g+w "$PARTITION"/tce