init commit
[profile-appoint] / switch_backend
1 #!/bin/sh
2
3 #set -x
4 prefix=/usr/lib/switchProfByMeeting
5 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:$prefix
6 #exec_prefix=${prefix}
7 #sbindir=${exec_prefix}/sbin
8 NAME=switch_backend
9 DAEMON=${prefix}/switch_backend.py
10 USER=user
11 DESC="switch profile by meeting"
12 unset USE_UPSTART
13 #INITCTL=/sbin/initctl
14 ACTION=$1
15 test -x $DAEMON || exit 0
16
17 kill_deamon()
18 {
19 ps ax |grep $NAME |grep -v grep|grep -v init|awk '{print $1}'|while read pid 
20 do kill $pid 
21 done 
22 }
23
24 case "$ACTION" in
25   start)
26         echo "before"
27         kill_deamon
28         echo "after"
29         echo -n "Starting $DESC: "
30         start-stop-daemon --start --quiet -c $USER \
31                 --background --exec "$DAEMON"
32         if test $? == 0
33         then
34             echo "$NAME"
35         fi
36         ;;
37   stop)
38         echo -n "Stopping $DESC: "
39                 start-stop-daemon --stop --quiet --oknodo --user $USER \
40                 --exec "$DAEMON"
41         if test $? == 0
42         then
43             echo "$NAME"
44         fi
45         kill_deamon
46         ;;
47   reload|restart|force-reload)
48         #
49         #       If the "reload" option is implemented, move the "force-reload"
50         #       option to the "reload" entry above. If not, "force-reload" is
51         #       just the same as "restart".
52         #
53         "$0" stop
54         "$0" start
55         ;;
56   *)
57         N=/etc/init.d/$NAME
58         echo "Usage: $N {start|stop|restart|force-reload}" >&2
59         exit 1
60         ;;
61 esac
62
63 exit 0