forked from slackhq/go-audit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrh-sysv.go-audit.init
68 lines (57 loc) · 1.39 KB
/
rh-sysv.go-audit.init
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
#!/bin/sh
#
# go-audit
#
# chkconfig: - 15 85
# description: go-audit is an alternative to the auditd daemon that \
# ships with many distros.
# processname: go-audit
# config: /etc/go-audit.yaml
# pidfile: /var/run/go-audit.pid
# Source function library.
. /etc/rc.d/init.d/functions
exec="/usr/local/bin/go-audit"
prog=$(basename $exec)
pidfile=/var/run/${prog}.pid
CONFIG_FILE="/etc/go-audit.yaml"
LOG_DIRECTORY="/var/log/go-audit"
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
start() {
[ -f $pidfile ] && checkpid $(cat $pidfile) && echo "$prog already running" && return
echo -n $"Starting $prog: "
nohup $exec --config $CONFIG_FILE >>${LOG_DIRECTORY}/go-audit.out 2>>${LOG_DIRECTORY}/go-audit.err </dev/null &
pid=$!
echo $pid >$pidfile
sleep 0.1 # Sleep briefly to see if the process ends immediately
checkpid $(cat $pidfile)
status=$?
if [ $status -eq 0 ]; then success; else failure; fi
echo
return $status
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
retval=$?
echo
[ $retval -eq 0 ] && rm -f $pidfile
return $retval
}
restart() {
stop
start
}
rh_status() {
status -p $pidfile $prog
}
case "$1" in
start|stop|restart)
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac