diff --git a/.gitignore b/.gitignore index 7a38a39..e9c2dd8 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ /kexec-tools-2.0.11.tar.xz /makedumpfile-1.5.9.tar.gz /kexec-tools-2.0.12.tar.xz +coverage/ diff --git a/kdump-lib.sh b/kdump-lib.sh index 5b1656e..557eff6 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -2,8 +2,11 @@ # # Kdump common variables and functions # - -. /usr/lib/kdump/kdump-lib-initramfs.sh +if [[ ${__SOURCED__:+x} ]]; then + . ./kdump-lib-initramfs.sh +else + . /lib/kdump/kdump-lib-initramfs.sh +fi FADUMP_ENABLED_SYS_NODE="/sys/kernel/fadump_enabled" diff --git a/kdumpctl b/kdumpctl index 4d819c2..6188d47 100755 --- a/kdumpctl +++ b/kdumpctl @@ -32,8 +32,14 @@ fi [[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut . $dracutbasedir/dracut-functions.sh -. /lib/kdump/kdump-lib.sh -. /lib/kdump/kdump-logger.sh + +if [[ ${__SOURCED__:+x} ]]; then + KDUMP_LIB_PATH=. +else + KDUMP_LIB_PATH=/lib/kdump +fi +. $KDUMP_LIB_PATH/kdump-lib.sh +. $KDUMP_LIB_PATH/kdump-logger.sh #initiate the kdump logger if ! dlog_init; then @@ -1676,11 +1682,6 @@ reset_crashkernel_for_installed_kernel() fi } -if [[ ! -f $KDUMP_CONFIG_FILE ]]; then - derror "Error: No kdump config file found!" - exit 1 -fi - main() { # Determine if the dump mode is kdump or fadump @@ -1753,6 +1754,15 @@ main() esac } +if [[ ${__SOURCED__:+x} ]]; then + return +fi + +if [[ ! -f $KDUMP_CONFIG_FILE ]]; then + derror "Error: No kdump config file found!" + exit 1 +fi + # Other kdumpctl instances will block in queue, until this one exits single_instance_lock