blob: 2f23bffd9e0af7e24f22ef16caf35e5f5f114caa [file] [log] [blame]
Richard Marian Thomaiyar14fddef2018-07-13 23:55:56 +05301#!/bin/sh
2# chkconfig: 2345 99 10
3# description: File Integrity Checking Daemon
4#
5# processname: samhain
6# config : /etc/samhainrc
7# logfile : /var/log/samhain_log
8# database: /var/lib/samhain/samhain_file
9#
10
11NAME=samhain
12DAEMON=/usr/sbin/samhain
13RETVAL=0
14VERBOSE=yes
15PIDFILE=/var/run/samhain.pid
16
17. /etc/default/samhain-standalone
18
19if [ "x$SAMHAIN_STANDALONE_START" != "xyes" ]; then
20 echo "${0}: samhain disabled in /etc/default/samhain-standalone"
21 exit 0
22fi
23
24if [ -x $DAEMON ]; then
25 :
26else
27 echo "${0}: executable ${DAEMON} not found"
28 exit 1
29fi
30
31if [ ! -e /var/lib/samhain/samhain_file ]; then
32 echo "${0}: /var/lib/samhain/samhain_file does not exist. You must"
33 echo " run 'samhain -t init' before samhian can start."
34 exit 1
35fi
36
37samhain_done()
38{
39 if [ $RETVAL -eq 0 ]; then
40 echo "."
41 else
42 echo " failed."
43 fi
44}
45
46log_stat_msg () {
47case "$1" in
48 0)
49 echo "Service $NAME: Running";
50 ;;
51 1)
52 echo "Service $NAME: Stopped and /var/run pid file exists";
53 ;;
54 3)
55 echo "Service $NAME: Stopped";
56 ;;
57 *)
58 echo "Service $NAME: Status unknown";
59 ;;
60esac
61}
62
63case "$1" in
64 start)
65 #
66 # Remove a stale PID file, if found
67 #
68 if test -f ${PIDFILE}; then
69 /bin/rm -f ${PIDFILE}
70 fi
71
72 echo -n "Starting ${NAME}"
73 start-stop-daemon --start --quiet --exec $DAEMON
74 RETVAL=$?
75 samhain_done
76 exit $RETVAL
77 ;;
78 stop)
79 echo -n "Stopping $NAME"
80 start-stop-daemon --stop --quiet --exec $DAEMON
81 RETVAL=$?
82 samhain_done
83 #
84 # Remove a stale PID file, if found
85 #
86 if test -f ${PIDFILE}; then
87 /bin/rm -f ${PIDFILE}
88 fi
89 if test -S /var/run/${NAME}.sock; then
90 /bin/rm -f /var/run/${NAME}.sock
91 fi
92 ;;
93
94 restart)
95 $0 stop
96 sleep 3
97 $0 start
98 RETVAL=$?
99 ;;
100
101 reload|force-reload)
102 echo -n "Reloading $NAME configuration files"
103 start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
104 RETVAL=$?
105 samhain_done
106 ;;
107
108 status)
109 if pidof -o %PPID $DAEMON > /dev/null; then
110 echo "Samhain running"
111 RETVAL=0
112 else
113 echo "Samhain not running"
114 RETVAL=1
115 fi
116 ;;
117 *)
118 echo "$0 usage: {start|stop|status|restart|reload}"
119 exit 1
120 ;;
121esac
122
123exit $RETVAL