- realted to trac#927

Signed-off-by: Jakub Filak <[email protected]>
---
 .gitignore                       |  1 +
 src/hooks/Makefile.am            |  6 +++-
 src/hooks/abrt-harvest-vmcore    | 63 -------------------------------------
 src/hooks/abrt-harvest-vmcore.in | 68 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 64 deletions(-)
 delete mode 100755 src/hooks/abrt-harvest-vmcore
 create mode 100644 src/hooks/abrt-harvest-vmcore.in

diff --git a/.gitignore b/.gitignore
index af61b26..039b9f6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,7 @@ src/plugins/abrt-action-install-debuginfo
 src/plugins/abrt-action-generate-core-backtrace
 src/plugins/abrt-bodhi
 src/hooks/abrt_exception_handler.py
+src/hooks/abrt-harvest-vmcore
 src/hooks/abrt-hook-ccpp
 src/hooks/abrt-install-ccpp-hook
 src/applet/abrt-applet.desktop
diff --git a/src/hooks/Makefile.am b/src/hooks/Makefile.am
index 982803e..fe0c8db 100644
--- a/src/hooks/Makefile.am
+++ b/src/hooks/Makefile.am
@@ -33,7 +33,7 @@ abrt_hook_ccpp_LDADD = \
 python_PYTHON = abrt.pth abrt_exception_handler.py
 EXTRA_DIST = abrt_exception_handler.py.in \
        abrt-install-ccpp-hook.in \
