forked from tacacsgui/tacacsgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtac_plus.sh
executable file
·120 lines (110 loc) · 2.26 KB
/
tac_plus.sh
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/sh
#
# Start-stop script for tac_plus
#
### BEGIN INIT INFO
# Provides: tac_plus
# Required-Start: $remote_fs $syslog $time
# Required-Stop: $remote_fs $syslog $time
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Starts and stops the tac_plus server process.
# Description: Starts and stops the tac_plus server process.
### END INIT INFO
# $Id: etc_init.d_tac_plus,v 1.1 2011/07/22 17:04:03 marc Exp $
# (C)2001-2010 by Marc Huber <Marc.Huber@web.de>
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
DEFAULT=/etc/default/tacplus-tac_plus
PROG=/usr/local/sbin/tac_plus
CONF=/opt/tacacsgui/tac_plus.cfg
PIDFILE=/var/run/tac_plus.pid
NAME=tac_plus
[ -f "$DEFAULT" ] && . "$DEFAULT"
for FILE in $PROG $CONF ; do
if ! [ -f "$FILE" ] ; then
echo $FILE does not exist.
DIE=1
fi
done
if [ "$DIE" != "" ] ; then
echo Exiting.
exit 1
fi
start () {
/bin/echo -n "Starting $NAME: "
if $PROG -bp $PIDFILE $CONF
then
echo "done."
else
echo "failed."
fi
}
restart () {
PID=`cat $PIDFILE 2>/dev/null`
/bin/echo -n "Restarting $NAME: "
if [ "x$PID" = "x" ]
then
echo "failed (service not running)"
else
kill -1 $PID 2>/dev/null
echo "initiated."
fi
}
stop () {
PID=`cat $PIDFILE 2>/dev/null`
/bin/echo -n "Stopping $NAME: "
if [ "x$PID" = "x" ]
then
echo "failed ($NAME is not running)"
else
kill -9 $PID 2>/dev/null
rm -f $PIDFILE
echo "done."
fi
}
case "$1" in
stop)
stop
;;
status)
PID=`cat $PIDFILE 2>/dev/null`
if [ "x$PID" = "x" ]
then
echo "$NAME is not running."
exit 1
fi
if ps -p $PID 2>/dev/null >&2
then
echo "$NAME ($PID) is running."
exit 0
fi
echo "$NAME ($PID) is not running but pid file exists."
;;
start|restart|force-reload|reload)
if $PROG -P $CONF ;then
if [ "$1" = "start" ]
then
stop 2>/dev/null >&2
start
else
restart
fi
else
cat <<EOT
********************************************************************************
* Unable to $1 $NAME ... please fix the configuration problem
* indicated above.
********************************************************************************
EOT
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|reload|status}"
exit 1
;;
esac
exit 0