#!/bin/sh

res=`find /sys$DEVPATH -name uevent -exec grep -i DRIVER=usblp {} \;`
case "$ACTION" in
  add)
  if [ -c /dev/lp0 ]; then
        if [ -n "$res" ]; then
                logger "Insert printer: chmod /dev/lp0"
                chmod 777 /dev/lp0
                killall -9 dray_lpd > /dev/null 2>&1
                /usr/sbin/dray_lpd &
        fi
  fi
  ;;
  remove)
        if [ -n "$res" ]; then
                echo "kill lpd"
                killall -9 dray_lpd
        fi
  ;;
esac