-       abrt-harvest-vmcore
+       abrt-harvest-vmcore.in
 
 CLEANFILES := $(notdir $(wildcard *~)) $(notdir $(wildcard *\#)) $(notdir 
$(wildcard \.\#*)) $(notdir $(wildcard *.pyc)) $(man1_MANS)
 
@@ -56,3 +56,7 @@ abrt-install-ccpp-hook: abrt-install-ccpp-hook.in
        sed -e s,\@VAR_RUN\@,$(VAR_RUN),g \
            -e s,\@libexecdir\@,$(libexecdir),g \
                $< >$@
+
+abrt-harvest-vmcore: abrt-harvest-vmcore.in
+       sed -e s,\@CONF_DIR\@,\$(CONF_DIR)\,g \
+               $< >$@
diff --git a/src/hooks/abrt-harvest-vmcore b/src/hooks/abrt-harvest-vmcore
deleted file mode 100755
index dbca8ca..0000000
--- a/src/hooks/abrt-harvest-vmcore
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-#
-# This script is meant to be run once at system startup after abrtd is up
-# and running. It moves all vmcore directories in /var/crash
-# (which are presumably created by kdump) to abrtd spool directory.
-#
-# The goal is to let abrtd notice and process them as new problem data dirs.
-#
-
-cd /var/crash 2>/dev/null || exit 0
-
-# Wait for abrtd to start. Give it at least 1 second to initialize.
-i=10
-while ! pidof abrtd >/dev/null; do
-       if test $((i--)) = 0; then
-               exit 1
-       fi
-       sleep 1
-done
-sleep 1
-
-umask 077
-
-CopyVMcore=`sed -n '/^CopyVMcore[ \t]*=/ s/.*=[ \t]*//p' 
/etc/abrt/abrt-harvest-vmcore.conf 2>/dev/null`
-
-move_core=false
-if test x"$CopyVMcore" = x"no" || test x"$CopyVMcore" = x"0"; then
-       move_core=true
-fi
-
-for d in *; do
-       test -d "$d" || continue
-       test -f "$d/vmcore" || continue
-
-       # Let abrtd know what type of problem it is:
-       printf 'vmcore' >"$d/analyzer"
-       printf 'vmcore' >"$d/type"
-       printf 'kernel' >"$d/component"
-       printf '%s' "`date '+%s'`" >"$d/time"
-       printf '0' >"$d/uid"
-       # TODO: need to generate *real* UUID,
-       # one which has a real chance of catching dups!
-       # This one generates different hashes even for similar cores:
-       printf '%s' "`sha1sum <"$d/vmcore" | cut -d" " -f1`" >"$d/uuid"
-
-       # Move vmcore directory to abrt spool dir.
-       # We use .new suffix - we must make sure abrtd doesn't try
-       # to process partially-copied directory.
-       #
-       # This is the efficient way:
-       #mv -- "$d" "/var/spool/abrt/vmcore-$d.new" || continue
-       # ...and this is what selinux forces me to do
-       # (otherwise files have wrong context and abrtd can't access them):
-       cp -r --no-preserve=all -- "$d" "/var/spool/abrt/vmcore-$d.new" || {
-               rm -rf "/var/spool/abrt/vmcore-$d.new"
-               continue
-       }
-       $move_core && rm -rf -- "$d"
-
-       chown -R 0:0 "/var/spool/abrt/vmcore-$d.new"
-       chmod -R u+rwX,go-rwxst "/var/spool/abrt/vmcore-$d.new"
-       mv "/var/spool/abrt/vmcore-$d.new" "/var/spool/abrt/vmcore-$d"
-done
diff --git a/src/hooks/abrt-harvest-vmcore.in b/src/hooks/abrt-harvest-vmcore.in
new file mode 100644
index 0000000..3c463df
--- /dev/null
+++ b/src/hooks/abrt-harvest-vmcore.in
@@ -0,0 +1,68 @@
+#!/bin/sh
+#
+# This script is meant to be run once at system startup after abrtd is up
+# and running. It moves all vmcore directories in /var/crash
+# (which are presumably created by kdump) to abrtd spool directory.
+#
+# The goal is to let abrtd notice and process them as new problem data dirs.
+#
+
+cd /var/crash 2>/dev/null || exit 0
+
+# Wait for abrtd to start. Give it at least 1 second to initialize.
+i=10
+while ! pidof abrtd >/dev/null; do
+       if test $((i--)) = 0; then
+               exit 1
+       fi
+       sleep 1
+done
+sleep 1
+
+umask 077
+
+CopyVMcore=`sed -n '/^CopyVMcore[ \t]*=/ s/.*=[ \t]*//p' 
@CONF_DIR@/abrt-harvest-vmcore.conf 2>/dev/null`
+ABRTDumpDir=`sed -n '/^DumpLocation [ \t]*=/ s/.*=[ \t]*//p' 
@CONF_DIR@/abrt.conf 2>/dev/null`
+
+if test -z "$ABRTDumpDir"; then
+    ABRTDumpDir="/var/spool/abrt"
+fi
+
+move_core=false
+if test x"$CopyVMcore" = x"no" || test x"$CopyVMcore" = x"0"; then
+       move_core=true
+fi
+
+for d in *; do
+       test -d "$d" || continue
+       test -f "$d/vmcore" || continue
+
+       # Let abrtd know what type of problem it is:
+       printf 'vmcore' >"$d/analyzer"
+       printf 'vmcore' >"$d/type"
+       printf 'kernel' >"$d/component"
+       printf '%s' "`date '+%s'`" >"$d/time"
+       printf '0' >"$d/uid"
+       # TODO: need to generate *real* UUID,
+       # one which has a real chance of catching dups!
+       # This one generates different hashes even for similar cores:
+       printf '%s' "`sha1sum <"$d/vmcore" | cut -d" " -f1`" >"$d/uuid"
+
+       # Move vmcore directory to abrt spool dir.
+       # We use .new suffix - we must make sure abrtd doesn't try
+       # to process partially-copied directory.
+       #
+       # This is the efficient way:
+       #mv -- "$d" "/var/spool/abrt/vmcore-$d.new" || continue
+       # ...and this is what selinux forces me to do
+       # (otherwise files have wrong context and abrtd can't access them):
+       cp -r --no-preserve=all -- "$d" "$ABRTDumpDir/vmcore-$d.new" || {
+               rm -rf "$ABRTDumpDir/vmcore-$d.new"
+               continue
+       }
+       $move_core && rm -rf -- "$d"
+
+       chown -R 0:0 "$ABRTDumpDir/vmcore-$d.new"
+       chmod -R u+rwX,go-rwxst "$ABRTDumpDir/vmcore-$d.new"
+       mv "$ABRTDumpDir/vmcore-$d.new" "$ABRTDumpDir/vmcore-$d"
+done
-- 
1.7.11.7

Reply via email to