1 |
#! /bin/bash |
2 |
|
3 |
PIDFILE="/var/run/smsdaemon.pid" |
4 |
|
5 |
function start_d |
6 |
{ |
7 |
/usr/local/sbin/smsdaemon --daemon |
8 |
} |
9 |
|
10 |
function stop_d |
11 |
{ |
12 |
if [ -f $PIDFILE ] ; then |
13 |
PID=`cat $PIDFILE` |
14 |
LINES=`ps aux | grep smsdaemon | grep $PID | wc -l` |
15 |
if [ "$LINES" == "1" ] ; then |
16 |
kill $PID |
17 |
else |
18 |
echo "pidfile found -- but smsdaemon not running" |
19 |
fi |
20 |
else |
21 |
echo "PIDFILE not found !!!!!!!!" |
22 |
fi |
23 |
} |
24 |
|
25 |
function status_d |
26 |
{ |
27 |
if [ -f $PIDFILE ] ; then |
28 |
PID=`cat $PIDFILE` |
29 |
LINES=`ps aux | grep smsdaemon | grep $PID | wc -l` |
30 |
if [ "$LINES" == "1" ] ; then |
31 |
echo "smsdaemon running (pid=$PID)" |
32 |
else |
33 |
echo "pidfile found -- but smsdaemon not running" |
34 |
fi |
35 |
else |
36 |
echo "no pidfile - smsdaemon not started" |
37 |
fi |
38 |
} |
39 |
|
40 |
function reload_d |
41 |
{ |
42 |
PID=`cat $PIDFILE` |
43 |
kill -HUP $PID |
44 |
} |
45 |
|
46 |
case $1 in |
47 |
"start") |
48 |
start_d |
49 |
;; |
50 |
"stop") |
51 |
stop_d |
52 |
;; |
53 |
"status") |
54 |
status_d |
55 |
;; |
56 |
"reload") |
57 |
reload_d |
58 |
;; |
59 |
"restart") |
60 |
stop_d |
61 |
sleep 5 |
62 |
start_d |
63 |
;; |
64 |
*) |
65 |
echo "Usage $0 [start|stop|status|reload|restart]" |
66 |
;; |
67 |
esac |