[Main]
Type = classic
Version = 0.1.0
Description = "spice-vdagentd daemon"
User = ( root )
Depends = ( mount-rw )
Options = ( log )

[Start]
Execute = (
	# spice-vdagentd in foreground (-x), matching debian/sv/spice-vdagentd.
	# Pause when the spice virtio port is absent (runit exits 161 / disables).
	
	envfile -I /etc/default/spice-vdagentd
	importas -sCuD "" SPICE_VDAGENTD_EXTRA_ARGS SPICE_VDAGENTD_EXTRA_ARGS
	
	ifelse { test -c /dev/virtio-ports/com.redhat.spice.0 } {
		foreground { mkdir -p /run/spice-vdagentd }
		foreground { modprobe uinput }
		foreground { rm -f /run/spice-vdagentd/spice-vdagent-sock }
		exec /usr/sbin/spice-vdagentd ${Args} ${SPICE_VDAGENTD_EXTRA_ARGS}
	}
	s6-pause
)

[Logger]
RunAs = s6log
Backup = 3
MaxSize = 2000000
Timestamp = tai
Destination = /var/log/spice-vdagentd-s6

[Environment]
Args = !-x
