summaryrefslogtreecommitdiff
path: root/debian/librumpdev-audio0.init.linux
blob: 832d8d666e0335c955f9e094d5bc6df635f0e5dc (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
### BEGIN INIT INFO
# Provides:          uio-audio
# Required-Start:
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: UIO access to audio devices
# Description:       See:
#		     https://github.com/rumpkernel/wiki/wiki/Howto%3A-Accessing-PCI-devices-from-userspace
### END INIT INFO

# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/bin
NAME=uio-audio
SCRIPTNAME=/etc/init.d/$NAME

# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
# and status_of_proc is working.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
	modprobe uio_pci_generic || return 2
	lspci_n=$(lspci -n)
	for busid in $(echo "${lspci_n}" | awk '{ if ($2 == "0401:" || $2 == "0403:") print $1 }') ; do
		echo "${lspci_n}" | grep "^${busid}\s" | awk '{ print $3 }' | tr ':' ' ' \
			> /sys/bus/pci/drivers/uio_pci_generic/new_id || return 2
	done
	return 0
}

#
# Function that stops the daemon/service
#
do_stop()
{
	rmmod uio_pci_generic || return 2
	return 0
}

case "$1" in
  start)
	[ "$VERBOSE" != no ] && log_daemon_msg "Enabling UIO access to audio devices" "$NAME"
	do_start
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  stop)
	[ "$VERBOSE" != no ] && log_daemon_msg "Disabling UIO access to audio devices" "$NAME"
	do_stop
	case "$?" in
		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
	esac
	;;
  status)
	;;
  restart|force-reload)
	;;
  *)
	echo "Usage: $SCRIPTNAME {start|stop}" >&2
	exit 3
	;;
esac

: