WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: get-release script  (Read 4868 times)

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
get-release script
« 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

Code: [Select]
#!/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

« Last Edit: October 14, 2009, 04:33:53 AM by jpeters »

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: get-release script
« Reply #1 on: September 22, 2009, 02:38:35 PM »
I think your version requires the wget extension.
I modified your version:
Code: [Select]
#!/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
« Last Edit: October 24, 2009, 05:57:27 PM by jls_legalize »
dCore user

Offline samedirection

  • Jr. Member
  • **
  • Posts: 64
Re: get-release script
« Reply #2 on: September 22, 2009, 03:59:40 PM »
A microcore version would, I assume, ideally update Xprogs, Xtools, and [I forget the name of the last one] if necessary, as well.

Offline jpeters

  • Restricted
  • Hero Member
  • *****
  • Posts: 1017
Re: get-release script
« Reply #3 on: September 22, 2009, 04:49:24 PM »
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
« Last Edit: September 22, 2009, 05:33:50 PM by jpeters »

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: get-release script
« Reply #4 on: October 24, 2009, 05:58:13 PM »
I modified my script, see post number 2
dCore user