WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Downloading extensions without appbrowser access.  (Read 11624 times)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Downloading extensions without appbrowser access.
« on: September 12, 2010, 02:10:42 AM »
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:
Code: [Select]
#!/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






  
« Last Edit: November 11, 2010, 01:50:12 AM by Jason W »

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Downloading extensions without appbrowser access.
« Reply #1 on: September 18, 2010, 02:20:00 PM »
Fixed  a critical kernel version bug.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Downloading extensions without appbrowser access.
« Reply #2 on: November 11, 2010, 01:43:41 AM »
There has been some interest in being able to do this from within Windows, so this has been adapted for use with Cygwin running under Windows.   Just install the "full" version of Cygwin to give you all the normal Unix commands.  Also, install Windows version of Wget with the "Install" option so it gets installed to it's normal Windows path.  Then in Firefox, download this script attachment, which will put it in your "Downloads" directory.  Then launch Cygwin from it's desktop icon.  Then use these specific commands if making a tce directory on the main C: drive:

$ chmod +x /cygdrive/c/Documents\ and\ Settings/$USER/My\ Documents/Downloads/filltcedir

$ /cygdrive/c/Documents\ and\ Settings/$USER/My\ Documents/Downloads/filltcedir

Then just answer the questions. 

To use drive C:, enter without quotes "/cygdrive/c" as the mounted partition to place your tce directory on in the first question.


As to the drive letters, I have tested this under my fat32 C: drive, as well as ext2 formatted drives using an ext2 driver.  The ext2 driver I had best use with is this one:  www.ext2fsd.com    Just set it up per instructions to use an ext2 formatted drive or usb key.    If using drive F: for example, then obviously use the letter f instead of c in that first question:  (/cygdrive/f    instead of   /cygdrive/c).

Offline TaoTePuh

  • Full Member
  • ***
  • Posts: 172
Re: Downloading extensions without appbrowser access.
« Reply #3 on: December 18, 2010, 02:57:42 PM »
Quote
This script simply requires that GNU wget is installed.

Note on running the script in TC-Enviroment:

The script requires the extensions for "wget" and "grep" (busybox versions are not enough).

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Downloading extensions without appbrowser access.
« Reply #4 on: December 18, 2010, 08:18:32 PM »
Thanks, worth noting even if the intended use is on a non-TC machine. 

Offline Patatalo

  • Newbie
  • *
  • Posts: 12
Re: Downloading extensions without appbrowser access.
« Reply #5 on: December 21, 2010, 12:42:22 AM »
I go here: http://ftp.vim.org/metalab/distributions/tinycorelinux/3.x/tcz/

download every tcz you want and mount them with "mount file.tcz /mnt -o loop". I think a tcz is a squashfs file.

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Downloading extensions without appbrowser access.
« Reply #6 on: May 23, 2011, 08:19:14 PM »
With the advent of the starter packs that are for gaining network access, this script will now be unmaintained as no longer really needed.

Offline tinypoodle

  • Hero Member
  • *****
  • Posts: 3857
Re: Downloading extensions without appbrowser access.
« Reply #7 on: May 23, 2011, 08:55:47 PM »
With the advent of the starter packs that are for gaining network access, this script will now be unmaintained as no longer really needed.

Hmm, there might still be a potential need in cases where the only way to connect would not be covered by starter pack, e.g. out of kernel or staging wifi, dial-up, cellphone modems.
"Software gets slower faster than hardware gets faster." Niklaus Wirth - A Plea for Lean Software (1995)

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: Downloading extensions without appbrowser access.
« Reply #8 on: May 23, 2011, 09:46:51 PM »
True, and it would be fairly trivial to maintain and keep current.  But I promote the use of the new starter packs above using this script.

If a script is needed to download existing extensions in the repo that will provide for a the ability to set up a connection after those extensions are downloaded and set up in a tce directory, then I am sure those extensions are candidates for inclusion in a starter pack.