Put the pid and log files into their own subdir
[vd_agent/hramrach.git] / spice-vdagentd.sh
blob1ff20159ed69912b5cf2b1d7dbdaf76b96e5fe29
1 #!/bin/sh
3 # spice-vdagentd Agent daemon for Spice guests
5 # chkconfig: 345 70 30
6 # description: Together with a per X-session agent process the spice agent \
7 # daemon enhances the spice guest user experience with client \
8 # mouse mode, guest <-> client copy and paste support and more.
10 ### BEGIN INIT INFO
11 # Provides: spice-vdagentd
12 # Required-Start: $local_fs messagebus
13 # Required-Stop: $local_fs messagebus
14 # Should-Start: $local_fs messagebus
15 # Should-Stop: $local_fs messagebus
16 # Default-Start: 5
17 # Default-Stop: 0 1 2 3 4 6
18 # Short-Description: Agent daemon for Spice guests
19 # Description: Together with a per X-session agent process the spice agent
20 # daemon enhances the spice guest user experience with client
21 # mouse mode, guest <-> client copy and paste support and more.
22 ### END INIT INFO
24 # Source function library.
25 . /etc/rc.d/init.d/functions
27 exec="/usr/sbin/spice-vdagentd"
28 prog="spice-vdagentd"
29 port="/dev/virtio-ports/com.redhat.spice.0"
30 pid="/var/run/spice-vdagentd/spice-vdagentd.pid"
32 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
34 lockfile=/var/lock/subsys/$prog
36 start() {
37 [ -x $exec ] || exit 5
38 [ -c $port ] || exit 6
39 # In case the previous running vdagentd crashed
40 rm -f /var/run/spice-vdagentd/spice-vdagent-sock
41 echo -n $"Starting $prog: "
42 daemon --pidfile $pid $exec $SPICE_VDAGENTD_EXTRA_ARGS
43 retval=$?
44 echo
45 [ $retval -eq 0 ] && touch $lockfile
46 return $retval
49 stop() {
50 echo -n $"Stopping $prog: "
51 killproc -p $pid $prog
52 retval=$?
53 echo
54 [ $retval -eq 0 ] && rm -f $lockfile
55 return $retval
58 restart() {
59 stop
60 start
63 reload() {
64 restart
67 force_reload() {
68 restart
71 rh_status() {
72 # run checks to determine if the service is running or use generic status
73 status -p $pid $prog
76 rh_status_q() {
77 rh_status >/dev/null 2>&1
81 case "$1" in
82 start)
83 rh_status_q && exit 0
86 stop)
87 rh_status_q || exit 0
90 restart)
93 reload)
94 rh_status_q || exit 7
97 force-reload)
98 force_reload
100 status)
101 rh_status
103 condrestart|try-restart)
104 rh_status_q || exit 0
105 restart
108 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
109 exit 2
110 esac
111 exit $?