summaryrefslogtreecommitdiffstats
path: root/defaultenv/defaultenv-2-base/bin/ifup
diff options
context:
space:
mode:
Diffstat (limited to 'defaultenv/defaultenv-2-base/bin/ifup')
-rw-r--r--defaultenv/defaultenv-2-base/bin/ifup67
1 files changed, 67 insertions, 0 deletions
diff --git a/defaultenv/defaultenv-2-base/bin/ifup b/defaultenv/defaultenv-2-base/bin/ifup
new file mode 100644
index 0000000..37b986c
--- /dev/null
+++ b/defaultenv/defaultenv-2-base/bin/ifup
@@ -0,0 +1,67 @@
+#!/bin/sh
+
+mkdir -p /tmp/network
+
+if [ $# != 1 ]; then
+ echo "usage: ifup <interface>"
+ exit 1
+fi
+
+interface="$1"
+
+if [ -f /tmp/network/$interface ]; then
+ exit 0
+fi
+
+cmd=/env/network/$interface
+
+if [ ! -e $cmd ]; then
+ echo "$f: no such file"
+ exit 1
+fi
+
+ip=
+ipaddr=
+netmask=
+gateway=
+serverip=
+ethaddr=
+
+. $cmd
+
+if [ $? != 0 ]; then
+ echo "failed to bring up $interface"
+ exit 1
+fi
+
+if [ -f /env/network/${interface}-discover ]; then
+ /env/network/${interface}-discover
+ if [ $? != 0 ]; then
+ echo "failed to discover eth0"
+ exit 1
+ fi
+fi
+
+if [ -n "$ethaddr" ]; then
+ ${interface}.ethaddr=$ethaddr
+fi
+
+if [ "$ip" = static ]; then
+ ${interface}.ipaddr=$ipaddr
+ ${interface}.netmask=$netmask
+ ${interface}.serverip=$serverip
+ ${interface}.gateway=$gateway
+ ret=0
+elif [ "$ip" = dhcp ]; then
+ dhcp
+ ret=$?
+ if [ $ret = 0 -a -n "$serverip" ]; then
+ ${interface}.serverip=$serverip
+ fi
+fi
+
+if [ $ret = 0 ]; then
+ echo -o /tmp/network/$interface up
+fi
+
+exit $ret