summaryrefslogtreecommitdiffstats
path: root/logd/logd.in
blob: 41d60c5a9d375f2c3057d9a1930f84f9098947e8 (plain)
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
#!/bin/sh
#
#
# logd     	    Start logd (non-blocking log service)
#
# Author:       Dejan Muhamedagic <dmuhamedagic@suse.de>
#               (After the heartbeat init script)
# License:      GNU General Public License (GPL)
#
#		This script works correctly under SuSE, Debian,
#		Conectiva, Red Hat and a few others.  Please let me know if it
#		doesn't work under your distribution, and we'll fix it.
#		We don't hate anyone, and like for everyone to use
#		our software, no matter what OS or distribution you're using.
#
# chkconfig: 2345 19 21
# description: Startup script logd service.
# processname: ha_logd
# pidfile: @localstatedir@/run/logd.pid
# config: @sysconfdir@/logd.cf
#
### BEGIN INIT INFO
# Description: ha_logd is a non-blocking logging daemon.
#	It can log messages either to a file or through syslog
#	daemon.
# Short-Description: ha_logd logging daemon
# Provides: ha_logd
# Required-Start: $network $syslog $remote_fs
# Required-Stop: $network $syslog $remote_fs
# X-Start-Before: heartbeat openais corosync
# Default-Start: 3 5
# Default-Stop: 0 1 6
### END INIT INFO

LOGD_CFG=@sysconfdir@/logd.cf
LOGD_OPT=""
[ -f "$LOGD_CFG" ] && LOGD_OPT="-c $LOGD_CFG"
LOGD_BIN="@libdir@/@HB_PKG@/ha_logd"

if [ ! -f $LOGD_BIN ]; then
  echo -n "ha_logd not installed."
  exit 5
fi

StartLogd() {
    echo -n "Starting ha_logd: "
    $LOGD_BIN -s >/dev/null 2>&1
    if [ $? -eq 0 ]; then
	echo "logd is already running" 
	return 0
    fi
    
    $LOGD_BIN -d $LOGD_OPT >/dev/null 2>&1
    if [ $? -ne 0 ]; then
	echo "starting logd failed"
	exit 1
    fi
    echo "ok"
    exit 0
}

StopLogd() {
    echo -n "Stopping ha_logd: "

    $LOGD_BIN -s >/dev/null 2>&1
    if [ $? -ne 0 ]; then
	   echo "logd is already stopped" 
	   return 0
    fi

    $LOGD_BIN -k >/dev/null 2>&1
    if [ $? -ne 0 ]; then
	echo "stopping logd failed"
	exit 1
    fi
    echo "stopped"
    exit 0
}

StatusLogd() {
  $LOGD_BIN -s
  exit $?
}

case "$1" in
  start) StartLogd ;;
  status) StatusLogd ;;
  stop) StopLogd ;;
  restart)
	sleeptime=1
	$0 stop && sleep $sleeptime && $0 start
	echo
	;;
  try-restart)
	$0 status && $0 restart
	;;
  *)
	echo "Usage: $0 {start|stop|status|restart}"
	exit 1
esac