From 2b2f3018bd91e50c874cfab4df4a847941cb140c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 20 Apr 2011 13:53:42 +0200 Subject: run abrt oops log scanner as a separate service In preparation for https://fedorahosted.org/abrt/ticket/189 "abrtd should reload configuration when some of it's config files changes" I would like to stop running abrt-dump-oops as a child of abrtd. We experimented with it: we made abrt-ccpp hook (de)installation a separate service, and in my opinion it ended up a better solution than making it a part of daemon. Among other things, it made abrt and abrt-addon-ccpp packages independent. This change does the same for abrt-dump-oops. Signed-off-by: Denys Vlasenko --- abrt-oops.init | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++ abrt.spec | 64 ++++++++++++++++++++++++++++------ scripts/dbg_mkrpm | 3 +- src/daemon/abrt.conf | 8 ++--- 4 files changed, 156 insertions(+), 16 deletions(-) create mode 100644 abrt-oops.init diff --git a/abrt-oops.init b/abrt-oops.init new file mode 100644 index 00000000..cb64daca --- /dev/null +++ b/abrt-oops.init @@ -0,0 +1,97 @@ +#!/bin/bash +# Start ABRT kernel log watcher +# +# chkconfig: 35 82 16 +# description: Watches system log for oops messages, creates ABRT dump directories for each oops +### BEGIN INIT INFO +# Provides: abrt-oops +# Required-Start: $abrtd +# Default-Stop: 0 1 2 6 +# Default-Start: 3 5 +# Short-Description: Watches system log for oops messages, creates ABRT dump directories for each oops +# Description: Watches system log for oops messages, creates ABRT dump directories for each oops +### END INIT INFO + +# Source function library. +. /etc/rc.d/init.d/functions + +# For debugging +dry_run=false +verbose=false + +# We don't have pid files, therefore have to use +# a flag file in /var/lock/subsys to enable GUI service tools +# to figure out our status +LOCK="/var/lock/subsys/abrt-oops" + +RETVAL=0 + +check() { + # Check that we're a privileged user + [ "`id -u`" = 0 ] || exit 4 +} + +start() { + check + killall abrt-dump-oops 2>/dev/null + setsid abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages /dev/null 2>&1 & + $dry_run || touch -- "$LOCK" + return $RETVAL +} + +stop() { + check + killall abrt-dump-oops + $dry_run || rm -f -- "$LOCK" + return $RETVAL +} + +restart() { + stop + start +} + +reload() { + restart +} + +case "$1" in +start) + start + ;; +stop) + stop + ;; +reload) + reload + ;; +force-reload) + echo "$0: Unimplemented feature." + RETVAL=3 + ;; +restart) + restart + ;; +condrestart) + # Is it already running? + if test -f "$LOCK"; then # yes + $verbose && printf "Running, restarting\n" + restart + fi + ;; +status) + # Is it already running? + if test -f "$LOCK"; then # yes + $verbose && printf "Running\n" + RETVAL=0 + else + $verbose && printf "Not running\n" + RETVAL=3 # "stopped normally" + fi + ;; +*) + echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}" + RETVAL=2 +esac + +exit $RETVAL diff --git a/abrt.spec b/abrt.spec index 4f1dffb5..98599ddb 100644 --- a/abrt.spec +++ b/abrt.spec @@ -29,6 +29,7 @@ URL: https://fedorahosted.org/abrt/ Source: https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.gz Source1: abrt.init Source2: abrt-ccpp.init +Source3: abrt-oops.init BuildRequires: dbus-devel BuildRequires: gtk2-devel BuildRequires: curl-devel @@ -281,6 +282,7 @@ find $RPM_BUILD_ROOT -name '*.la' -or -name '*.a' | xargs rm -f mkdir -p ${RPM_BUILD_ROOT}/%{_initrddir} install -m 755 %SOURCE1 ${RPM_BUILD_ROOT}/%{_initrddir}/abrtd install -m 755 %SOURCE2 ${RPM_BUILD_ROOT}/%{_initrddir}/abrt-ccpp +install -m 755 %SOURCE3 ${RPM_BUILD_ROOT}/%{_initrddir}/abrt-oops mkdir -p $RPM_BUILD_ROOT/var/cache/abrt-di mkdir -p $RPM_BUILD_ROOT/var/run/abrt mkdir -p $RPM_BUILD_ROOT/var/spool/abrt @@ -330,7 +332,13 @@ fi # so 2.x fails when it tries to extract debuginfo there.. chown -R abrt:abrt %{_localstatedir}/cache/abrt-di if [ $1 -eq 1 ]; then -/sbin/chkconfig --add abrt-ccpp + /sbin/chkconfig --add abrt-ccpp +fi +#systemd: TODO + +%post addon-kerneloops +if [ $1 -eq 1 ]; then + /sbin/chkconfig --add abrt-oops fi #systemd: TODO @@ -340,27 +348,46 @@ fi %preun if [ "$1" -eq "0" ] ; then - service abrtd stop >/dev/null 2>&1 - /sbin/chkconfig --del abrtd + service abrtd stop >/dev/null 2>&1 + /sbin/chkconfig --del abrtd fi #systemd %if %{?with_systemd} if [ "$1" -eq "0" ] ; then - /bin/systemctl stop abrtd.service >/dev/null 2>&1 || : - /bin/systemctl disable abrtd.service >/dev/null 2>&1 || : + /bin/systemctl stop abrtd.service >/dev/null 2>&1 || : + /bin/systemctl disable abrtd.service >/dev/null 2>&1 || : fi %endif %preun addon-ccpp if [ "$1" -eq "0" ] ; then - service abrt-ccpp stop >/dev/null 2>&1 - /sbin/chkconfig --del abrt-ccpp + service abrt-ccpp stop >/dev/null 2>&1 + /sbin/chkconfig --del abrt-ccpp fi -#systemd: TODO +#systemd (not tested): +%if %{?with_systemd} +if [ "$1" -eq "0" ] ; then + /bin/systemctl stop abrt-ccpp.service >/dev/null 2>&1 || : + /bin/systemctl disable abrt-ccpp.service >/dev/null 2>&1 || : +fi +%endif + +%preun addon-kerneloops +if [ "$1" -eq "0" ] ; then + service abrt-oops stop >/dev/null 2>&1 + /sbin/chkconfig --del abrt-oops +fi +#systemd (not tested): +%if %{?with_systemd} +if [ "$1" -eq "0" ] ; then + /bin/systemctl stop abrt-oops.service >/dev/null 2>&1 || : + /bin/systemctl disable abrt-oops.service >/dev/null 2>&1 || : +fi +%endif %preun retrace-server if [ "$1" = 0 ]; then - /sbin/install-info --delete %{_infodir}/abrt-retrace-server %{_infodir}/dir 2> /dev/null || : + /sbin/install-info --delete %{_infodir}/abrt-retrace-server %{_infodir}/dir 2> /dev/null || : fi %postun @@ -404,7 +431,23 @@ fi if [ "$1" -eq "0" ]; then service abrt-ccpp condrestart >/dev/null 2>&1 || : fi -#systemd: TODO +#systemd +%if %{?with_systemd} +if [ "$1" -eq "0" ]; then + /bin/systemctl try-restart abrt-ccpp.service >/dev/null 2>&1 || : +fi +%endif + +%posttrans addon-kerneloops +if [ "$1" -eq "0" ]; then + service abrt-oops condrestart >/dev/null 2>&1 || : +fi +#systemd +%if %{?with_systemd} +if [ "$1" -eq "0" ]; then + /bin/systemctl try-restart abrt-oops.service >/dev/null 2>&1 || : +fi +%endif %files -f %{name}.lang @@ -513,6 +556,7 @@ fi %config(noreplace) %{_sysconfdir}/%{name}/plugins/Kerneloops.conf %{_sysconfdir}/%{name}/events/report_Kerneloops.xml %config(noreplace) %{_sysconfdir}/%{name}/events.d/koops_events.conf +%{_initrddir}/abrt-oops %{_mandir}/man7/abrt-KerneloopsReporter.7.gz %{_bindir}/abrt-dump-oops %{_bindir}/abrt-action-analyze-oops diff --git a/scripts/dbg_mkrpm b/scripts/dbg_mkrpm index c3dbcf84..68ab9e2e 100755 --- a/scripts/dbg_mkrpm +++ b/scripts/dbg_mkrpm @@ -31,8 +31,7 @@ mkdir "$BUILDDIR" 2>/dev/null (tar -czf - -C "$T" "abrt-$ABRTVER") >"$BUILDDIR"/"abrt-$ABRTVER".tar.gz rm -rf "$T" cp "$SRCDIR"/abrt.spec "$BUILDDIR" -cp "$SRCDIR"/abrt.init "$BUILDDIR" -cp "$SRCDIR"/abrt-ccpp.init "$BUILDDIR" +cp "$SRCDIR"/abrt*.init "$BUILDDIR" #cp "$SRCDIR"/dbg_* "$BUILDDIR" 2>/dev/null # developers' toys { diff --git a/src/daemon/abrt.conf b/src/daemon/abrt.conf index 3611b29b..3b87b0ff 100644 --- a/src/daemon/abrt.conf +++ b/src/daemon/abrt.conf @@ -30,7 +30,7 @@ BlackListedPaths = /usr/share/doc/*,*/example* MaxCrashReportsSize = 1000 -# So far we support only one line here -# -[ LogScanners ] -abrt-dump-oops = abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages +### # So far we support only one line here +### # +### [ LogScanners ] +### abrt-dump-oops = abrt-dump-oops -d /var/spool/abrt -rwx /var/log/messages -- cgit