On 04/18/16 at 03:23pm, Pratyush Anand wrote:
Relevant kdump files are also part of system. Therefore, moving logic
of
file modification checking in is_system_modified() function now.
Signed-off-by: Pratyush Anand <panand(a)redhat.com>
---
kdumpctl | 65 ++++++++++++++++++++++++++++++++++++++++------------------------
1 file changed, 41 insertions(+), 24 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 64dc92da605b..8ef11501342b 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -327,19 +327,59 @@ setup_target_initrd()
fi
}
+is_files_modified()
+{
+ local modified_files=""
+
+ #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled.
+ modified_files=$(get_pcs_cluster_modified_files $image_time)
+
+ EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
+ CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
+ EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
+ CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
+ EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
+ files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS /etc/fstab"
+
+ check_exist "$files" && check_executable "$EXTRA_BINS"
+ [ $? -ne 0 ] && return 2
+
+ for file in $files; do
+ time_stamp=`stat -c "%Y" $file`
+ if [ "$time_stamp" -gt "$image_time" ]; then
Since we use image_time in both this function and check_rebuild, how about
add a global var in the head of the file or passing it as an argument?
+ modified_files="$modified_files $file"
+ fi
+ done
+ if [ -n "$modified_files" ]; then
+ echo "Detected change(s) in the following file(s):"
+ echo -n " "; echo "$modified_files" | sed 's/\s/\n /g'
+ return 1
+ fi
+
+ return 0
+}
+
# returns 0 if system is not modified
# returns 1 if system is modified
# returns 2 if system modification is invalid
is_system_modified()
{
+ local ret
+
[[ -f $TARGET_INITRD ]] || return 1
+ is_files_modified
+ ret=$?
+ if [ "$ret" -ne 0 ]; then
Ditto about a nitpick "$ret" quotation..
> + return $ret
> + fi
> +
> return 0
> }
>
> check_rebuild()
> {
> - local extra_modules modified_files=""
> + local extra_modules
> local _force_rebuild force_rebuild="0"
> local ret system_modified="0"
> local initramfs_has_fadump
> @@ -379,26 +419,6 @@ check_rebuild()
> image_time=0
> fi
>
> - #also rebuild when Pacemaker cluster conf is changed and fence kdump is enabled.
> - modified_files=$(get_pcs_cluster_modified_files $image_time)
> -
> - EXTRA_BINS=`grep ^kdump_post $KDUMP_CONFIG_FILE | cut -d\ -f2`
> - CHECK_FILES=`grep ^kdump_pre $KDUMP_CONFIG_FILE | cut -d\ -f2`
> - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
> - CHECK_FILES=`grep ^extra_bins $KDUMP_CONFIG_FILE | cut -d\ -f2-`
> - EXTRA_BINS="$EXTRA_BINS $CHECK_FILES"
> - files="$KDUMP_CONFIG_FILE $kdump_kernel $EXTRA_BINS /etc/fstab"
> -
> - check_exist "$files" && check_executable "$EXTRA_BINS"
> - [ $? -ne 0 ] && return 1
> -
> - for file in $files; do
> - time_stamp=`stat -c "%Y" $file`
> - if [ "$time_stamp" -gt "$image_time" ]; then
> - modified_files="$modified_files $file"
> - fi
> - done
> -
> is_system_modified
> ret=$?
> if [ "$ret" -eq 2 ]; then
> @@ -420,9 +440,6 @@ check_rebuild()
> echo -n "Force rebuild $TARGET_INITRD"; echo
> elif [ "$system_modified" != "0" ]; then
> echo -n "System has been modified"; echo
> - elif [ -n "$modified_files" ]; then
> - echo "Detected change(s) in the following file(s):"
> - echo -n " "; echo "$modified_files" | sed 's/\s/\n
/g'
> else
> return 0
> fi
> --
> 2.5.0
> _______________________________________________
> kexec mailing list
> kexec(a)lists.fedoraproject.org
>
http://lists.fedoraproject.org/admin/lists/kexec@lists.fedoraproject.org