From 096ada0e66f079baea86c2592e3e44e8c9de4444 Mon Sep 17 00:00:00 2001 From: Marc Andre Tanner Date: Sat, 17 Oct 2009 20:10:55 +0200 Subject: [PATCH] Add network support to initscripts Signed-off-by: Marc Andre Tanner --- rootfs-overlay/etc/init.d/dropbear | 20 +++++++++++ rootfs-overlay/etc/init.d/networking | 70 ++++++++++++++++++++++++++++++++++++ rootfs-overlay/sbin/init | 28 ++++++++++----- 3 files changed, 109 insertions(+), 9 deletions(-) create mode 100755 rootfs-overlay/etc/init.d/dropbear create mode 100755 rootfs-overlay/etc/init.d/networking diff --git a/rootfs-overlay/etc/init.d/dropbear b/rootfs-overlay/etc/init.d/dropbear new file mode 100755 index 0000000..698af13 --- /dev/null +++ b/rootfs-overlay/etc/init.d/dropbear @@ -0,0 +1,20 @@ +#!/bin/sh + +case "$1" in + start) + dropbear + ;; + stop) + killall dropbear + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/rootfs-overlay/etc/init.d/networking b/rootfs-overlay/etc/init.d/networking new file mode 100755 index 0000000..da9bde0 --- /dev/null +++ b/rootfs-overlay/etc/init.d/networking @@ -0,0 +1,70 @@ +#!/bin/sh + +case "$1" in + start) + # gathers or create necessary host and device mac addresses for + # the g_ether module. If the g_ether module options file exists, + # we have nothing to do. + + if [ ! -e /etc/modprobe.d/g_ether.conf ] ; then + + # Gather up all g_ether parameters passed in on the kernel + # command line, and make sure to pass them to the module. + + # Begin by searching the command line for the host and dev addrs + da=`sed -n -e 's|.*g_ether\.dev_addr\=\(..:..:..:..:..:..\).*|\1|p' /proc/cmdline` + ha=`sed -n -e 's|.*g_ether\.host_addr\=\(..:..:..:..:..:..\).*|\1|p' /proc/cmdline` + + # If have a device address, now we need to sort out the host address. + # If it is unspecified, or if it is the same as the device address + # (Qi does this), compute a new address by just incrementing the device + # address. + + if [ -n "$da" -a -z "$ha" -o "$da" = "$ha" ]; then + + # We need to compute a new address - split the device + # address into two part, and increment the second part. + pfx=`echo "$da" | sed -n -e 's|\(..:..:..:\)..:..:..|\1|p'` + i=`echo "$da" | sed -n -e 's|..:..:..:\(..\):\(..\):\(..\)|0x\1\2\3|p'` + + # Now increment the mac addr + i=$(printf %06x $(($i+1))) + + # And glue the parts back together again. + i=`echo "$i" | sed -n -e 's|\(..\)\(..\)\(..\)|\1:\2:\3|p'` + + # Assign the computed host address, if this all worked out. + [ -n "$i" -a -n "$pfx" ] && ha=$pfx$i + fi + + [ -n "$da" ] && daddr="dev_addr=$da" + [ -n "$ha" ] && haddr="host_addr=$ha" + + [ -d /etc/modprobe.d ] || mkdir /etc/modprobe.d + echo "options g_ether $daddr $haddr" >/etc/modprobe.d/g_ether.conf + fi + + # load g_ether module if it isn't yet + lsmod | grep g_ether 2>/dev/null || modprobe g_ether 2>/dev/null + + ifconfig usb0 192.168.0.202 netmask 255.255.255.0 up + route add default gw 192.168.0.200 metric 8 + echo nameserver 208.67.222.222 > /etc/resolv.conf + echo nameserver 208.67.220.220 >> /etc/resolv.conf + + ;; + stop) + ifconfig usb0 down + modprobe -r g_ether + ;; + restart) + $0 stop + $0 start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/rootfs-overlay/sbin/init b/rootfs-overlay/sbin/init index 8b4334c..ae79ee5 100755 --- a/rootfs-overlay/sbin/init +++ b/rootfs-overlay/sbin/init @@ -1,19 +1,29 @@ -#!/bin/ash +#!/bin/sh export PATH=/sbin:/bin:/usr/sbin:/usr/bin export HOME=/home/root export USER=root +export TSLIB_TSDEVICE=/dev/input/touchscreen0 export ELM_ENGINE=fb export ELM_FONT_PATH=/usr/share/fonts +export EDITOR=/bin/vi -mount -t proc none /proc -mount -t sysfs none /sys -mount -t tmpfs none /tmp +mount -t proc proc /proc +mount -t sysfs sysfs /sys +mount -t tmpfs tmpfs /tmp +mount -t tmpfs tmpfs /dev +mkdir /dev/pts +mount -t devpts devpts /dev/pts +#mkdir /dev/shm +#mount -t tmpfs tmpfs /dev/shm +echo /bin/mdev > /proc/sys/kernel/hotplug +mdev -s -echo -echo Hello World -echo +nice -n -20 dialog "HELLO WOLRD" & -dropbear +sleep 5 -/bin/ash -l +/etc/init.d/networking start +/etc/init.d/dropbear start + +/bin/sh -l -- 2.11.4.GIT