summaryrefslogtreecommitdiff
path: root/package/base-files/src/sbin
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2010-02-07 20:15:44 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2010-02-07 20:15:44 +0100
commit483e9fde0b3923169c3c70720ca94b032dd30ae8 (patch)
treebd4ea28db271093276fe295b2da2e000a28aa857 /package/base-files/src/sbin
parent10997d993a55465525b026b9404f5809687e9e3c (diff)
parent25448b89bc693d56b074cd7b2a9c60ddc12f7404 (diff)
Merge branch 'master' of git+ssh://openadk.org/git/openadk
Diffstat (limited to 'package/base-files/src/sbin')
-rwxr-xr-xpackage/base-files/src/sbin/adkupdate80
1 files changed, 80 insertions, 0 deletions
diff --git a/package/base-files/src/sbin/adkupdate b/package/base-files/src/sbin/adkupdate
new file mode 100755
index 000000000..db1dfb73a
--- /dev/null
+++ b/package/base-files/src/sbin/adkupdate
@@ -0,0 +1,80 @@
+#!/bin/sh
+
+who=$(id -u)
+if [ $who -ne 0 ]; then
+ echo 'Exit. System update must be run as root.'
+ exit 1
+fi
+
+if [ -x /sbin/mtd ];then
+ updatecmd="mtd -r write - linux"
+else
+ updatecmd="gunzip -c | tar -xf -"
+fi
+
+system=$(awk '/system type/ { print $5 }' /proc/cpuinfo 2>/dev/null)
+
+check_exit() {
+ if [ $? -ne 0 ];then
+ echo "Update failed."
+ exit 1
+ fi
+}
+
+prepare() {
+ cd /
+ umount -f /etc
+ mount -o remount,rw /
+ if [ "$system" == "RB532" ];then
+ mount -t yaffs2 /dev/mtdblock0 /boot
+ fi
+}
+
+extract_from_file() {
+ prepare
+ cat $1 | eval $updatecmd
+ check_exit
+}
+
+extract_from_ssh() {
+ prepare
+ ssh $1 "cat $2" | eval $updatecmd
+ check_exit
+}
+
+extract_from_http() {
+ prepare
+ wget -O - $1 | eval $updatecmd
+ check_exit
+}
+
+case $1 in
+ file://*|/*)
+ url=$(echo $1|sed -e "s#file://##")
+ echo "Updating system from $1"
+ extract_from_file $url
+ ;;
+ ssh://*)
+ host=$(echo $1|sed -e "s#ssh://\(.*\):.*#\1#")
+ file=$(echo $1|sed -e "s#ssh://.*:\(.*\)#\1#")
+ echo "Updating system from $1"
+ extract_from_ssh $host $file
+ ;;
+ http://*|ftp://*)
+ echo "Updating system from $1"
+ extract_from_http $1
+ ;;
+ *)
+ echo "No or wrong uri given. exit."
+ echo "Use one of the following uri:"
+ echo "http://myserver/myupdate.tar.gz"
+ echo "ssh://myuser@myserver:/my/path/myupdate.tar.gz"
+ echo "file:///mypath/myupdate.tar.gz"
+ exit 1
+ ;;
+esac
+
+sync
+mount -o bind /etc /tmp/.cfgfs/root
+
+echo "Update sucessful. You should reboot now."