blob: 10d6e58c2f33e15e94e217fc04477d69227f7823 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/bin/sh
who=$(id -u)
if [ $who -ne 0 ]; then
echo 'Exit. System update must be run as root.'
exit 1
fi
cd /
umount -f /etc
mount -o remount,rw /
check_exit() {
if [ $? -ne 0 ];then
echo "Update failed."
exit 1
fi
}
extract_from_file() {
cat $1 | gunzip -c | tar -xf -
check_exit
}
extract_from_ssh() {
ssh $1 "cat $2" | gunzip -c | tar -xf -
check_exit
}
extract_from_http() {
wget -O - $1 | gunzip -c | tar -xf -
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."
|