~ubuntu-branches/ubuntu/utopic/acct/utopic

« back to all changes in this revision

Viewing changes to debian/acct.init.d

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-11-20 19:00:51 UTC
  • mfrom: (3.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091120190051-ya3i3t9ygi4jpjgg
Tags: 6.4~pre1-9ubuntu1
* Resynchronise with Debian. Remaining changes:
  - Remove stop links from rc0 and rc6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
### BEGIN INIT INFO
 
4
# Provides:          acct
 
5
# Required-Start:    $remote_fs $syslog
 
6
# Required-Stop:     $remote_fs $syslog
 
7
# Default-Start:     2 3 4 5
 
8
# Default-Stop:      1
 
9
# Short-Description: process and login accounting
 
10
# Description:       GNU Accounting Utilities is a set of utilities which
 
11
#                    reports and summarizes data about user connect times and
 
12
#                    process execution statistics.
 
13
### END INIT INFO
 
14
 
 
15
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
16
DAEMON=/usr/sbin/accton
 
17
NAME=acct
 
18
DESC="process accounting"
 
19
 
 
20
test -x $DAEMON || exit 0
 
21
 
 
22
# Include acct defaults if available
 
23
if [ -f /etc/default/acct ]
 
24
then
 
25
        . /etc/default/acct
 
26
else
 
27
        ACCT_ENABLE="1"
 
28
        ACCT_LOGGING="30"
 
29
fi
 
30
 
 
31
set -e
 
32
 
 
33
case "$1" in
 
34
        start)
 
35
                if [ "${ACCT_ENABLE}" = "1" ]
 
36
                then
 
37
 
 
38
                # Have to turn this on to be able to test the return code
 
39
                set +e
 
40
 
 
41
                echo -n "Starting $DESC: "
 
42
                /usr/sbin/accton /var/log/account/pacct 2>/dev/null
 
43
 
 
44
                rv=$?
 
45
                if [ $rv -eq 0 ]
 
46
                then
 
47
                        echo "$NAME."
 
48
                elif [ $rv -eq 38 ]
 
49
                then
 
50
                        echo "failed."
 
51
                        echo "Process accounting not available on this system."
 
52
                elif [ $rv -eq 16 ]
 
53
                then
 
54
                        echo "failed."
 
55
                        echo "Process accounting already running on this system."
 
56
                else
 
57
                        logger -p daemon.err "Unexpected error code $rv received in /etc/init.d/acct"
 
58
                fi
 
59
 
 
60
                fi
 
61
 
 
62
                set -e
 
63
                ;;
 
64
 
 
65
        stop)
 
66
                echo -n "Stopping $DESC: "
 
67
 
 
68
                # Have to turn this on to be able to test the return code
 
69
                set +e
 
70
 
 
71
                /usr/sbin/accton off 2>/dev/null
 
72
 
 
73
                if [ $? -eq 0 ]
 
74
                then
 
75
                        echo "$NAME."
 
76
                else
 
77
                        echo "failed."
 
78
                        echo "Process accounting not available on this system."
 
79
                fi
 
80
 
 
81
                set -e
 
82
                ;;
 
83
 
 
84
        restart|force-reload)
 
85
                $0 stop
 
86
                sleep 1
 
87
                $0 start
 
88
                ;;
 
89
 
 
90
        *)
 
91
                N=/etc/init.d/$NAME
 
92
                echo "Usage: $N {start|stop|restart|force-reload}" >&2
 
93
                exit 1
 
94
                ;;
 
95
esac
 
96
 
 
97
exit 0