vdagentd: unlink socket on exit rather then startup
[vd_agent/hramrach.git] / spice-vdagentd.sh
blobe1ddcc4bc008169d665bdebd1924b9d31aff301b
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: 2 3 4 5
17 # Default-Stop: 0 1 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="/sbin/spice-vdagentd"
28 prog="spice-vdagentd"
29 port="/dev/virtio-ports/com.redhat.spice.0"
31 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
33 lockfile=/var/lock/subsys/$prog
35 start() {
36 [ -x $exec ] || exit 5
37 [ -c $port ] || exit 6
38 echo -n $"Starting $prog: "
39 daemon $exec $SPICE_VDAGENTD_EXTRA_ARGS
40 retval=$?
41 echo
42 [ $retval -eq 0 ] && touch $lockfile
43 return $retval
46 stop() {
47 echo -n $"Stopping $prog: "
48 killproc $prog
49 retval=$?
50 echo
51 [ $retval -eq 0 ] && rm -f $lockfile
52 return $retval
55 restart() {
56 stop
57 start
60 reload() {
61 restart
64 force_reload() {
65 restart
68 rh_status() {
69 # run checks to determine if the service is running or use generic status
70 status $prog
73 rh_status_q() {
74 rh_status >/dev/null 2>&1
78 case "$1" in
79 start)
80 rh_status_q && exit 0
83 stop)
84 rh_status_q || exit 0
87 restart)
90 reload)
91 rh_status_q || exit 7
94 force-reload)
95 force_reload
97 status)
98 rh_status
100 condrestart|try-restart)
101 rh_status_q || exit 0
102 restart
105 echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
106 exit 2
107 esac
108 exit $?