blob: 20041ecfa3d5cc8201a76db93d9d365a7b4cb33e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/usr/bin/env bash
# -*- coding: utf-8 -*-
# region imports
source '/usr/lib/rebash/core.sh'
core.import exceptions
core.import logging
# endregion
(
logging.set_commands_level debug
logging.set_level debug
[[ "$SLX_LOG_FILE_PATH" == "" ]] && SLX_LOG_FILE_PATH=/var/log/openslx
logging.set_log_file "$SLX_LOG_FILE_PATH"
SLX_INITIAL_KERNEL_COMMAND_LINE="$(cat /proc/cmdline | tr --delete '\n')"
# This location will be used to have a writable kernel command line file
# location.
writeable_proc_cmdline_path='/writable_proc_cmdline/'
mkdir --parents "$writeable_proc_cmdline_path"
# NOTE: The fake writeable overlay have to be a temporary filesystem for the
# hack to work.
mount --types tmpfs tmpfs "$writeable_proc_cmdline_path"
echo -n "$SLX_INITIAL_KERNEL_COMMAND_LINE" > \
"${writeable_proc_cmdline_path}/cmdline"
logging.debug \
'-----------------------Kernel-Command-Line:------------------------------'
logging.debug "${SLX_INITIAL_KERNEL_COMMAND_LINE}"
logging.debug \
'-------------------------------------------------------------------------'
for parameter in $(getargs BOOTIF=); do
logging.debug "PXE given boot interface $parameter"
dracut_interface_name="bootnet:$(echo $parameter | \
sed --regexp-extended 's/.{2}[:\-]((.{2}[:\-]){5}.{2})/\1/' | \
sed s/-/:/g)"
logging.debug "Dracut interface name is: $dracut_interface_name"
logging.plain -n " ifname=$dracut_interface_name" >> \
"${writeable_proc_cmdline_path}cmdline"
done
for parameter in $(getargs ip=); do
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
logging.debug "PXE given net configuration: ip: $ip server_ip: $server_ip gateway_ip: $gateway_ip net_mask: $net_mask"
dracut_ip_configuration="$ip::$gateway_ip:$net_mask::bootnet:off"
logging.debug "Dracut ip configuration is: $dracut_ip_configuration"
sed --regexp-extended "s/ip=[^ ]*/ip=$dracut_ip_configuration/g" \
--in-place "${writeable_proc_cmdline_path}cmdline"
done
if [ -z "$dracut_ip_configuration" ]; then
logging.warn 'No "ip" parameter found in the kernel command line.'
fi
if [ -z "$dracut_interface_name" ]; then
logging.warn 'No "BOOTIF" parameter found in the kernel command line.'
fi
mount --options bind "${writeable_proc_cmdline_path}cmdline" /proc/cmdline
if [ -z "$(getargs slxsrv=)" ]; then
logging.warn 'No "slxsrv" parameter found in the kernel command line.'
exit 1
fi
if [ -z "$(getargs slxbase=)" ]; then
logging.warn 'No "slxbase" parameter found in the kernel command line.'
exit 1
fi
logging.debug \
'-----------------------Dracut-Kernel-Command-Line:-----------------------'
logging.debug "$(logging.cat /proc/cmdline)"
logging.debug \
'-------------------------------------------------------------------------'
)
# region vim modline
# vim: set tabstop=4 shiftwidth=4 expandtab:
# vim: foldmethod=marker foldmarker=region,endregion:
# endregion
|