File: nomadjukebox

package info (click to toggle)
gnomad2 2.5.0-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,384 kB
  • ctags: 650
  • sloc: ansic: 8,784; sh: 3,240; makefile: 112
file content (35 lines) | stat: -rw-r--r-- 1,048 bytes parent folder | download
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
#!/bin/sh
# Lifts a plugged in nomad jukebox to user space and
# optionally runs a client program.
# Written by Linus Walleij 2004, based on the "usbcam"
# script by Nalin Dahyabhai.
DEVICEOWNER=CONSOLE
DEVICEPERMS=0600
PROGRAM="cd ~; gnomad2 --display=localhost:0"

if [ "${ACTION}" = "add" ] && [ -f "${DEVICE}" ]
then
    # New code, using lock files instead of copying /dev/console permissions
    # This also works with non-gdm logins (e.g. on a virtual terminal)
    # Idea and code from Nalin Dahyabhai <nalin@redhat.com>
    if [ "x$DEVICEOWNER" = "xCONSOLE" ]
    then
	if [ -f /var/run/console.lock ]
	then
	    DEVICEOWNER=`cat /var/run/console.lock`
	elif [ -f /var/lock/console.lock ]
	then
	    DEVICEOWNER=`cat /var/lock/console.lock`
	else
	    DEVICEOWNER=
	fi
    fi
    if [ -n "$DEVICEOWNER" ]
    then
        chmod 0000 "${DEVICE}"
        chown "${DEVICEOWNER}" "${DEVICE}"
        chmod "${DEVICEPERMS}" "${DEVICE}"
	# Then run an optional program - this does not work yet.
	# su "${CONSOLEOWNER}" -c "${PROGRAM}"
    fi
fi