Add a moused init script

This commit is contained in:
Roy Marples 2007-11-20 14:44:43 +00:00
parent c94bfb2f9b
commit 4a99001a0f
4 changed files with 102 additions and 2 deletions

View File

@ -1,5 +1,5 @@
DIR = /etc/conf.d
CONF = localmount net.example
CONF = localmount moused net.example
TOPDIR = ..
include $(TOPDIR)/default.mk

18
conf.d.BSD/moused Normal file
View File

@ -0,0 +1,18 @@
# See the moused man page for available settings.
# Set to your mouse device psm[0-9] for PS/2 ports, ums[0-9] for USB ports
# Leave blank to try to autodetect it
MOUSED_DEVICE=""
# Any additional arguments required
MOUSED_ARGS=""
# If 0xd0-0xd3 default range is occupied in your language code table, specify
# alternative range start like MOUSECHAR_START="3", see vidcontrol(1)
MOUSECHAR_START=""
# You can also multiplex the init script for each device like so
# ln -s moused /etc/init.d/moused.ums0
# This enables you to have a config file per mouse (forces MOUSED_DEVICE
# to ums0 in this case) and control each mouse.
# devd can also start and stop these mice, which laptop users will find handy.

View File

@ -1,5 +1,5 @@
DIR = /etc/init.d
BIN = clock sysctl
BIN = clock moused sysctl
TOPDIR = ..
include $(TOPDIR)/default.mk

82
init.d.BSD/moused Normal file
View File

@ -0,0 +1,82 @@
#!/sbin/runscript
# Copyright 2007 Roy Marples
# All rights reserved
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
name=${SVCNAME##*.}
if [ -n "${name}" -a "${name}" != "moused" ] ; then
device=/dev/"${name}"
pidfile=/var/run/moused-"${name}".pid
else
name=
pidfile=/var/run/moused.pid
fi
depend() {
need localmount
after bootmisc
}
start() {
ebegin "Starting the Console Mouse Daemon" "${name}"
if [ -z "${device}" ] ; then
local dev=
for dev in /dev/psm[0-9]* /dev/ums[0-9]* ; do
[ -e "${dev}" ] || continue
[ -e /var/run/moused-$(basename "${dev}").pid ] && continue
device=${dev}
eindent
einfo "Using mouse on ${device}"
eoutdent
break
done
fi
if [ -z "${device}" ] ; then
eend 1 "No mouse device found"
return 1
fi
start-stop-daemon --start --exec /usr/sbin/moused \
--pidfile "${pidfile}" \
-- ${MOUSED_ARGS} -p "${device}" -I "${pidfile}"
local retval=$?
[ -n "${MOUSE_CHAR_START}" ] && MOUSE_CHAR_START="-M ${MOUSE_CHAR_START}"
local ttyv=
for ttyv in /dev/ttyv*; do
vidcontrol < "${ttyv}" ${MOUSE_CHAR_START} -m on
: $((${retval} += $?))
done
eend ${retval} "Failed to start moused"
}
stop() {
ebegin "Stopping the Console Mouse Daemon ${name}"
start-stop-daemon --quiet --stop --pidfile "${pidfile}"
eend $? "Failed to stop moused"
}
# vim: set ts=4 :