123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/bin/sh
- # RC script for cwiid's wminput daemon, part of the SBo cwiid package.
- # Where's the config file for this script? This is the only variable that can't
- # be overridden in the config file.
- RC_CONF=/etc/rc.d/rc.cwiid.conf
- ####
- # Override this stuff in $RC_CONF if you see a need to:
- # Default config file for wminput instances
- WMINPUT_DEFAULT_CONF=default
- # full path to wminput binary:
- WMINPUT_BIN=/usr/bin/wminput
- # probably nobody will ever need to increase this:
- MAX_WIIMOTES=9
- ####
- start_cwiid() {
- local cwiid_conf
- local cwiid_addr
- local cmd
- local daemons
- echo "Starting cwiid wminput daemon(s)..."
- # Guarantee the uinput module gets loaded, don't complain if not
- # (it may not be modular in the running kernel)
- /sbin/modprobe uinput &>/dev/null
- # WIIMOTE is a bash array, will be populated by config file or default conf
- unset WIIMOTE
- if [ -r "$RC_CONF" ]; then
- source $RC_CONF
- else
- echo -e "$RC_CONF missing, using defaults:\\n\\tWIIMOTE[0]='auto'\\n\\tWIIMOTE_CONF[0]='$WMINPUT_DEFAULT_CONF'" 1>&2
- WIIMOTE[0]=auto
- fi
- i=0
- daemons=0
- while [ $i -le $MAX_WIIMOTES ]; do
- if [ -n "${WIIMOTE[$i]}" ]; then
- cwiid_conf="${WIIMOTE_CONF[$i]:-$WMINPUT_DEFAULT_CONF}"
- cwiid_addr=${WIIMOTE[$i]}
- if [ "$cwiid_addr" = "auto" ]; then
- cwiid_addr=""
- fi
- cmd="$WMINPUT_BIN -d -c $cwiid_conf $cwiid_addr"
- echo " Starting daemon: $cmd"
- $cmd &
- daemons=$((daemons+1))
- fi
- i=$((i+1))
- done
- echo "cwiid startup done, $daemons daemons started"
- }
- stop_cwiid() {
- echo -n "Stopping cwiid wminput daemon(s)..."
- killall wminput &>/dev/null
- sleep 2
- killall -9 wminput &>/dev/null
- echo "done"
- }
- case "$1" in
- start) start_cwiid ;;
- stop) stop_cwiid ;;
- restart)
- stop_cwiid
- sleep 1
- start_cwiid
- ;;
- *)
- echo "Usage: $0 start|stop|restart" 1>&2
- exit 1
- ;;
- esac
- exit 0
|