summaryrefslogtreecommitdiffstats
path: root/testModule/debugging_tools
diff options
context:
space:
mode:
authortorben2015-04-20 14:44:12 +0200
committertorben2015-04-20 14:44:12 +0200
commit81e7552e02341e6bff0ac1daccbe9156fbd1d147 (patch)
tree3cfe9fe7ea679cfdcbcce3634a3dc59e4355cb91 /testModule/debugging_tools
parentMerge branch 'master' of git.openslx.org:openslx-ng/systemd-init (diff)
downloadsystemd-init-81e7552e02341e6bff0ac1daccbe9156fbd1d147.tar.gz
systemd-init-81e7552e02341e6bff0ac1daccbe9156fbd1d147.tar.xz
systemd-init-81e7552e02341e6bff0ac1daccbe9156fbd1d147.zip
Cleanup refactoring. Evaluate minimal needed dependencies.
Diffstat (limited to 'testModule/debugging_tools')
-rwxr-xr-xtestModule/debugging_tools/busyboxbin0 -> 931664 bytes
-rwxr-xr-xtestModule/debugging_tools/dnbd3-clientbin0 -> 31150 bytes
-rwxr-xr-xtestModule/debugging_tools/endlessbin0 -> 6752 bytes
-rw-r--r--testModule/debugging_tools/endless.c10
-rwxr-xr-xtestModule/debugging_tools/nbd-clientbin0 -> 59639 bytes
-rw-r--r--testModule/debugging_tools/nbd-debugging.kobin0 -> 463248 bytes
-rw-r--r--testModule/debugging_tools/network.functions23
-rwxr-xr-xtestModule/debugging_tools/qemu-nbd-systemd-markbin0 -> 7131834 bytes
-rwxr-xr-xtestModule/debugging_tools/qemu-nbd-systemd-mark-alternatebin0 -> 7128103 bytes
-rw-r--r--testModule/debugging_tools/setup_network.sh84
10 files changed, 117 insertions, 0 deletions
diff --git a/testModule/debugging_tools/busybox b/testModule/debugging_tools/busybox
new file mode 100755
index 00000000..1212ae20
--- /dev/null
+++ b/testModule/debugging_tools/busybox
Binary files differ
diff --git a/testModule/debugging_tools/dnbd3-client b/testModule/debugging_tools/dnbd3-client
new file mode 100755
index 00000000..76924b49
--- /dev/null
+++ b/testModule/debugging_tools/dnbd3-client
Binary files differ
diff --git a/testModule/debugging_tools/endless b/testModule/debugging_tools/endless
new file mode 100755
index 00000000..de7a8c0a
--- /dev/null
+++ b/testModule/debugging_tools/endless
Binary files differ
diff --git a/testModule/debugging_tools/endless.c b/testModule/debugging_tools/endless.c
new file mode 100644
index 00000000..22c9bc50
--- /dev/null
+++ b/testModule/debugging_tools/endless.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+int main(int argc, char *argv[]) {
+ // Provides a dummy worker.
+ while (1)
+ sleep(999999999);
+}
diff --git a/testModule/debugging_tools/nbd-client b/testModule/debugging_tools/nbd-client
new file mode 100755
index 00000000..7bb2207f
--- /dev/null
+++ b/testModule/debugging_tools/nbd-client
Binary files differ
diff --git a/testModule/debugging_tools/nbd-debugging.ko b/testModule/debugging_tools/nbd-debugging.ko
new file mode 100644
index 00000000..47cf6cd6
--- /dev/null
+++ b/testModule/debugging_tools/nbd-debugging.ko
Binary files differ
diff --git a/testModule/debugging_tools/network.functions b/testModule/debugging_tools/network.functions
new file mode 100644
index 00000000..89ca5a20
--- /dev/null
+++ b/testModule/debugging_tools/network.functions
@@ -0,0 +1,23 @@
+wait_for_iface() {
+ local DEVICE=$1
+ local TIMEOUT=10
+ echo -n "Waiting for interface $DEVICE: "
+ # Some systems don't have operstate. Seems to be hardware dependent
+ [ ! -e "/sys/class/net/${DEVICE}/operstate" ] && usleep 10000
+ if [ -e "/sys/class/net/${DEVICE}/operstate" ]; then
+ while true; do
+ # check linkstate
+ [ "x$(cat "/sys/class/net/${DEVICE}/operstate")" == "xup" ] && break
+ TIMEOUT=$(( $TIMEOUT - 1 )) # don't wait forever, the pcnet iface of vmware will never be "up" although it's working
+ [ "$TIMEOUT" -le 0 ] && break
+ # else
+ echo -n "."
+ usleep 500000
+ done
+ else
+ # we really don't have a operstate .. then just wait a sec and hope for the best.
+ sleep 1
+ fi
+ echo ".$(cat "/sys/class/net/${DEVICE}/operstate" 2>/dev/null)"
+}
+true
diff --git a/testModule/debugging_tools/qemu-nbd-systemd-mark b/testModule/debugging_tools/qemu-nbd-systemd-mark
new file mode 100755
index 00000000..26fefe9d
--- /dev/null
+++ b/testModule/debugging_tools/qemu-nbd-systemd-mark
Binary files differ
diff --git a/testModule/debugging_tools/qemu-nbd-systemd-mark-alternate b/testModule/debugging_tools/qemu-nbd-systemd-mark-alternate
new file mode 100755
index 00000000..03c2a6b1
--- /dev/null
+++ b/testModule/debugging_tools/qemu-nbd-systemd-mark-alternate
Binary files differ
diff --git a/testModule/debugging_tools/setup_network.sh b/testModule/debugging_tools/setup_network.sh
new file mode 100644
index 00000000..3b32a68c
--- /dev/null
+++ b/testModule/debugging_tools/setup_network.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+echo "Setting up network..."
+
+echo "Main MAC address is '$MAC'"
+
+# setup network
+source /inc/network.functions
+
+# set up loopback networking
+echo "Setting up loopback"
+ip link set dev lo up 2>/dev/null
+ip addr add 127.0.0.1/8 dev lo 2>/dev/null
+
+echo "Setting up bridge"
+BRIDGE="br0"
+
+# Following was supposed to prevent scripts from getting confused by multiple interfaces with same MAC - does not work though
+## Flip mac address of original interface - this var is not local so init sees the changes too
+#MAC="$(echo "$MAC" | awk -F ':' '{printf $1 ":" $2 ":" $5 ":" $3 ":" $6 ":" $4}')"
+#ip link set addr "$MAC" "$SLAVE"
+
+mkdir -p "${FUTURE_ROOT}/etc/udev/rules.d"
+
+#IP_OUT=$(ip a | sed -r ':a;N;$!ba;s/: ([a-z0-9]+): /####\1####/g;s/ether ([a-f0-9:]+) /####\1####/g'| grep -E -o '####[^ ]+####' | sed 's/#//g' | grep -B 1 ':')
+IP_OUT=$(ip a | grep -B 1 "/ether" | sed -r '/^--$/d;$!N;s#^[0-9]+: ([a-z0-9\.:]+): .*?/ether ([0-9a-fA-Z:]+) .*$#\1==\2#')
+
+if ! echo "$IP_OUT" | grep -q -- "$MAC"; then
+ drop_shell "Boot interface not found in interface list. NIC driver missing?"
+fi
+
+for LINE in $IP_OUT; do
+ IFACE=$(echo "$LINE" | awk -F '==' '{printf $1}')
+ IFMAC=$(echo "$LINE" | awk -F '==' '{printf $2}' | tr '[A-Z]' '[a-z]') # udev requires mac addesses to be lowercase (a-f), see http://www.debianhelp.co.uk/udev.htm
+ echo "${IFACE} = ${IFMAC}"
+
+ if [ "x$IFMAC" == "x$MAC" ]; then
+ brctl addbr "$BRIDGE" || drop_shell "Could not create bridge $BRIDGE"
+ brctl stp "$BRIDGE" 0
+ brctl setfd "$BRIDGE" 0.000000000001
+ ip link set addr "$IFMAC" "$BRIDGE" || drop_shell "Could not set mac of $BRIDGE"
+ ip link set dev "$IFACE" up
+ wait_for_iface "$IFACE"
+ brctl addif "$BRIDGE" "$IFACE" || drop_shell "Could not add $IFACE to $BRIDGE"
+
+ # save our variables for retry on fail
+ echo "IFACE=$IFACE" > /run/network.conf
+
+ # analyze ip information from the kernel command line and put parts
+ # of it into several variables
+ if [ -n "$CLIENTIP" ] ; then
+ # set static ip address
+ ip addr add "$CLIENTIP/$(ipcalc -s -p "$CLIENTIP" "$SUBNET_MASK" | sed "s/.*=//")" broadcast "$BROADCAST_ADDRESS" dev "$BRIDGE"
+ ip link set dev "$BRIDGE" up
+ [ -n "$GATEWAY" ] && ip route add default via "$GATEWAY" dev "$BRIDGE"
+ else
+ NOIPYET="yes"
+ fi
+ # Ignore this device later on when systemd handles network interfaces (see hacked 99-systemd.rules in systemd data dir)
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNEL==\"eth*\", ATTR{address}==\"$IFMAC\", TAG+=\"openslxignore\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/01-ignore-boot-interface.rules"
+ fi
+ # youdev
+ echo "SUBSYSTEM==\"net\", ACTION==\"add\", DRIVERS==\"?*\", ATTR{address}==\"$IFMAC\", ATTR{dev_id}==\"0x0\", ATTR{type}==\"1\", KERNEL==\"eth*\", NAME=\"$IFACE\"" >> "${FUTURE_ROOT}/etc/udev/rules.d/70-net-boot-nic-name.rules"
+ # continue...
+ IFACE=""
+done
+
+wait_for_iface "$BRIDGE"
+
+# udhcpc
+PARAM=
+if [ -n "$CLIENTIP" ]; then
+ PARAM="-r $CLIENTIP"
+fi
+echo -n "$CLIENTIP" > "/run/firstip"
+echo -n "$GATEWAY" > "/run/firstgw"
+
+# save our variables for retry on fail ff.
+echo "CLIENTIP=$CLIENTIP" >> /run/network.conf
+echo "GATEWAY=$GATEWAY" >> /run/network.conf
+echo "BRIDGE=$BRIDGE" >> /run/network.conf
+
+udhcpc $PARAM -O domain -O nissrv -O nisdomain -O wpad -O search -t 5 -T 2 -s "/inc/udhcpc-trigger" -f -n -q -i "$BRIDGE"
+# udhcpc return value will be return value of this script