Repository navigation
Expand file tree
/
Copy pathsplunk
More file actions
77 lines (69 loc) · 1.4 KB
/
Copy pathsplunk
File metadata and controls
77 lines (69 loc) · 1.4 KB
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
#!/bin/sh
#
# /etc/init.d/splunk
# init script for Splunk.
# generated by 'splunk enable boot-start'.
#
# chkconfig: 2345 90 60
# description: Splunk indexer service
#
#
RETVAL=0
. /etc/init.d/functions
test -f /etc/sysconfig/splunk && . /etc/sysconfig/splunk
CMD=${CMD-/opt/splunk/bin/splunk}
USER="${USER-root}"
CURRENT_USER=`id -nu`
run_splunk() {
if [[ $CURRENT_USER == $USER ]]; then
$CMD "$@"
else
if [[ "${CURRENT_USER}" != "root" ]]; then
echo "Script must be run from $USER or root. You are '${CURRENT_USER}'"
exit 1
fi
su ${USER} --command="$CMD $*"
fi
}
splunk_start() {
echo Starting Splunk...
run_splunk start --accept-license --no-prompt --answer-yes
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk
}
splunk_stop() {
echo Stopping Splunk...
run_splunk stop
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/splunk
}
splunk_restart() {
echo Restarting Splunk...
run_splunk restart --accept-license --no-prompt --answer-yes
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk
}
splunk_status() {
echo Splunk status:
run_splunk status
RETVAL=$?
}
case "$1" in
start)
splunk_start
;;
stop)
splunk_stop
;;
restart)
splunk_restart
;;
status)
splunk_status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL