modified install path for auto start in emulator
[platform/adaptation/emulator/spice-vdagent.git] / data / spice-vdagent
1 #!/bin/sh
2 #
3 # spice-vdagentd Agent daemon for Spice guests
4 #
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.
9
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
23
24 # Source function library.
25 . /etc/rc.d/init.d/functions
26
27 exec="/usr/sbin/spice-vdagentd"
28 prog="spice-vdagentd"
29 port="/dev/virtio-ports/com.redhat.spice.0"
30 pid="/tmp/spice-vdagentd/spice-vdagentd.pid"
31
32 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
33
34 lockfile=/tmp/spice-vdagentd/lock/subsys/$prog
35
36 start() {
37     [ -x $exec ] || exit 5
38     [ -c $port ] || exit 0
39     modprobe uinput > /dev/null 2>&1
40     # In case the previous running vdagentd crashed
41     rm -f /tmp/spice-vdagentd/spice-vdagent-sock
42
43     echo -n $"Starting $prog: "
44     daemon --pidfile $pid $exec $SPICE_VDAGENTD_EXTRA_ARGS
45     retval=$?
46     echo
47     [ $retval -eq 0 ] && touch $lockfile
48     return $retval
49 }
50
51 stop() {
52     echo -n $"Stopping $prog: "
53     killproc -p $pid $prog
54     retval=$?
55     echo
56     [ $retval -eq 0 ] && rm -f $lockfile
57     return $retval
58 }
59
60 restart() {
61     stop
62     start
63 }
64
65 reload() {
66     restart
67 }
68
69 force_reload() {
70     restart
71 }
72
73 rh_status() {
74     # run checks to determine if the service is running or use generic status
75     status -p $pid $prog
76 }
77
78 rh_status_q() {
79     rh_status >/dev/null 2>&1
80 }
81
82
83 case "$1" in
84     start)
85         rh_status_q && exit 0
86         $1
87         ;;
88     stop)
89         rh_status_q || exit 0
90         $1
91         ;;
92     restart)
93         $1
94         ;;
95     reload)
96         rh_status_q || exit 7
97         $1
98         ;;
99     force-reload)
100         force_reload
101         ;;
102     status)
103         rh_status
104         ;;
105     condrestart|try-restart)
106         rh_status_q || exit 0
107         restart
108         ;;
109     *)
110         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
111         exit 2
112 esac
113 exit $?