summaryrefslogtreecommitdiffstats
path: root/abrt-ccpp.init
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2011-01-19 17:12:53 +0100
committerDenys Vlasenko <dvlasenk@redhat.com>2011-01-19 17:12:53 +0100
commite001c3c0c7d8dc9576f1630551a73cc01f19769b (patch)
tree0d8e510ff2e54ff119e4a8b282f4f080510ed7fa /abrt-ccpp.init
parentc59a0c4143cd285c7c513e124baed517002750bc (diff)
downloadabrt-e001c3c0c7d8dc9576f1630551a73cc01f19769b.tar.gz
abrt-e001c3c0c7d8dc9576f1630551a73cc01f19769b.tar.xz
abrt-e001c3c0c7d8dc9576f1630551a73cc01f19769b.zip
move (de)installation of abrt-hook-ccpp into abrt-ccpp service.
Init script is packaged and installed with abrt-addon-ccpp package. In order to not install the hook twice, "old" plugin loading in abrtd is disabled (pending deletion of entire "old" plugin machinery). Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'abrt-ccpp.init')
-rw-r--r--abrt-ccpp.init129
1 files changed, 129 insertions, 0 deletions
diff --git a/abrt-ccpp.init b/abrt-ccpp.init
new file mode 100644
index 00000000..457378a9
--- /dev/null
+++ b/abrt-ccpp.init
@@ -0,0 +1,129 @@
+#!/bin/bash
+# Install abrt coredump hook
+#
+# chkconfig: 35 82 16
+# description: Installs coredump handler which saves segfault data
+### BEGIN INIT INFO
+# Provides: abrt-ccpp
+# Required-Start: $abrtd
+# Default-Stop: 0 1 2 6
+# Default-Start: 3 5
+# Short-Description: Installs coredump handler which saves segfault data
+# Description: Installs coredump handler which saves segfault data
+### 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-ccpp"
+
+PATTERN_FILE="/proc/sys/kernel/core_pattern"
+SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern"
+HOOK_BIN="/usr/libexec/abrt-hook-ccpp"
+PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %h %e"
+
+RETVAL=0
+
+check() {
+ # Check that we're a privileged user
+ [ "`id -u`" = 0 ] || exit 4
+}
+
+start() {
+ check
+
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+
+ $verbose && printf "cur:'%s'\n" "$cur"
+ # Is it already installed?
+ if test x"$cur_first" != x"|$HOOK_BIN"; then # no
+ # It is not installed
+ printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE"
+ OLD_PATTERN=""
+ # Does old pattern start with '|'?
+ if test x"${cur#|}" = x"$cur"; then # no
+ # Encode it as hex string, NUL terminated
+ OLD_PATTERN=`printf "%s" "$cur" | od -tx1 | sed 's/000[^ ]*//' | xargs | sed 's/ //g'`
+ $verbose && printf "OLD_PATTERN:'%s'\n" "$OLD_PATTERN"
+ OLD_PATTERN=" ${OLD_PATTERN}00"
+ fi
+ # Install new handler
+ $verbose && printf "Installing to %s:'%s'\n" "$PATTERN_FILE" "${PATTERN}${OLD_PATTERN}"
+ $dry_run || echo "${PATTERN}${OLD_PATTERN}" >"$PATTERN_FILE"
+ $dry_run || touch -- "$LOCK"
+ fi
+ return $RETVAL
+}
+
+stop() {
+ check
+
+ if test -f "$SAVED_PATTERN_FILE"; then
+ $verbose && printf "Restoring to %s:'%s'\n" "$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`"
+ $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE"
+ fi
+ $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)
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+ # Is it already installed?
+ if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
+ $verbose && printf "Installed, re-installing\n"
+ restart
+ fi
+ ;;
+status)
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+ # Is it already installed?
+ if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
+ $verbose && printf "Installed\n"
+ RETVAL=0
+ else
+ $verbose && printf "Not installed\n"
+ RETVAL=3 # "stopped normally"
+ fi
+ ;;
+*)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
+ RETVAL=2
+esac
+
+exit $RETVAL