diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2009-11-25 23:02:27 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2009-11-25 23:02:27 +0100 |
commit | 83f5e16fffe029232114ee9f54b8df41d5841912 (patch) | |
tree | 981c8fe3ba18133dd7b01a79e817de1961253600 /package/base-files | |
parent | 02e9bb0970ba681f228dc642b1e5026cc97047c7 (diff) |
add update script to base-files
- system update via http/ftp/ssh/file possible
- add bridge script
- cleanup unused files
Diffstat (limited to 'package/base-files')
-rw-r--r-- | package/base-files/extra/etc/network/if-pre-up.d/bridge | 32 | ||||
-rwxr-xr-x | package/base-files/extra/usr/sbin/update | 63 |
2 files changed, 95 insertions, 0 deletions
diff --git a/package/base-files/extra/etc/network/if-pre-up.d/bridge b/package/base-files/extra/etc/network/if-pre-up.d/bridge new file mode 100644 index 000000000..766084de1 --- /dev/null +++ b/package/base-files/extra/etc/network/if-pre-up.d/bridge @@ -0,0 +1,32 @@ +#!/bin/sh + +if [ ! -x /usr/sbin/brctl ] +then + exit 0 +fi + +case "$IF_BRIDGE_PORTS" in + "") + exit 0 + ;; + none) + INTERFACES="" + ;; + *) + INTERFACES="$IF_BRIDGE_PORTS" + ;; +esac + +brctl addbr $IFACE || exit 1 + +for IF in $INTERFACES; do + if ! grep -q $IF /proc/net/dev; then + echo "Error: interface '$IF' does not exist!" + brctl delbr $IFACE + exit 1 + fi + brctl addif $IFACE $IF + ip link set up dev $IF +done + +exit 0 diff --git a/package/base-files/extra/usr/sbin/update b/package/base-files/extra/usr/sbin/update new file mode 100755 index 000000000..57e9cf268 --- /dev/null +++ b/package/base-files/extra/usr/sbin/update @@ -0,0 +1,63 @@ +#!/bin/sh + +who=$(id -u) +if [ $who -ne 0 ]; then + echo 'Exit. System update must be run as root.' + exit 1 +fi + +cd / + +mount -o remount,rw / + +check_exit() { + if [ $? -ne 0 ];then + echo "Update failed." + exit 1 + fi +} + +extract_from_file() { + tar -xzvf $1 + check_exit +} + +extract_from_ssh() { + ssh $1 "cat $2" | tar -xzvf - + check_exit +} + +extract_from_http() { + wget -O - $1 | tar -xzvf - + 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 + +echo "You should reboot now." |