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 |
case $1 in |
41 |
"start") |
42 |
start_d |
43 |
;; |
44 |
"stop") |
45 |
stop_d |
46 |
;; |
47 |
"status") |
48 |
status_d |
49 |
;; |
50 |
*) |
51 |
echo "Usage $0 [start|stop|status]" |
52 |
;; |
53 |
esac |