File: prads.rc

package info (click to toggle)
prads 0.3.3-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 2,636 kB
  • sloc: ansic: 10,215; perl: 1,689; sql: 204; makefile: 152; sh: 144; python: 20
file content (102 lines) | stat: -rwxr-xr-x 2,311 bytes parent folder | download
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
#! /bin/sh 

### BEGIN INIT INFO
# Provides:          prads
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start PRADS sensor.
# Description:       This script provides a packet level 
#                    passive host and service detecion system
#                    in a chroot environment
### END INIT INFO
#remember, for this to work out:
# groupadd -g 5505 prads
# useradd -g 5505 -u 5505 prads -h /var/run/prads -s /bin/false
# useradd -g 5505 -u 5505 prads -d /var/run/prads -s /bin/false

# Source function library
. /lib/lsb/init-functions

NAME=prads
DESC="Passive Realtime Asset Detection System"
PATH=/sbin:/bin:/usr/sbin:/usr/bin

USER=prads
GROUP=prads
DAEMON=/usr/bin/prads
LOGFILE=/var/log/prads-asset.log
RUNDIR=/var/run/prads
PIDFILE=$RUNDIR/$NAME.pid
HOME_NETS="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,fe80::/64"
PIDNAME=$(echo $PIDFILE|sed "s@^$RUNDIR@@")

test -x $DAEMON || exit 0

mkdir -p $RUNDIR
chgrp $GROUP $RUNDIR
chmod g w $RUNDIR

# Include prads defaults if available
if [ -f /etc/default/prads ] ; then
	. /etc/default/prads
fi
DAEMON_OPTS=${DAEMON_OPTS:--D -u $(id -u $USER) -g $(id -g $GROUP) -C $RUNDIR -l $LOGFILE -a $HOME_NETS -p $PIDNAME}

if [ -n "$INTERFACE" ]
    then
    DAEMON_OPTS="$DAEMON_OPTS -i $INTERFACE"
fi


case "$1" in
	start)
		output=$(mktemp --suffix=.prads)
		log_daemon_msg "Starting $DESC" 
		log_progress_msg $NAME
		if start-stop-daemon \
			--start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- \
			${DAEMON_OPTS} > ${output} 2>&1; then
			log_end_msg 0
		else
			log_end_msg 1
			cat $output
			exit 1
		fi
		rm $output
		;;
	stop)
		log_daemon_msg "Stopping $DESC"
		log_progress_msg $NAME
		if start-stop-daemon \
		   --stop --quiet --pidfile $PIDFILE --retry 10 \
		   --exec $DAEMON; then
			log_end_msg 0
		else
			log_end_msg 1
		fi
        	;;
	reload)
		log_daemon_msg "Reloading $DESC"
		log_progress_msg $NAME
		if :; then
			log_end_msg 0
		else
			log_end_msg 1
		fi
		;;
	status)
		status_of_proc -p "${PIDFILE}" "${DAEMON}" "${NAME}"
		;;
	restart|force-reload)
		$0 stop
		$0 start
        	;;
	*)
		log_success_msg "Usage: $0 {start|stop|restart|force-reload}"
		exit 1
        ;;
esac

exit 0