summaryrefslogtreecommitdiff
path: root/net/ntop/files/ntop.sh
blob: 920ba0eacf190a707b78d65c4df60b660c8ab650 (plain) (blame)
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
#!/bin/sh

#----------------------------------------------------------------------
# The following variables may be changed
#

# Network interface(s) to be monitored;
# may be blank, or comma-separated list
interfaces=''

# User to run ntop as; leave blank for root
userid='nobody'

# [IP:]port for serving HTTP; set to '0' to disable
http_port='3000'

# [IP:]port for serving HTTPS; set to '0' to disable
# The certificate is %%PREFIX%%/share/ntop/ntop-cert.pem
https_port='3001'

# Directory for ntop.access.log
logdir='%%LOGDIR%%'

# Specify any additional arguments here - see ntop(8)
additional_args='-E'

#
# End of user-configurable variables
#----------------------------------------------------------------------

args='-d -L'

[ ! -z $interfaces ] && args="$args -i $interfaces"
[ ! -z $http_port ] && args="$args -w $http_port"
[ ! -z $https_port ] && args="$args -W $https_port"
[ ! -z $logdir ] && args="$args -a ${logdir}/ntop.access.log"
[ ! -z $userid ] && args="$args -u $userid"
[ ! -z "$additional_args" ] && args="$args $additional_args"

case "$1" in
start)
  [ -d $logdir ] && touch ${logdir}/ntop.access.log \
    && chown $userid ${logdir}/ntop.access.log
  [ -d %%PREFIX%%/share/ntop ] && cd %%PREFIX%%/share/ntop
  [ -x %%PREFIX%%/bin/ntop ] && %%PREFIX%%/bin/ntop $args >/dev/null 2>&1 \
    && echo -n ' ntop'
  ;;
stop)
  killall ntop >/dev/null 2>&1 && echo -n ' ntop'
  ;;
*)
  echo "Usage: `basename $0` {start|stop}" >&2
  exit 64
  ;;
esac

exit 0