From 91cc532a55fed3c6c27a2e14759e901ed3d72579 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:09:38 +0200 Subject: Code refactoring. --- testModule/binaries/busybox | Bin 0 -> 931664 bytes testModule/binaries/dnbd3-client | Bin 0 -> 31150 bytes testModule/binaries/endless | Bin 0 -> 6752 bytes .../binaries/systemd_preserve_process_marker | Bin 0 -> 7728 bytes testModule/busybox | Bin 931664 -> 0 bytes testModule/deprecated/network.functions | 23 ++++++ testModule/deprecated/setup_network.sh | 84 +++++++++++++++++++++ testModule/dnbd3-client | Bin 31150 -> 0 bytes testModule/dnbd3.ko | Bin 1345285 -> 0 bytes testModule/endless | Bin 6752 -> 0 bytes testModule/endless.c | 4 +- testModule/hooks/cmdline.sh | 34 +++++++++ testModule/hooks/pre-mount.sh | 14 ++++ testModule/hooks/pre-pivot.sh | 3 + testModule/kernel_modules/dnbd3.ko | Bin 0 -> 1345285 bytes testModule/kernel_modules/nbd.ko | Bin 0 -> 458623 bytes testModule/module-setup.sh | 18 ++--- testModule/nbd.ko | Bin 458623 -> 0 bytes testModule/network.functions | 23 ------ testModule/parse-ip.sh | 34 --------- testModule/pre-mount.sh | 14 ---- testModule/pre-pivot.sh | 3 - testModule/process-name-wrapper.sh | 5 -- testModule/setup_network.sh | 84 --------------------- testModule/systemd_preserve_process_marker.c | 31 ++++++++ testModule/wrap | Bin 7752 -> 0 bytes testModule/wrap.c | 40 ---------- 27 files changed, 200 insertions(+), 214 deletions(-) create mode 100755 testModule/binaries/busybox create mode 100755 testModule/binaries/dnbd3-client create mode 100755 testModule/binaries/endless create mode 100755 testModule/binaries/systemd_preserve_process_marker delete mode 100755 testModule/busybox create mode 100644 testModule/deprecated/network.functions create mode 100644 testModule/deprecated/setup_network.sh delete mode 100755 testModule/dnbd3-client delete mode 100755 testModule/dnbd3.ko delete mode 100755 testModule/endless create mode 100644 testModule/hooks/cmdline.sh create mode 100644 testModule/hooks/pre-mount.sh create mode 100644 testModule/hooks/pre-pivot.sh create mode 100755 testModule/kernel_modules/dnbd3.ko create mode 100644 testModule/kernel_modules/nbd.ko delete mode 100644 testModule/nbd.ko delete mode 100644 testModule/network.functions delete mode 100644 testModule/parse-ip.sh delete mode 100644 testModule/pre-mount.sh delete mode 100644 testModule/pre-pivot.sh delete mode 100755 testModule/process-name-wrapper.sh delete mode 100644 testModule/setup_network.sh create mode 100644 testModule/systemd_preserve_process_marker.c delete mode 100755 testModule/wrap delete mode 100644 testModule/wrap.c (limited to 'testModule') diff --git a/testModule/binaries/busybox b/testModule/binaries/busybox new file mode 100755 index 00000000..1212ae20 Binary files /dev/null and b/testModule/binaries/busybox differ diff --git a/testModule/binaries/dnbd3-client b/testModule/binaries/dnbd3-client new file mode 100755 index 00000000..76924b49 Binary files /dev/null and b/testModule/binaries/dnbd3-client differ diff --git a/testModule/binaries/endless b/testModule/binaries/endless new file mode 100755 index 00000000..de7a8c0a Binary files /dev/null and b/testModule/binaries/endless differ diff --git a/testModule/binaries/systemd_preserve_process_marker b/testModule/binaries/systemd_preserve_process_marker new file mode 100755 index 00000000..0181cd80 Binary files /dev/null and b/testModule/binaries/systemd_preserve_process_marker differ diff --git a/testModule/busybox b/testModule/busybox deleted file mode 100755 index 1212ae20..00000000 Binary files a/testModule/busybox and /dev/null differ diff --git a/testModule/deprecated/network.functions b/testModule/deprecated/network.functions new file mode 100644 index 00000000..89ca5a20 --- /dev/null +++ b/testModule/deprecated/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/deprecated/setup_network.sh b/testModule/deprecated/setup_network.sh new file mode 100644 index 00000000..3b32a68c --- /dev/null +++ b/testModule/deprecated/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 diff --git a/testModule/dnbd3-client b/testModule/dnbd3-client deleted file mode 100755 index 76924b49..00000000 Binary files a/testModule/dnbd3-client and /dev/null differ diff --git a/testModule/dnbd3.ko b/testModule/dnbd3.ko deleted file mode 100755 index d7b7ce3b..00000000 Binary files a/testModule/dnbd3.ko and /dev/null differ diff --git a/testModule/endless b/testModule/endless deleted file mode 100755 index e3c61074..00000000 Binary files a/testModule/endless and /dev/null differ diff --git a/testModule/endless.c b/testModule/endless.c index e3598e88..22c9bc50 100644 --- a/testModule/endless.c +++ b/testModule/endless.c @@ -4,7 +4,7 @@ #include int main(int argc, char *argv[]) { - // argv[0][0] = '@'; + // Provides a dummy worker. while (1) - sleep(5); + sleep(999999999); } diff --git a/testModule/hooks/cmdline.sh b/testModule/hooks/cmdline.sh new file mode 100644 index 00000000..5731242f --- /dev/null +++ b/testModule/hooks/cmdline.sh @@ -0,0 +1,34 @@ +# Converts ip configuration format given by the pxe pre boot provider to a +# dracut compatible static ip configuration. + +# TODO +warn 'LOAD ...........................' +warn 'LOAD ...........................' + +source /usr/lib/test-library.sh + +for parameter in $(getargs ip=); do + local temp="$parameter:" + set -- + while [ -n "$temp" ]; do + set -- "$@" "${temp%%:*}" + temp=${temp#*:} + done + + [ -n "$1" ] && ip=$1 + [ -n "$2" ] && server_ip=$2 + [ -n "$3" ] && gateway_ip=$3 + [ -n "$4" ] && net_mask=$4 + + warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" + local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" + warn "Final dracut ip config: $final_dracut_ip_config" + #final_dracut_ip_config="enp0s3:dhcp" + replace_cmd ip "$final_dracut_ip_config" +done + +# NOTE: Doesn't work since dracuts needed version of mount doesn't support +# binds. +#cat /proc/cmdline | sed --regexp-extended 's/ip=[^ ]+//g' \ +# >"$temporary_kernel_commandline_file_path" && \ +#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline diff --git a/testModule/hooks/pre-mount.sh b/testModule/hooks/pre-mount.sh new file mode 100644 index 00000000..301381e6 --- /dev/null +++ b/testModule/hooks/pre-mount.sh @@ -0,0 +1,14 @@ +# TODO +warn '............START.............' + +insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko + +#dnbd3-client --daemon & +#sleep 3 +local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" +dnbd3_device_node='/dev/dnbd0' +qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 +insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko +wrap qemu-nbd -c /dev/nbd0 /test.qcow2 + +#wrap /usr/bin/bash -c 'while true; do wget http://10.126.2.184:8080; sleep 10; done' & diff --git a/testModule/hooks/pre-pivot.sh b/testModule/hooks/pre-pivot.sh new file mode 100644 index 00000000..c868fc30 --- /dev/null +++ b/testModule/hooks/pre-pivot.sh @@ -0,0 +1,3 @@ +# TODO +warn '............MOUNT.............' +mount /dev/nbd0 /sysroot/mnt diff --git a/testModule/kernel_modules/dnbd3.ko b/testModule/kernel_modules/dnbd3.ko new file mode 100755 index 00000000..d7b7ce3b Binary files /dev/null and b/testModule/kernel_modules/dnbd3.ko differ diff --git a/testModule/kernel_modules/nbd.ko b/testModule/kernel_modules/nbd.ko new file mode 100644 index 00000000..40b67a92 Binary files /dev/null and b/testModule/kernel_modules/nbd.ko differ diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index 1718cca3..5451bb42 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -5,7 +5,7 @@ check() { } depends() { - echo base network rootfs-block bash kernel-modules systemd shutdown udev-rules debug qemu btrfs + echo base network rootfs-block bash kernel-modules systemd debug return 0 } @@ -28,19 +28,19 @@ installkernel() { install() { # Loads globally needed useful functions or fixes some native dracut ones. inst "$moddir/library.sh" /usr/lib/test-library.sh - inst "$moddir/process-name-wrapper.sh" /usr/bin/process-name-wrapper - inst "$moddir/wrap" /usr/bin/wrap - inst "$moddir/endless" /usr/bin/endless - inst "$moddir/dnbd3-client" /usr/bin/dnbd3-client - inst "$moddir/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko - inst "$moddir/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko + inst "$moddir/binaries/systemd_preserve_process_marker" /usr/bin/systemd_preserve_process_marker + inst "$moddir/binaries/endless" /usr/bin/endless + inst "$moddir/binaries/dnbd3-client" /usr/bin/dnbd3-client + inst "$moddir/binaries/busybox" /usr/bin/busybox + inst "$moddir/kernel_modules/dnbd3.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko + inst "$moddir/kernel_modules/nbd.ko" /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko # NOTE: Priority has to be greater than the network cmdline parsing hooks # since we have to modify the some kernel parameter before. - inst_hook cmdline 100 "$moddir/parse-ip.sh" + inst_hook cmdline 100 "$moddir/cmdline.sh" inst_hook pre-mount 100 "$moddir/pre-mount.sh" inst_hook pre-pivot 100 "$moddir/pre-pivot.sh" - inst_simple "$moddir/busybox" /usr/bin/busybox #inst_hook pre-mount 20 "$moddir/setup_network.sh" inst_multiple lsblk ping ip ifconfig sshd htop dhclient tail head cat vim touch sed lsmod insmod qemu-img qemu-nbd sleep route wget find + # FINAL: inst_multiple insmod qemu-img qemu-nbd return 0 } diff --git a/testModule/nbd.ko b/testModule/nbd.ko deleted file mode 100644 index 40b67a92..00000000 Binary files a/testModule/nbd.ko and /dev/null differ diff --git a/testModule/network.functions b/testModule/network.functions deleted file mode 100644 index 89ca5a20..00000000 --- a/testModule/network.functions +++ /dev/null @@ -1,23 +0,0 @@ -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/parse-ip.sh b/testModule/parse-ip.sh deleted file mode 100644 index 5731242f..00000000 --- a/testModule/parse-ip.sh +++ /dev/null @@ -1,34 +0,0 @@ -# Converts ip configuration format given by the pxe pre boot provider to a -# dracut compatible static ip configuration. - -# TODO -warn 'LOAD ...........................' -warn 'LOAD ...........................' - -source /usr/lib/test-library.sh - -for parameter in $(getargs ip=); do - local temp="$parameter:" - set -- - while [ -n "$temp" ]; do - set -- "$@" "${temp%%:*}" - temp=${temp#*:} - done - - [ -n "$1" ] && ip=$1 - [ -n "$2" ] && server_ip=$2 - [ -n "$3" ] && gateway_ip=$3 - [ -n "$4" ] && net_mask=$4 - - warn "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask" - local final_dracut_ip_config="$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" - warn "Final dracut ip config: $final_dracut_ip_config" - #final_dracut_ip_config="enp0s3:dhcp" - replace_cmd ip "$final_dracut_ip_config" -done - -# NOTE: Doesn't work since dracuts needed version of mount doesn't support -# binds. -#cat /proc/cmdline | sed --regexp-extended 's/ip=[^ ]+//g' \ -# >"$temporary_kernel_commandline_file_path" && \ -#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline diff --git a/testModule/pre-mount.sh b/testModule/pre-mount.sh deleted file mode 100644 index 301381e6..00000000 --- a/testModule/pre-mount.sh +++ /dev/null @@ -1,14 +0,0 @@ -# TODO -warn '............START.............' - -insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/dnbd3.ko - -#dnbd3-client --daemon & -#sleep 3 -local dnbd3_device_node="$(dnbd3-client -h 132.230.4.1 -i stage4/torben/test -r 1 -d /dev/dnbd0)" -dnbd3_device_node='/dev/dnbd0' -qemu-img create -f qcow2 -o backing_file="$dnbd3_device_node",backing_fmt=qcow2 /test.qcow2 -insmod /usr/lib/modules/3.10.0-229.1.2.el7.x86_64/extra/nbd.ko -wrap qemu-nbd -c /dev/nbd0 /test.qcow2 - -#wrap /usr/bin/bash -c 'while true; do wget http://10.126.2.184:8080; sleep 10; done' & diff --git a/testModule/pre-pivot.sh b/testModule/pre-pivot.sh deleted file mode 100644 index c868fc30..00000000 --- a/testModule/pre-pivot.sh +++ /dev/null @@ -1,3 +0,0 @@ -# TODO -warn '............MOUNT.............' -mount /dev/nbd0 /sysroot/mnt diff --git a/testModule/process-name-wrapper.sh b/testModule/process-name-wrapper.sh deleted file mode 100755 index 36712e51..00000000 --- a/testModule/process-name-wrapper.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -programPath="$(echo "$0" | sed --regexp-extended 's/^(.*)@([^/]+)$/\1\2/')" -echo "Run \"$programPath\" with arguments \"${@}\"." && \ -exec "$programPath" "$@" diff --git a/testModule/setup_network.sh b/testModule/setup_network.sh deleted file mode 100644 index 3b32a68c..00000000 --- a/testModule/setup_network.sh +++ /dev/null @@ -1,84 +0,0 @@ -#!/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 diff --git a/testModule/systemd_preserve_process_marker.c b/testModule/systemd_preserve_process_marker.c new file mode 100644 index 00000000..172a5546 --- /dev/null +++ b/testModule/systemd_preserve_process_marker.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +void print_array(int argc, char *argv[]) { + // Helper function to print given array with given length. + int i = 0; + int j = 0; + for (i = 0; i < argc; i ++) { + j = 0; + while(argv[i][j] != '\0') + printf("%c", argv[i][j++]); + printf(" "); + } + printf("\n"); +} +int main(int argc, char *argv[]) { + int count; + char **copy = malloc(sizeof(char *) * (argc-1)); + for (count = 0; count < argc - 1; count++) + copy[count] = strdup(argv[count + 1]); + // Adding systemd indicator to preserve wrapped process during changing + // root filesystem. We mark wrapper and child process. + copy[0][0] = '@'; + argv[0][0] = '@'; + if (-1 == execvp(argv[1], copy)) { + perror("child process execve failed [%m]"); + return -1; + } +} diff --git a/testModule/wrap b/testModule/wrap deleted file mode 100755 index bb5590d3..00000000 Binary files a/testModule/wrap and /dev/null differ diff --git a/testModule/wrap.c b/testModule/wrap.c deleted file mode 100644 index bfb0b881..00000000 --- a/testModule/wrap.c +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include -#include -#include - -void arg_print(int argc, char *argv[]) { - int i = 0; - int j = 0; - for (i = 0; i < argc; i ++) { - j = 0; - while(argv[i][j] != '\0') - printf("%c", argv[i][j++]); - printf(" "); - } - printf("\n"); -} - - -int main(int argc, char *argv[]) { - - arg_print(argc, argv); - - int count; - char **copy = malloc(sizeof(char *) * (argc-1)); - for ( count = 0; count < argc - 1; count++ ) { - copy[count] = strdup(argv[count + 1]); - } - - arg_print(argc - 1, copy); - - copy[0][0] = '@'; - argv[0][0] = '@'; - - arg_print(argc - 1, copy); - - if (-1 == execvp(argv[1], copy)) { - perror("child process execve failed [%m]"); - return -1; - } -} -- cgit v1.2.3-55-g7522