On 08/15/2013 05:24 PM, wmealing(a)redhat.com wrote:
From: Wade Mealing <wmealing(a)redhat.com>
The RHEL 5 release of mkdumprd allowed for comments in the kdump config file as shown
below:
net 192.168.1.1 # this is the comment part
The Fedora 18/19/Rawhide release would fail when inline comments were used
at runtime and when building the initrd.
This patch introduces a function which is repeated a few times, but
could be broken out at a later date into its an existing or new shell
library which could be source.
This patch does not introduce any new functionality.
I have not tested this patch as I do not yet have build permissions on koji.
Hi, Wade
There's several trailing white space otherwise code looks good.
For testing, you can just copy these files to test machine:
cp dracut-kdump.sh /usr/lib/dracut/modules.d/99kdumpbase/kdump.sh
cp dracut-module-setup.sh /usr/lib/dracut/modules.d/99kdumpbase/module-setup.sh
cp kdumpctl /bin/kdumpctl
cp mkdumprd /usr/sbin/mkdumprd
Or use fedpkg to create a srpm for rebuilding rpm
$fedpkg srpm
$rpmbuild --rebuild [srpm]
---
dracut-kdump.sh | 8 ++++++++
dracut-module-setup.sh | 7 +++++++
kdumpctl | 14 +++++++++++++-
mkdumprd | 6 ++++++
4 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index 7baa673..fab176a 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -230,6 +230,10 @@ get_host_ip()
return 0
}
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
read_kdump_conf()
{
if [ ! -f "$conf_file" ]; then
@@ -240,6 +244,8 @@ read_kdump_conf()
# first get the necessary variables
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
path)
KDUMP_PATH="$config_val"
@@ -283,6 +289,8 @@ read_kdump_conf()
# rescan for add code for dump target
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
ext[234]|xfs|btrfs|minix|nfs)
add_dump_code "dump_fs $config_val"
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index 099c03a..2ef76f5 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -62,6 +62,11 @@ kdump_is_vlan() {
[ -f /proc/net/vlan/"$1" ]
}
Above line contains trailing white space.
+# $1 is the full line from the config file
above line
contains trailing white space, can remove the above
comment, because it's not always the full line.
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
# $1: netdev name
kdump_setup_dns() {
_dnsfile=${initdir}/etc/cmdline.d/42dns.conf
@@ -252,6 +257,8 @@ kdump_install_conf() {
while read config_opt config_val;
do
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
case "$config_opt" in
ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#"
/tmp/$$-kdump.conf
diff --git a/kdumpctl b/kdumpctl
index aba1e3c..4a09a6c 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -78,6 +78,12 @@ function check_exist()
done
}
+# $1 is the full line parsed from the file.
ditto
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
One more blank line?
+
#$1: the files to be checked with IFS=' '
function check_executable()
{
@@ -100,7 +106,10 @@ function check_config()
}
while read config_opt config_val; do
- case "$config_opt" in
+ # remove inline comments after the end of a directive.
+ config_val=$(strip_comments $config_val)
+
ditto
> + case "$config_opt" in
> \#* | "")
> ;;
>
raw|ext2|ext3|ext4|minix|btrfs|xfs|nfs|ssh|sshkey|path|core_collector|kdump_post|kdump_pre|extra_bins|extra_modules|default|force_rebuild|dracut_args)
> @@ -257,6 +266,9 @@ function load_kdump()
> function check_ssh_config()
> {
> while read config_opt config_val; do
> + # remove inline comments after the end of a directive.
> + config_val=$(strip_comments $config_val)
> +
> case "$config_opt" in
> sshkey)
> if [ -f "$config_val" ]; then
> diff --git a/mkdumprd b/mkdumprd
> index 26fe5af..57217d1 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -518,8 +518,14 @@ if [ "$(uname -m)" = "s390x" ]; then
> add_dracut_module "znet"
> fi
>
+strip_comments() {
+ echo $1 | sed -e 's/\(.*\)#.*/\1/'
+}
+
> while read config_opt config_val;
> do
> + # remove inline comments after the end of a directive.
> + config_val=$(strip_comments $config_val)
> case "$config_opt" in
> extra_modules)
> extra_modules="$extra_modules $config_val"
>
--
Thanks
Dave