Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # some distributions mount the root as read only until fsck has run,
- # so we cannot edit xorg and create .activdevices.
- # we need to wait until the root is writable, which happens
- # later.
- # however, udev is synchronous, so we must relaunch ourselves async and exit.
- DAEMON_FILE=/tmp/activboard/.activdevices
- if [ "$1" == "wait" ]; then
- while [ ! -w /tmp ]; do
- sleep 1
- done
- shift
- else
- if [ ! -w /tmp ]; then
- $0 wait $@ &
- exit 0
- fi
- fi
- if [ "$1" == "add" ]; then
- if [ "`id -u`" == "0" ]; then
- #make sure evdev is loaded first
- (/sbin/lsmod|grep -iq evdev) || modprobe evdev
- #add the promethean drivers if not there
- (/sbin/lsmod|grep -iq promethean) || modprobe promethean
- fi
- #reset the access rights for /dev/ACTIVBoard* (now done in udev)
- # chmod 644 /dev/ACTIVBoard*
- if [ ! -e "/etc/promethean/calibration" ]; then
- #create calibration directory with proper rights (user can write to it)
- mkdir -p /etc/promethean/calibration
- chmod -R 777 /etc/promethean/calibration
- fi
- # since HAL, udev seems to be called before ACTIVBoard<n> is available (sometimes)
- [ "`ls /dev/ACTIVBoard* -1|wc -l`" == "0" ] && logger Promethean: No devices ready yet so sleep && sleep 3
- logger ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Beeping boards $$ $2
- if [ -e "/dev/$2" ]; then
- # beep the board
- logger Beeping Board /dev/$2
- echo -e ":BP\r" > /dev/$2
- #send the calibration to the device if activmgr is not running.
- # if it is running, it will run activlc from activmgr
- ps ax|grep activmgr|grep -vq grep || (activlc --load /dev/$2 | logger)
- fi
- logger ++++++++++++++++++++++++++++++ Done beeping boards $$ $2
- if [ -f "$DAEMON_FILE" ]; then
- rm "$DAEMON_FILE"
- fi
- echo add > "$DAEMON_FILE"
- chmod 666 "$DAEMON_FILE"
- logger "Promethean: device added"
- elif [ "$1" == "remove" ]; then
- # remove but file not present, this can happen at startup if tmp was erased.
- # we need to create it first then delete so that gamin / fam picks it up.
- if [ ! -f "$DAEMON_FILE" ]; then
- echo add > "$DAEMON_FILE"
- chmod 666 "$DAEMON_FILE"
- fi
- rm "$DAEMON_FILE"
- rm /tmp/activboard*
- # if more devices, create the file again.
- # libactivboardex uses 1 of 3 mechanisms to detect changes:
- # FAM, Gamin and file polling.
- # FAM usually fails, something to do with the library.
- # Gamin checks for "$DAEMON_FILE" and is accurate
- # file polling checks for any file called /tmp/.activboard*
- for f in /dev/ACTIVBoard*
- do
- if [ -e $f ]; then
- echo add > "$DAEMON_FILE"
- chmod 666 "$DAEMON_FILE"
- break
- fi
- done
- logger "Promethean: device removed"
- else
- logger "Promethean: invalid argument in promethean.sh "$1
- fi
- # create the activboard[n] for file polling method
- for f in /dev/ACTIVBoard*
- do
- if [ -e $f ]; then
- BFILE="/tmp/`basename $f|tr [:upper:] [:lower:]`"
- echo add > $BFILE
- chmod 666 $BFILE
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment