diff options
| author | torben | 2015-04-09 03:27:39 +0200 |
|---|---|---|
| committer | torben | 2015-04-09 03:27:39 +0200 |
| commit | 3541f12849b277a2405a4d3bf692cf62f2045126 (patch) | |
| tree | 065f302e6fe108d53771bf421429224202ba33f1 | |
| parent | Trying convert given pxe ip configuration to dracut compatible one. (diff) | |
| download | systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.tar.gz systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.tar.xz systemd-init-3541f12849b277a2405a4d3bf692cf62f2045126.zip | |
Adding functions library.
| -rwxr-xr-x | grub2.conf | 6 | ||||
| -rwxr-xr-x | testModule/busybox | bin | 0 -> 931664 bytes | |||
| -rw-r--r-- | testModule/library.sh | 38 | ||||
| -rw-r--r-- | testModule/module-setup.sh | 5 | ||||
| -rw-r--r-- | testModule/parse-ip.sh | 30 |
5 files changed, 55 insertions, 24 deletions
@@ -1,13 +1,13 @@ #!/bin/sh exec tail -n +3 $0 -menuentry 'test' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-123.el7.x86_64-advanced-6c06919a-389a-4a50-8c6b-b086e65db9b0' { +menuentry 'test' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-229.1.2.el7.x86_64-advanced-6c06919a-389a-4a50-8c6b-b086e65db9b0' { insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' - linux16 /vmlinuz-3.10.0-123.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break=cleanup root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp - # TRY: linux16 /vmlinuz-3.10.0-123.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break=cleanup root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp + linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break=cleanup root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug test=hans # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp + # TRY: linux16 /vmlinuz-3.10.0-229.1.2.el7.x86_64 ro vconsole.font=latarcyrheb-sun16 vconsole.keymap=de rd.break=cleanup root=UUID=6c06919a-389a-4a50-8c6b-b086e65db9b0 rd.udev.log-priority=debug ip=10.0.2.15:132.230.4.2:10.0.2.2:255.255.255.0 # NOTE: Prevents dracut console: console=tty0 console=ttyS0,9600 ip=enp0s3:dhcp # selxsrv=132.230.4.2 slxbase=boot/openselx-productive quiet splash vga=current wurstgesicht initrd=http://132.230.4.2/boot/openslx-productive/initramfs-stage31 ip=132.230.4.67:132.230.4.2:132.230.4.254:255.255.255.0 BOOTIF=01-08-00-27-60-49-62 BOOT_IMAGE=http://132.230.4.2/boot/openslx-productive/kernel initrd16 /initramfs-test.img diff --git a/testModule/busybox b/testModule/busybox Binary files differnew file mode 100755 index 00000000..1212ae20 --- /dev/null +++ b/testModule/busybox diff --git a/testModule/library.sh b/testModule/library.sh new file mode 100644 index 00000000..d3f97aff --- /dev/null +++ b/testModule/library.sh @@ -0,0 +1,38 @@ +cat /proc/cmdline >/tmp/cmdline + +replace_cmd() { + sed --regexp-extended "s/$1=[^ ]*/$1=$2/g" /tmp/cmdline -i +} + +getcmdline() { + local _line + local _i + local CMDLINE_ETC_D + local CMDLINE_ETC + unset _line + + if [ -e /etc/cmdline ]; then + while read -r _line; do + CMDLINE_ETC="$CMDLINE_ETC $_line"; + done </etc/cmdline; + fi + for _i in /etc/cmdline.d/*.conf; do + [ -e "$_i" ] || continue + while read -r _line; do + CMDLINE_ETC_D="$CMDLINE_ETC_D $_line"; + done <"$_i"; + done + ## NOTE: We modify this to be able to alter kernel command line arguments + ## at runtime. + if [ -e /tmp/cmdline ]; then + read -r CMDLINE </tmp/cmdline; + CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE" + else + ## + if [ -e /proc/cmdline ]; then + read -r CMDLINE </proc/cmdline; + CMDLINE="$CMDLINE_ETC_D $CMDLINE_ETC $CMDLINE" + fi + fi + printf "%s" "$CMDLINE" +} diff --git a/testModule/module-setup.sh b/testModule/module-setup.sh index b06de3f5..8b35d52a 100644 --- a/testModule/module-setup.sh +++ b/testModule/module-setup.sh @@ -10,11 +10,14 @@ depends() { } install() { + # Loads globally needed useful functions or fixes some native dracut ones. + inst_hook cmdline 10 "$moddir/library.sh" # 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_simple "$moddir/busybox" /usr/bin/busybox #inst_hook pre-mount 20 "$moddir/setup_network.sh" - inst_multiple ping ip ifconfig mount sshd htop dhclient tail head cat vim touch + inst_multiple ping ip ifconfig sshd htop dhclient tail head cat vim touch sed return 0 } diff --git a/testModule/parse-ip.sh b/testModule/parse-ip.sh index 75fca7b2..2f720c57 100644 --- a/testModule/parse-ip.sh +++ b/testModule/parse-ip.sh @@ -1,19 +1,12 @@ # 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 + local temp="$parameter:" set -- - while [ -n "$parameter" ]; do - set -- "$@" "${parameter%%:*}" - parameter=${parameter#*:} - warn - warn JAU - warn + while [ -n "$temp" ]; do + set -- "$@" "${temp%%:*}" + temp=${temp#*:} done [ -n "$1" ] && ip=$1 @@ -21,17 +14,14 @@ for parameter in $(getargs ip=); do [ -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 + local gateway_ip="$broadcast_ip" + repace_cmd test "$ip::$gateway_ip:$net_mask:dracut_test_client:enp0s3:none" done -#cat /proc/cmdline | sed --regexp-extended 's/ ip=[^ ]+//g' \ +# 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 --bind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline +#mount -n --rbind -o ro "$temporary_kernel_commandline_file_path" /proc/cmdline |
