]>
Commit | Line | Data |
---|---|---|
162dab2c | 1 | #!/bin/sh |
2 | # | |
3 | # speech-dispatcher A device independent layer for speech synthesis | |
4 | # | |
5 | # chkconfig: 345 99 01 | |
6 | # | |
7 | # description: A device independent layer for speech synthesis. | |
8 | # | |
9 | # Id: template.init 9117 2007-11-28 20:28:39Z qboosh | |
10 | ||
11 | # Source function library | |
12 | . /etc/rc.d/init.d/functions | |
13 | ||
14 | # $ speech-dispatcher -h | |
15 | # Usage: speech-dispatcher [-{d|s}] [-l {1|2|3|4|5}] [-p=port] | [-v] | [-h] | |
16 | # Speech Dispatcher -- Common interface for Speech Synthesis (GNU GPL) | |
17 | # | |
18 | # -d, --run-daemon - Run as a daemon | |
19 | # -s, --run-single - Run as single application | |
20 | # -l, --log-level - Set log level (1..5) | |
21 | # -p, --port - Specify a port number | |
22 | # -P, --pid-file - Set path to pid file | |
23 | # -C, --config-dir - Set path to configuration | |
24 | # -v, --version - Report version of this program | |
25 | # -h, --help - Print this info | |
26 | ||
27 | LOGLEVEL="" | |
28 | PORT="" | |
29 | PIDFILE="" | |
30 | RUNAS="" | |
31 | ||
32 | # Get service config - may override defaults | |
33 | [ -f /etc/sysconfig/speech-dispatcher ] && . /etc/sysconfig/speech-dispatcher | |
34 | ||
35 | start() { | |
36 | # Check if the service is already running? | |
37 | if [ ! -f /var/lock/subsys/speech-dispatcher ]; then | |
38 | msg_starting speech-dispatcher | |
39 | daemon --user ${RUNAS:-speech-dispatcher} \ | |
40 | "$SERVICE_RUN_NICE_LEVEL" \ | |
41 | speech-dispatcher --pid-file ${PIDFILE:-/var/run/speech-dispatcher/speech-dispatcher.pid} \ | |
42 | ${LOGLEVEL:+--log-level $LOGLEVEL} | |
43 | RETVAL=$? | |
44 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/speech-dispatcher | |
45 | else | |
46 | msg_already_running speech-dispatcher | |
47 | fi | |
48 | } | |
49 | ||
50 | stop() { | |
51 | if [ -f /var/lock/subsys/speech-dispatcher ]; then | |
52 | # Stop daemons. | |
53 | msg_stopping speech-dispatcher | |
54 | killproc speech-dispatcher | |
55 | killproc --pidfile ${PIDFILE:-/var/run/speech-dispatcher/speech-dispatcher.pid} speech-dispatcher -TERM | |
56 | rm -f /var/lock/subsys/speech-dispatcher | |
57 | else | |
58 | msg_not_running speech-dispatcher | |
59 | fi | |
60 | } | |
61 | ||
62 | reload() { | |
63 | if [ -f /var/lock/subsys/speech-dispatcher ]; then | |
64 | msg_reloading speech-dispatcher | |
65 | killproc speech-dispatcher -HUP | |
66 | killproc --pidfile ${PIDFILE:-/var/run/speech-dispatcher/speech-dispatcher.pid} speech-dispatcher -HUP | |
67 | RETVAL=$? | |
68 | else | |
69 | msg_not_running speech-dispatcher | |
70 | RETVAL=7 | |
71 | fi | |
72 | } | |
73 | ||
74 | condrestart() { | |
75 | if [ -f /var/lock/subsys/speech-dispatcher ]; then | |
76 | stop | |
77 | start | |
78 | else | |
79 | msg_not_running speech-dispatcher | |
80 | RETVAL=$1 | |
81 | fi | |
82 | } | |
83 | ||
84 | RETVAL=0 | |
85 | # See how we were called. | |
86 | case "$1" in | |
87 | start) | |
88 | start | |
89 | ;; | |
90 | stop) | |
91 | stop | |
92 | ;; | |
93 | restart) | |
94 | stop | |
95 | start | |
96 | ;; | |
97 | try-restart) | |
98 | condrestart 0 | |
99 | ;; | |
100 | # include force-reload here if program allows reloading without restart | |
101 | # otherwise remove reload action and support force-reload as restart if running | |
102 | reload|force-reload) | |
103 | reload | |
104 | ;; | |
105 | # use this one if program doesn't support reloading without restart | |
106 | force-reload) | |
107 | condrestart 7 | |
108 | ;; | |
109 | status) | |
110 | status speech-dispatcher | |
111 | RETVAL=$? | |
112 | ;; | |
113 | *) | |
114 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" | |
115 | exit 3 | |
116 | esac | |
117 | ||
118 | exit $RETVAL |