File: sshguard.init

package info (click to toggle)
sshguard 2.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,772 kB
  • sloc: ansic: 2,608; sh: 2,429; lex: 329; yacc: 238; makefile: 92
file content (75 lines) | stat: -rw-r--r-- 2,208 bytes parent folder | download | duplicates (3)
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
#! /bin/sh
### BEGIN INIT INFO
# Provides:          sshguard
# Required-Start:    $remote_fs $network $syslog
# Required-Stop:     $remote_fs $network $syslog
# Should-Start:      sshd
# Should-Stop:       sshd
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: SSHGuard Server
# Description:       Sshguard is a log monitor. It protects networked hosts
#                    from the today's widespread brute force attacks against services,
#                    most notably SSH. It detects such attacks and blocks
#                    the author's address with a firewall rule.
### END INIT INFO

# Author: Eugene San <eugenesan@gmail.com>
# Modify by Julián Moreno Patiño <darkjunix@gmail.com>
# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="SSHGuard Server"
NAME=sshguard
DAEMON=/usr/sbin/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
DAEMON_ARGS="-i $PIDFILE"

# Exit if the package is not installed
[ ! -x "$DAEMON" ] && log_warning_msg "No valid daemon $DAEMON for $NAME, exiting" && exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

case "$1" in
	start)
	log_daemon_msg "Starting $DESC" "$NAME"
	if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS; then
		log_end_msg 0
	else
		log_end_msg 1
	fi
	;;
	stop)
	log_daemon_msg "Stopping $DESC" "$NAME"
	if start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE; then
		ret=0
	else
		ret=1
	fi
        log_end_msg $ret
	;;
	restart|force-reload)
	log_daemon_msg "Restarting $DESC" "$NAME"
	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $PIDFILE
	if start-stop-daemon --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON --background -- $DAEMON_ARGS; then
		log_end_msg 0
	else
		log_end_msg 1
	fi
	;;
	status)
		status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
	;;

	*)
	log_action_msg "Usage: $SCRIPTNAME {start|stop|force-reload|restart|status}"
	exit 3
	;;
esac