3
# Init.d file for Samhain, based on the example init.d file written by
4
# Miquel van Smoorenburg and modified for Debian GNU/Linux by Ian Murdock
8
# Required-Start: $remote_fs $syslog
9
# Required-Stop: $remote_fs $syslog
10
# Default-Start: 2 3 4 5
16
exec_prefix="${prefix}"
18
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
19
DAEMON=${exec_prefix}/sbin/samhain
21
DESC="file integrity checker"
22
PIDFILE=/var/run/${NAME}/${NAME}.pid
24
test -x $DAEMON || exit 0
26
. /lib/lsb/init-functions
30
# Check if a daemon is running
33
# Check with pidfile first, if available
34
if [ -r "$PIDFILE" ] ; then
36
# No pid, probably no daemon present
37
if [ -n "$pid" ] ; then
38
pidofproc -p $PIDFILE $DAEMON
42
# Try to find the daemon by name
43
pidof $DAEMON >/dev/null
50
# Initialize the database only if does not exist yet, abort if
51
# it cannot be created
52
[ -f /var/state/samhain/samhain_file ] && return
53
log_progress_msg "Creating integrity database (this can take some minutes)."
54
samhain -t init >/var/log/samhain/samhain-init.log 2>&1
55
if [ ! -f /var/state/samhain/samhain_file ] ; then
56
log_failure_msg "Database could not be created. Review /var/log/samhain/samhain-init.log"
60
log_progress_msg "Database created."
67
[ ! -e /var/run/${NAME} ] && mkdir -p /var/run/${NAME}
68
log_begin_msg "Starting $DESC: $NAME"
70
start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
74
log_begin_msg "Stopping $DESC: $NAME"
75
start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME
79
log_begin_msg "Reloading $DESC configuration files: $NAME"
81
start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON
84
log_daemon_msg " ERROR: $DAEMON is not running."
90
log_begin_msg "Restarting $DESC: $NAME"
92
start-stop-daemon --stop --quiet --retry 5 --oknodo --pidfile $PIDFILE --name $NAME
94
if ! running; then break ; fi
99
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON
102
log_daemon_msg " ERROR: $DAEMON did not die in the expected time, will not restart/force-reload"
107
if [ -e $PIDFILE ] ; then
108
status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
110
status_of_proc $DAEMON $NAME && exit 0 || exit $?
114
N=/etc/init.d/${0##*/}
115
echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2