diff options
| author | jandob | 2016-03-24 17:49:09 +0100 |
|---|---|---|
| committer | jandob | 2016-03-24 17:49:09 +0100 |
| commit | f788dbdbe414089a728be044b2603dc3db475f75 (patch) | |
| tree | 28a503ec8815d22d019f6971a4a5595e696215be /builder/dnbd3-rootfs | |
| parent | update rebash (log file support) (diff) | |
| parent | Improve openslx config file. (diff) | |
| download | systemd-init-f788dbdbe414089a728be044b2603dc3db475f75.tar.gz systemd-init-f788dbdbe414089a728be044b2603dc3db475f75.tar.xz systemd-init-f788dbdbe414089a728be044b2603dc3db475f75.zip | |
Merge branch 'master' of git.openslx.org:openslx-ng/systemd-init
Diffstat (limited to 'builder/dnbd3-rootfs')
| -rwxr-xr-x | builder/dnbd3-rootfs/debugging-tools/endless | bin | 6752 -> 0 bytes | |||
| -rw-r--r-- | builder/dnbd3-rootfs/debugging-tools/endless.c | 10 | ||||
| -rw-r--r-- | builder/dnbd3-rootfs/debugging-tools/network.functions | 23 | ||||
| -rw-r--r-- | builder/dnbd3-rootfs/debugging-tools/setup-network.sh | 84 | ||||
| -rwxr-xr-x | builder/dnbd3-rootfs/hooks/prepare-root-partition.sh | 39 |
5 files changed, 15 insertions, 141 deletions
diff --git a/builder/dnbd3-rootfs/debugging-tools/endless b/builder/dnbd3-rootfs/debugging-tools/endless Binary files differdeleted file mode 100755 index de7a8c0a..00000000 --- a/builder/dnbd3-rootfs/debugging-tools/endless +++ /dev/null diff --git a/builder/dnbd3-rootfs/debugging-tools/endless.c b/builder/dnbd3-rootfs/debugging-tools/endless.c deleted file mode 100644 index 22c9bc50..00000000 --- a/builder/dnbd3-rootfs/debugging-tools/endless.c +++ /dev/null @@ -1,10 +0,0 @@ -#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/builder/dnbd3-rootfs/debugging-tools/network.functions b/builder/dnbd3-rootfs/debugging-tools/network.functions deleted file mode 100644 index 89ca5a20..00000000 --- a/builder/dnbd3-rootfs/debugging-tools/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/builder/dnbd3-rootfs/debugging-tools/setup-network.sh b/builder/dnbd3-rootfs/debugging-tools/setup-network.sh deleted file mode 100644 index 3b32a68c..00000000 --- a/builder/dnbd3-rootfs/debugging-tools/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/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh index 79cb6225..b57a915c 100755 --- a/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh +++ b/builder/dnbd3-rootfs/hooks/prepare-root-partition.sh @@ -18,36 +18,27 @@ source /etc/openslx if [[ "$SLX_WRITABLE_DEVICE_IDENTIFIER" != '' ]] && ! persistent_device="$( tools.find_block_device "$SLX_WRITABLE_DEVICE_IDENTIFIER" '' \ - "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT" + "$SLX_WRITABLE_DEVICE_IDENTIFIER_TIMEOUT_IN_SECONDS" )" then logging.warn "Failed to find unique device with identifier" \ "\"${SLX_WRITABLE_DEVICE_IDENTIFIER}\"; matched devices:" \ "\"${persistent_device}\"" fi - -# TODO move somewhere else -#tmp_device="$(tools.find_block_device \ - #'$SLX_TMP_PARTITION_IDENTIFIER')" - -#if [ -n $tmp_device ]; then - #mount --type auto "$tmp_device" "$NEWROOT/tmp" -#fi - -if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE" ] && [ -n "$persistent_device" ] +if [ -n "$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" ] && [ -n "$persistent_device" ] then persistent_mountpoint=/mnt/slx_writable_device - storage_file=$persistent_mountpoint/$SLX_WRITABLE_DEVICE_STORAGE_FILE - ! mkdir --parents $persistent_mountpoint + storage_file_path="${persistent_mountpoint}/$SLX_WRITABLE_DEVICE_STORAGE_FILE_PATH" + ! mkdir --parents "$(dirname "$storage_file_path")" if ! mount --type auto "$persistent_device" "$persistent_mountpoint"; then logging.warn "Failed to mount $persistent_device, checking filesystem." - ! $SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CHECK_COMMAND \ + ! $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CHECK_COMMAND \ "$persistent_device" if ! mount --type auto "$persistent_device" "$persistent_mountpoint" then logging.warn "Mounting $persistent_device, still failing," \ "creating new filesystem on device" - $SLX_WRITABLE_DEVICE_STORAGE_FILSYSTEM_CREATE_COMMAND \ + $SLX_WRITABLE_DEVICE_STORAGE_FILESYSTEM_CREATE_COMMAND \ "$persistent_device" fi if ! mount --type auto "$persistent_device" "$persistent_mountpoint" @@ -58,13 +49,13 @@ then fi fi if [ -n "$persistent_device" ]; then - if [ ! -e "$storage_file" ]; then + if [ ! -e "$storage_file_path" ]; then # Create a sparse file. - dd of="$storage_file" bs=1M \ - seek="$SLX_WRITABLE_DEVICE_STORAGE_FILE_MAX_SIZE_MB" count=0 + dd of="$storage_file_path" bs=1M \ + seek="$SLX_WRITABLE_DEVICE_STORAGE_MAXIMUM_FILE_SIZE_IN_MB" count=0 fi persistent_device="$(losetup --find)" - losetup "$persistent_device" "$storage_file" + losetup "$persistent_device" "$storage_file_path" fi fi @@ -77,19 +68,19 @@ if [ -n "$persistent_device" ]; then persistent='P' fi else - ramdisk_size="$SLX_RAMDISK_SIZE" - if [ "$ramdisk_size" = '' ]; then - ramdisk_size="$(awk '/MemTotal/ {print $2}' /proc/meminfo)" + ramdisk_size_in_kb="$SLX_RAMDISK_SIZE_IN_KB" + if [ "$ramdisk_size_in_kb" = '' ]; then + ramdisk_size_in_kb="$(awk '/MemTotal/ {print $2}' /proc/meminfo)" fi # NOTE: If the kernel modul "brd" is compiled into current kernel we can't # configure ram disk size dynamically. In this case it have to be # configured via kernel command line: "brd.rd_size=SITE_IN_KILOBYTE" # statically: #! rmmod brd 2>/dev/null - #modprobe brd max_part=1 rd_size="$ramdisk_size" + #modprobe brd max_part=1 rd_size="$ramdisk_size_in_kb" #writable_device='/dev/ram0' ramdisk_location="$(mktemp)" - dd of="$ramdisk_location" seek="$ramdisk_size" count=0 1>/dev/null + dd of="$ramdisk_location" seek="$ramdisk_size_in_kb" count=0 1>/dev/null writable_device="$(losetup --find)" losetup "$writable_device" "$ramdisk_location" fi |
