WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: dCore-update script  (Read 1987 times)

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
dCore-update script
« on: December 17, 2015, 03:10:49 PM »
Hi
I've modified the following script:

http://forum.tinycorelinux.net/index.php/topic,3101.msg15964.html#msg15964

for let it working here on dCore:
Code: [Select]
#!/bin/sh
#download the latest dCore initrd
#tinycorelinux.net
#Original from jpeters,
#http://forum.tinycorelinux.net/index.php/topic,3101.msg15964.html#msg15964
#modified for dCore by jls (franclinux@gmail.com)


BOOTDIR="/etc/sysconfig/tcedir/boot"
MIRROR="$(cat /opt/tcemirror)/dCore/x86"
DCORETYPE=$(version|awk -F . '{ print $1 }')
INITRD=$DCORETYPE.gz


### Select Release or Release Candidate
echo "Enter r or c (release or candidate)"
read RELEASE

case $RELEASE in
 "r" ) REMOTEDIR="${MIRROR}/release/$DCORETYPE"  ;;
 "c" ) REMOTEDIR="${MIRROR}/release_candidates/$DCORETYPE" ;;
 * ) echo "invalid option" ; exit 1 ;;
esac

####### View Directory ######
if [ `which netrik` ]; then
   netrik  "${REMOTEDIR}"
   echo "continue?  'y' "
   read RESPONSE
   [ ${RESPONSE} == "y" ] || exit 1
fi
 


####### Download and Check Release #########

[ -e /tmp/download ] || mkdir /tmp/download


cd /tmp/download
wget ${REMOTEDIR}/$INITRD
wget ${REMOTEDIR}/$INITRD.md5.txt


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 $INITRD ] && mv $INITRD  $INITRD.old

########### Copy new release to boot dirctory #######

cp /tmp/download/$INITRD ${BOOTDIR}

############  Cleanup ##########
#sudo  umount /tmp/extract
#rmdir /tmp/extract
sudo rm -R /tmp/download


echo "Done!"

exit 0



« Last Edit: December 17, 2015, 03:28:40 PM by jls_legalize »
dCore user

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: dCore-update script
« Reply #1 on: December 17, 2015, 04:14:20 PM »
Thank you, I will look at it soon.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: dCore-update script
« Reply #2 on: December 19, 2015, 03:35:10 PM »
updated for version name change:
Code: [Select]
jls@box:~$ cat .local/bin/dCore-update
#!/bin/sh
#download the latest dCore initrd
#tinycorelinux.net
#Original from jpeters( http://forum.tinycorelinux.net/index.php/topic,3101.msg15964.html#msg15964)
#forum topic: http://forum.tinycorelinux.net/index.php/topic,19305.0.html
#modified for dCore by jls (franclinux@gmail.com)


BOOTDIR="/etc/sysconfig/tcedir/boot"
MIRROR="$(cat /opt/tcemirror)/dCore/x86"
DCORETYPE=$(version|awk -F . '{ print $1 }')
INITRD=$DCORETYPE.gz


### Select Release or Release Candidate
echo "Enter r or c (release or candidate)"
read RELEASE

case $RELEASE in
 "r" ) REMOTEDIR="${MIRROR}/release/$DCORETYPE"  ;;
 "c" ) REMOTEDIR="${MIRROR}/release_candidates/$DCORETYPE" ;;
 * ) echo "invalid option" ; exit 1 ;;
esac

####### View Directory ######
if [ `which netrik` ]; then
   netrik  "${REMOTEDIR}"
   echo "continue?  'y' "
   read RESPONSE
   [ ${RESPONSE} == "y" ] || exit 1
fi



####### Download and Check Release #########

[ -e /tmp/download ] || mkdir /tmp/download


cd /tmp/download
wget ${REMOTEDIR}/$INITRD
wget ${REMOTEDIR}/$INITRD.md5.txt


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 $INITRD ] && mv $INITRD  $INITRD.old

########### Copy new release to boot dirctory #######

cp /tmp/download/$INITRD ${BOOTDIR}

############  Cleanup ##########
#sudo  umount /tmp/extract
#rmdir /tmp/extract
sudo rm -R /tmp/download


echo "Done!"

exit 0

