1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#!/bin/sh
### BEGIN INIT INFO
# Provides: apport
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: Apport crash handling
# Description: Starts and stops apport crash handling
### END INIT INFO
# Source LSB init functions
. /lib/lsb/init-functions
DESC="apport crash handling"
# The location of the apport binary
AGENT=/usr/share/apport/apport
# The location of the core pattern file
PATFILE=/proc/sys/kernel/core_pattern
# Location to save the old core_pattern
OLDPAT=/var/tmp/core_pattern
# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
[ -x $AGENT ] || { log_failure_msg "$AGENT not installed";
if [ "$1" = "stop" ]; then exit 0;
else exit 5; fi; }
# Return success if apport is already enabled
apport_is_enabled() {
grep -q "^|.*apport" $PATFILE
}
#
# Function that starts the daemon/service
#
start_apport()
{
if ! apport_is_enabled; then
[ -e /var/crash ] || {
log_failure_msg "There is /var/crash directory missing in your system";
exit 2; }
cat $PATFILE > $OLDPAT
echo "|$AGENT %p %s %c" > /proc/sys/kernel/core_pattern
fi
}
#
# Function that stops the daemon/service
#
stop_apport()
{
if apport_is_enabled; then
cat $OLDPAT > $PATFILE
rm -f $OLDPAT
fi
}
case "$1" in
start)
start_apport
touch /var/lock/subsys/apport
log_success_msg "Starting $DESC"
;;
stop)
stop_apport
rm -f /var/lock/subsys/apport
log_success_msg "Stopping $DESC"
;;
restart|reload)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
status)
# Return value is slightly different for the status command:
# 0 - service up and running
# 1 - service dead, but /var/run/ pid file exists
# 2 - service dead, but /var/lock/ lock file exists
# 3 - service not running (unused)
# 4 - service status unknown :-(
# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
if grep -q 'apport' $PATFILE; then
echo "Apport is enabled"
exit 0
else
echo "Apport is disabled"
exit 3
fi
rc_status -v
;;
try-restart|condrestart)
if [ -f /var/lock/subsys/apport ]; then
$0 stop
$0 start
fi
;;
*)
echo "Usage: $0 {start|stop|status|restart|reload|try-restart|condrestart}"
exit 1
;;
esac
exit 0
|