* app-crypt/ekeyd: Add
[portage-overlay.git] / app-crypt / ekeyd / files / ekey-ulusbd.init.2
1 #!/sbin/runscript
2 # Copyright 2009-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-x86/app-crypt/ekeyd/files/ekey-ulusbd.init.2,v 1.1 2011/10/20 11:40:27 flameeyes Exp $
5
6 INSTANCE="${SVCNAME#*.}"
7 if [ -z "${INSTANCE}" -o "${SVCNAME}" = "ekey-ulusbd" ]; then
8         INSTANCE="ekey-ulusbd"
9 fi
10
11 : ${SOCKET_PATH:=/var/run/ekey-ulusbd-${EKEY_SERIAL}}
12
13 description="EntropyKey Userland USB Daemon"
14
15 pidfile=/var/run/$SVCNAME.pid
16 command=/usr/libexec/ekey-ulusbd
17 command_args="-P ${pidfile} -p ${SOCKET_PATH}"
18
19 depend() {
20          need localmount
21 }
22
23 start() {
24         if [ -z ${USB_BUS} ]; then
25                 set -- $(lsusb -v -d 20df:0001 | \
26                         egrep '(^Bus|iSerial)' | \
27                         grep -B1 "${EKEY_SERIAL}" | \
28                         head -n 1 | \
29                         cut -c 5-7,15-18)
30                 USB_BUS=$1
31                 USB_DEV=$2
32         fi
33
34         ebegin "Starting ${description}"
35         start-stop-daemon \
36                 --start --pidfile ${pidfile} \
37                 --exec ${command} -- \
38                 ${command_args} \
39                 -b $(printf %03d ${USB_BUS}) -d $(printf %03d ${USB_DEV}) -D
40         eend $?
41 }