summaryrefslogtreecommitdiff
path: root/files/autossh.init.d
blob: fb3c57f7d335aac2842f0e146477799bf85252d8 (plain)
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
#! /bin/sh

### BEGIN INIT INFO
# Provides:		autossh
# Required-Start:	$remote_fs $syslog $network
# Required-Stop:	$remote_fs $syslog
# Default-Start:	2 3 4 5
# Default-Stop:		
# Short-Description:	Autossh for isuma
### END INIT INFO

set -e

umask 022

if test -f /etc/default/isuma-autossh; then
    . /etc/default/isuma-autossh
fi

. /lib/lsb/init-functions

export PATH=/sbin:/bin:/usr/sbin:/usr/bin

case "$1" in
  start)
	log_daemon_msg "Starting Autossh for isuma" "autossh"
	if start-stop-daemon --quiet --start --background --pidfile /var/run/autossh-isuma.pid --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;
  stop)
	log_daemon_msg "Stopping Autossh for isuma" "autossh"
	if start-stop-daemon --stop --quiet --pidfile /var/run/autossh-isuma.pid ; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;

  reload|force-reload)
	log_daemon_msg "Reloading Autossh for isuma's configuration" "autossh"
	if start-stop-daemon --stop --signal 1 --quiet --oknodo --pidfile /var/run/autossh-isuma.pid; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;

  restart)
	log_daemon_msg "Restarting Autossh for isuma" "autossh"
	start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile /var/run/autossh-isuma.pid
	if start-stop-daemon --start --quiet -b --make-pidfile  --pidfile /var/run/autossh-isuma.pid --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
	    log_end_msg 0
	else
	    log_end_msg 1
	fi
	;;

  try-restart)
	log_daemon_msg "Restarting Autossh for isuma" "autossh"
	set +e
	start-stop-daemon --stop --quiet --retry 30 --pidfile /var/run/autossh-isuma.pid
	RET="$?"
	set -e
	case $RET in
	    0)
		# old daemon stopped
		if start-stop-daemon --start --quiet --oknodo -b --pidfile /var/run/autossh-isuma.pid --make-pidfile --exec /usr/bin/autossh -- $AUTOSSH_ISUMA_OPTS; then
		    log_end_msg 0
		else
		    log_end_msg 1
		fi
		;;
	    1)
		# daemon not running
		log_progress_msg "(not running)"
		log_end_msg 0
		;;
	    *)
		# failed to stop
		log_progress_msg "(failed to stop)"
		log_end_msg 1
		;;
	esac
	;;

  status)
    status_of_proc -p /var/run/autossh-isuma.pid /usr/sbin/autossh autossh && exit 0 || exit $?
	;;

  *)
	log_action_msg "Usage: /etc/init.d/isuma-autossh {start|stop|reload|force-reload|restart|try-restart|status}"
	exit 1
esac

exit 0