summaryrefslogtreecommitdiff
path: root/system/spice-vdagent/files/rc.spice-vdagent
blob: 8f079f96532911918a6285ed72fef4ecd96e07d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
# spice-vdagentd Agent daemon for Spice guests
#
# Red Hat specific script slightly adapted for the Slackware init system
# by Matteo Bernardini <ponce@slackbuilds.org>
#
# Description: Together with a per X-session agent process the spice agent
#	daemon enhances the spice guest user experience with client
#	mouse mode, guest <-> client copy and paste support and more.

exec="/usr/sbin/spice-vdagentd"
prog="spice-vdagentd"
port="/dev/virtio-ports/com.redhat.spice.0"
pid="/var/run/spice-vdagentd/spice-vdagentd.pid"

lockfile=/var/lock/subsys/$prog

start() {
  /sbin/modprobe uinput > /dev/null 2>&1
  # In case the previous running vdagentd crashed
  /usr/bin/rm -f /var/run/spice-vdagentd/spice-vdagent-sock
  /usr/bin/mkdir -p /var/run/spice-vdagentd
  /usr/bin/echo "Starting $prog: "
  $exec -s $port
  retval=$?
  /usr/bin/echo
  [ $retval -eq 0 ] && echo "$(pidof $prog)" > $pid && /usr/bin/touch $lockfile
  return $retval
}

stop() {
  if [ "$(pidof $prog)" ]; then
    /usr/bin/echo "Stopping $prog: "
    /bin/kill $(cat $pid)
  else
    /usr/bin/echo "$prog not running"
    return 1
  fi
  retval=$?
  /usr/bin/echo
  [ $retval -eq 0 ] && rm -f $lockfile $pid
  return $retval
}

restart() {
  stop
  start
}

case "$1" in
  start)
    $1
    ;;
  stop)
    $1
    ;;
  restart)
    $1
    ;;
  *)
    /usr/bin/echo $"Usage: $0 {start|stop|restart}"
    exit 2
esac
exit $?