summaryrefslogtreecommitdiff
path: root/meta-security/recipes-security/samhain/files/samhain-server.init
blob: c456e51c9efae1cc49f30ee4df2edc46455efe8c (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# chkconfig: 2345 98 11
# description: File Integrity Checking Daemon
#
# processname: yule
# config  : /etc/yulerc
# logfile : /var/log/yule/yule_log
# database: /var/lib/yule/yule_file
#

NAME=yule
DAEMON=/usr/sbin/yule
RETVAL=0
PIDFILE=/var/run/yule.pid

. /etc/default/rcS

. /etc/default/samhain-server

if [ "x$SAMHAIN_SERVER_START" != "xyes" ]; then
	echo "${0}: server disabled in /etc/default/samhain-server"
	exit 0
fi

if [ -x $DAEMON ]; then
	:
else
	echo "${0}: executable ${DAEMON} not found"
	exit 1
fi

samhain_done()
{
	if [ $RETVAL -eq 0 ]; then
		echo "."
	else
		echo " failed."
	fi
}

log_stat_msg () {
case "$1" in
	0)
	echo "Service $NAME: Running";
	;;
	1)
	echo "Service $NAME: Stopped and /var/run pid file exists";
	;;
	3)
	echo "Service $NAME: Stopped";
	;;
	*)
	echo "Service $NAME: Status unknown";
	;;
esac
}

case "$1" in
  start)
	#
	# Remove a stale PID file, if found
	#
	if test -f ${PIDFILE}; then
	    /bin/rm -f ${PIDFILE}
	fi
	#
	echo -n "Starting ${NAME}"
	start-stop-daemon --start --quiet --exec $DAEMON
	RETVAL=$?
	samhain_done
	;;

  stop)
        echo -n "Stopping $NAME"
        start-stop-daemon --stop --quiet --exec $DAEMON
	RETVAL=$? 

	#
	# Remove a stale PID file, if found
	#
	if test -f ${PIDFILE}; then
	    /bin/rm -f ${PIDFILE}
	fi
        if test -S /var/run/${NAME}.sock; then
            /bin/rm -f /var/run/${NAME}.sock
        fi
	samhain_done
	;;

  restart)
	$0 stop
	sleep 3
	$0 start
	RETVAL=$?
	;;

  reload|force-reload)
        echo -n "Reloading $NAME configuration files"
        start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
	RETVAL=$?
	samhain_done
	;;

  status)
	$DAEMON status
	RETVAL=$?
	log_stat_msg ${RETVAL}
	;;

  *)
	echo "$0 usage: {start|stop|status|restart|reload}"
	exit 1
	;;
esac

exit $RETVAL