Tiny Core Linux
		General TC => Programming & Scripting - Unofficial => Topic started by: jpeters on September 22, 2009, 06:47:34 AM
		
			
			- 
				Script for downloading/installing new release; prompts for release or release_candidate. Set path
 for /boot directory at top of script.
 
 note: script is set for tinycore;  edit for microcore.
 
 edit: added view first option if Netrik browser loaded (you can add your own).
 
 edit: Requires wget.tcz
 
 edit: removed extra  "/"  in download path
 
 #!/bin/ash
 BOOTDIR="/mnt/hda3/tinycore2/boot/"
 MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
 
 
 ### Select Release or Release Candidate
 echo "Enter r or c (release or candidate)"
 read RELEASE
 
 case $RELEASE in
 "r" ) FTPDIR="${MIRROR}/release/"  ;;
 "c" ) FTPDIR="${MIRROR}/release_candidates/" ;;
 * ) echo "invalid option" ; exit 1 ;;
 esac
 
 ####### View Directory ######
 if [ `which netrik` ]; then
 netrik  "http://${FTPDIR}"
 echo "continue?  'y' "
 read RESPONSE
 [ ${RESPONSE} == "y" ] || exit 1
 fi
 
 
 
 ####### Download and Check Release #########
 
 [ -e /tmp/download ] || sudo mkdir /tmp/download
 
 
 cd /tmp/download
 sudo wget ftp://${FTPDIR}tinycore*
 
 CHECK="$(md5sum  -c  *.md5.txt)"
 if [ `echo $CHECK | awk '{print $2}'` != "OK" ]; then
 echo "md5 doesn't match"
 exit 1
 fi
 
 ##### Extract #########
 
 [ -e /tmp/extract ] || sudo mkdir /tmp/extract
 
 sudo mount *.iso  /tmp/extract -o loop,ro
 
 
 ######### Backup present release
 
 cd ${BOOTDIR}
 [ -e tinycore.gz ] && sudo mv tinycore.gz  tinycore.gz.old
 
 ########### Copy new release to boot dirctory #######
 
 sudo cp /tmp/extract/boot/tinycore.gz ${BOOTDIR}
 
 ############  Cleanup ##########
 sudo  umount /tmp/extract
 sudo  rmdir /tmp/extract
 sudo rm -R /tmp/download
 
 echo "Done!"
 
 exit 0
 
 
- 
				I think your version requires the wget extension.
 I modified your version:#!/bin/sh
 
 #### upgrade tc, jpeters
 ###modified by jls_legalize
 #### version 0.3
 ###first argument: release numeber
 ###second argument boot dir
 ###third argument (optional) 2nd boot dir
 
 if [ ! -n "$2" ]; then
 echo "Usage: tc-upgrade release_numb dir1 [dir2]"
 echo "Example: tc-upgrade 2.4rc1 /mnt/hda4/boot"
 echo "Example: tc-upgrade 2.4rc1 /mnt/hda4/boot /mnt/sda1/boot"
 exit 1
 fi
 ######## Set Path to tinycore.gz  ##########
 MIRROR="$(awk '/Mirror/ {print $2}' /opt/.tcrc)"
 ### Select Release or Release Candidate
 RELEASE=`echo $1 | grep rc`
 if [ "$RELEASE" == "" ]; then
 FTPDIR="${MIRROR}/release/"
 else
 FTPDIR="${MIRROR}/release_candidates/"
 fi
 TMPDIR=`mktemp -d`
 echo $TMPDIR
 ####### Download and Check Release #########
 echo ftp://${FTPDIR}tinycore_"$1".iso
 busybox wget ftp://${FTPDIR}/tinycore_"$1".iso -O $TMPDIR/tinycore_"$1".iso
 busybox wget ftp://${FTPDIR}/tinycore_"$1".iso.md5.txt -O $TMPDIR/tinycore_"$1".iso.md5.txt
 cd  $TMPDIR
 busybox md5sum -cs $TMPDIR/tinycore_"$1".iso.md5.txt
 if [ $? != 0 ];	then
 echo "md5 doesn't match"
 rm -rf $TMPDIR
 exit 1
 fi
 mkdir $TMPDIR/mnt
 sudo mount -o loop tinycore_"$1".iso $TMPDIR/mnt
 ########### Copy new release to boot dirctory(es) #######
 cp -f $TMPDIR/mnt/boot/tinycore.gz $2
 cp -f $TMPDIR/mnt/boot/bzImage $2
 if [ -n "$3" ]; then
 sudo cp -f $TMPDIR/mnt/boot/bzImage $3
 sudo cp -f $TMPDIR/mnt/boot/tinycore.gz $3
 fi
 sudo  umount $TMPDIR/mnt
 rm -rf $TMPDIR
 echo "Done!"
 exit 0
- 
				A microcore version would, I assume, ideally update Xprogs, Xtools, and [I forget the name of the last one] if necessary, as well.
 
- 
				A microcore version would, I assume, ideally update Xprogs, Xtools, and [I forget the name of the last one] if necessary, as well.
 
 
 
 Including the viewer option helps see what's in the directory before installing (you can add whatever to the script)
 
 jls-legalize:  I do use the gnu wget extension, but thought the busybox wget in base would work by default.  edit: Just tried it....you're right, didn't work without wget.tcz
- 
				I modified my script, see post number 2