dCore user

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: dCore-update script
« Reply #3 on: December 19, 2015, 05:12:59 PM »
sorry haven't actually fixed, now I think yes:
Code: [Select]
jls@box:~$ cat .local/bin/dCore-update
#!/bin/sh
#download the latest dCore initrd
#tinycorelinux.net
#Original from jpeters ( http://forum.tinycorelinux.net/index.php/topic,3101.msg
15964.html#msg15964 )
#forum topic: http://forum.tinycorelinux.net/index.php/topic,19305.0.html
#modified for dCore by jls (franclinux@gmail.com)


BOOTDIR="/etc/sysconfig/tcedir/boot"
MIRROR="$(cat /opt/tcemirror)/dCore/x86"
DCORETYPE=$(version|awk -F : '{ print $1 }')
INITRD=$DCORETYPE.gz


### Select Release or Release Candidate
echo "Enter r or c (release or candidate)"
read RELEASE

case $RELEASE in
 "r" ) REMOTEDIR="${MIRROR}/release/$DCORETYPE"  ;;
 "c" ) REMOTEDIR="${MIRROR}/release_candidates/$DCORETYPE" ;;
 * ) echo "invalid option" ; exit 1 ;;
esac

####### View Directory ######
if [ `which netrik` ]; then
   netrik  "${REMOTEDIR}"
   echo "continue?  'y' "
   read RESPONSE
   [ ${RESPONSE} == "y" ] || exit 1
fi



####### Download and Check Release #########

[ -e /tmp/download ] || mkdir /tmp/download


cd /tmp/download
wget ${REMOTEDIR}/$INITRD
wget ${REMOTEDIR}/$INITRD.md5.txt


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 $INITRD ] && mv $INITRD  $INITRD.old

########### Copy new release to boot dirctory #######

cp /tmp/download/$INITRD ${BOOTDIR}

############  Cleanup ##########
#sudo  umount /tmp/extract
#rmdir /tmp/extract
sudo rm -R /tmp/download


echo "Done!"

exit 0


dCore user

Offline Jason W

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 9730
Re: dCore-update script
« Reply #4 on: December 19, 2015, 05:36:14 PM »
Lets make this an extension at some point.  The reason I say extension is they are so much more easy to maintain as opposed to me having to repack and upload 8 images (1 being A10/20 uCore) upon any changes to the utility.  I put into extension whatever I can of my stuff for this same reason.  I like the idea of being able to run "version -r/c" and then running a command to fetch the new release or release candidate.

Offline jls

  • Hero Member
  • *****
  • Posts: 2135
Re: dCore-update script
« Reply #5 on: December 23, 2015, 10:17:43 AM »
swapped r & c for conformity with the "version" command
Code: [Select]
#!/bin/sh
#download the latest dCore initrd
#tinycorelinux.net
#Original from jpeters ( http://forum.tinycorelinux.net/index.php/topic,3101.msg15964.html#msg15964 )
#forum topic: http://forum.tinycorelinux.net/index.php/topic,19305.0.html
#modified for dCore by jls (franclinux@gmail.com)


BOOTDIR="/etc/sysconfig/tcedir/boot"
MIRROR="$(cat /opt/tcemirror)/dCore/x86"
DCORETYPE=$(version|awk -F : '{ print $1 }')
INITRD=$DCORETYPE.gz


### Select Release or Release Candidate
echo "Enter c or r (release or candidate)"
read RELEASE

case $RELEASE in
 "c" ) REMOTEDIR="${MIRROR}/release/$DCORETYPE"  ;;
 "r" ) REMOTEDIR="${MIRROR}/release_candidates/$DCORETYPE" ;;
 * ) echo "invalid option" ; exit 1 ;;
esac

####### View Directory ######
if [ `which netrik` ]; then
   netrik  "${REMOTEDIR}"
   echo "continue?  'y' "
   read RESPONSE
   [ ${RESPONSE} == "y" ] || exit 1
fi
 


####### Download and Check Release #########

[ -e /tmp/download ] || mkdir /tmp/download


cd /tmp/download
wget ${REMOTEDIR}/$INITRD
wget ${REMOTEDIR}/$INITRD.md5.txt


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 $INITRD ] && mv $INITRD  $INITRD.old

########### Copy new release to boot dirctory #######

cp /tmp/download/$INITRD ${BOOTDIR}

############  Cleanup ##########
#sudo  umount /tmp/extract
#rmdir /tmp/extract
sudo rm -R /tmp/download


echo "Done!"

exit 0
dCore user