summaryrefslogtreecommitdiff
blob: ee416dacd899ecc2e87335c26c581e853baeabca (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
#!/sbin/openrc-run
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

depend() {
    after dbus
}

PIDFILE="/var/run/spice-vdagentd/spice-vdagentd.pid"

start() {
    PORT="${PORT:-/dev/virtio-ports/com.redhat.spice.0}"
    DEVICE="${DEVICE:-/dev/uinput}"

    ebegin "Checking for required modules and devices"

    if [ ! -d /sys/module/uinput ]; then
        modprobe -q uinput
    fi

    if [ ! -e /dev/uinput ]; then
        eerror "Module 'uinput' not loaded or not enabled in the kernel"
        eend 1
        return 1
    fi

    if [ ! -c "${PORT}" ] ; then
        eerror "Required virtio port does not exist. Make sure you"
        eerror "started the virtual machine with appropriate parameters."
        eend 1
        return 1
    fi
    eend 0

    if [ ! -c ${DEVICE} -a -c /dev/input/uinput ]; then
        DEVICE=/dev/input/uinput
    fi

    # recreate the directory since /var/run may reside on a ramdisk
    mkdir -p /var/run/spice-vdagentd

    # cleanup stalled socket
    rm -f /var/run/spice-vdagentd/spice-vdagent-sock

    ebegin "Starting spice VD agent daemon"
    start-stop-daemon \
        --start \
        --pidfile "${PIDFILE}" \
        --exec /usr/sbin/spice-vdagentd \
        -- -u "${DEVICE}" ${SPICE_VDAGENT_ARGS}
    eend $?
}

stop() {
    ebegin "Stopping spice VD agent daemon"
    start-stop-daemon \
        --stop \
        --pidfile "${PIDFILE}"
    eend $?
}