updated on Thu Jan 19 20:01:47 UTC 2012
[aur-mirror.git] / speech-dispatcher-git / speechd.run
blob480e6a1a34c38535d94ed1a257173afb3d7a6909
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/rc.d/functions
6 SPEECHD_CMD="/usr/bin/speech-dispatcher -d -c unix_socket -S /var/run/speech-dispatcher/speechd.sock -P /var/run/speech-dispatcher/speech-dispatcher.pid"
7 PID=$(pidof -o %PPID /usr/bin/speech-dispatcher)
9 case "$1" in
10 start)
11 stat_busy "Starting speech dispatcher Daemon"
12 # initialization
13 if [ ! $(egrep '^speechd:' /etc/group) ]; then
14 stat_busy "Adding speechd group"
15 groupadd -r speechd
16 stat_done
18 if [ ! $(egrep '^speechd:' /etc/passwd) ]; then
19 stat_busy "Creating speechd user and adding to audio group"
20 useradd -r -g speechd -G audio -d /var/run/speech-dispatcher -s /bin/false speechd
21 stat_done
23 if [ ! -d /var/log/speech-dispatcher ]; then
24 mkdir /var/log/speech-dispatcher
25 chown speechd:speechd /var/log/speech-dispatcher
27 if [ ! -d /var/run/speech-dispatcher ]; then
28 mkdir /var/run/speech-dispatcher
29 chown speechd:speechd /var/run/speech-dispatcher
32 # start the process
33 [ -z "$PID" ] && su speechd -s /bin/sh -c "$SPEECHD_CMD"
34 if [ $? -gt 0 ]; then
35 stat_fail
36 else
37 add_daemon speechd
38 chmod 755 /etc/profile.d/speechd.sh
39 stat_done
42 stop)
43 stat_busy "Stopping speech dispatcher Daemon"
44 [ ! -z "$PID" ] && kill $PID &> /dev/null
45 if [ $? -gt 0 ]; then
46 stat_fail
47 else
48 rm_daemon speechd
49 chmod 644 /etc/profile.d/speechd.sh
50 stat_done
53 restart)
54 $0 stop
55 sleep 1
56 $0 start
59 echo "usage: $0 {start|stop|restart}"
60 esac
61 exit 0