summaryrefslogtreecommitdiffstats
path: root/testModule
diff options
context:
space:
mode:
authortorben2015-04-09 02:02:46 +0200
committertorben2015-04-09 02:02:46 +0200
commit46dfa60a5faf8c460143beabb9592588abed3902 (patch)
tree3842b8b856741ffb54aa0acad68ea8c85f5ff742 /testModule
parentRemove old approach to get internet. Adding command line parsing for (diff)
downloadsystemd-init-46dfa60a5faf8c460143beabb9592588abed3902.tar.gz
systemd-init-46dfa60a5faf8c460143beabb9592588abed3902.tar.xz
systemd-init-46dfa60a5faf8c460143beabb9592588abed3902.zip
Trying convert given pxe ip configuration to dracut compatible one.
Diffstat (limited to 'testModule')
-rw-r--r--testModule/ifcfg-enp0s316
-rw-r--r--testModule/module-setup.sh8
-rw-r--r--testModule/network.functions40
-rw-r--r--testModule/parse-ip.sh36
-rw-r--r--testModule/setup_network.sh2
5 files changed, 61 insertions, 41 deletions
diff --git a/testModule/ifcfg-enp0s3 b/testModule/ifcfg-enp0s3
deleted file mode 100644
index 2a2d9338..00000000
--- a/testModule/ifcfg-enp0s3
+++ /dev/null
@@ -1,16 +0,0 @@
-HWADDR=08:00:27:5A:D1:40
-TYPE=Ethernet
-BOOTPROTO=dhcp
-DEFROUTE=yes
-PEERDNS=yes
-PEERROUTES=yes
-IPV4_FAILURE_FATAL=no
-IPV6INIT=yes
-IPV6_AUTOCONF=yes
-IPV6_DEFROUTE=yes
-IPV6_PEERDNS=yes
-IPV6_PEERROUTES=yes
-IPV6_FAILURE_FATAL=no
-NAME=enp0s3
-UUID=5a775495-24d5-4d13-8c06-0196cf621bf1
-ONBOOT=yes
diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh
index 652602f5..b06de3f5 100644
--- a/testModule/module-setup.sh
+++ b/testModule/module-setup.sh
@@ -10,9 +10,11 @@ depends() {
}
install() {
- inst_hook cmdline 20 "$moddir/parse-ip.sh"
- inst_hook pre-mount 20 "$moddir/setup_network.sh"
- inst_multiple ping ip ifconfig mount sshd htop dhclient
+ # 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 pre-mount 20 "$moddir/setup_network.sh"
+ inst_multiple ping ip ifconfig mount sshd htop dhclient tail head cat vim touch
return 0
}
diff --git a/testModule/network.functions b/testModule/network.functions
index dc5dd52e..89ca5a20 100644
--- a/testModule/network.functions
+++ b/testModule/network.functions
@@ -1,23 +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)"
+ 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
index 07f61d50..75fca7b2 100644
--- a/testModule/parse-ip.sh
+++ b/testModule/parse-ip.sh
@@ -1,3 +1,37 @@
+# Converts ip configuration format given by the pxe pre boot provider to a
+# dracut compatible static ip configuration.
+
+temporary_kernel_commandline_file_path='/temporary_kernel_commandline.txt'
+warn
+warn 'Running ip kernel command line transformation.'
+warn
+
for parameter in $(getargs ip=); do
- COMMAND_LINE_IP="$parameter"
+ set --
+ while [ -n "$parameter" ]; do
+ set -- "$@" "${parameter%%:*}"
+ parameter=${parameter#*:}
+ warn
+ warn JAU
+ warn
+ done
+
+ [ -n "$1" ] && ip=$1
+ [ -n "$2" ] && server_ip=$2
+ [ -n "$3" ] && broadcast_ip=$3
+ [ -n "$4" ] && net_mask=$4
+
+ warn
+ warn "PXE given net configuration: ip: $ip server_ip: $server_ip broadcast_ip: $broadcast_ip net_mask: $net_mask"
+ warn
+ # TODO
+ gateway_ip="$broadcast_ip"
+ echo "ip=$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" > /etc/cmdline
+ warn
+ warn "Converted ip configuration: \"$ip\"."
+ warn
done
+
+#cat /proc/cmdline | sed --regexp-extended 's/ ip=[^ ]+//g' \
+# >"$temporary_kernel_commandline_file_path" && \
+#mount -n --bind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline
diff --git a/testModule/setup_network.sh b/testModule/setup_network.sh
index b1334a2b..3b32a68c 100644
--- a/testModule/setup_network.sh
+++ b/testModule/setup_network.sh
@@ -1,4 +1,4 @@
-#!/bin/ash
+#!/bin/bash
echo "Setting up network..."