post.warn 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. trap "" 1 2
  3. cd $LPSPOOL/queue
  4. POSTIOLOG="$LPSPOOL/log/${LPDEST}.st"
  5. MAILLOG=/usr/spool/mail/mail.log
  6. export MAILLOG POSTIOLOG
  7. case "$THIS_HOST" in
  8. "$DEST_HOST")
  9. ( trap "exit 0" 15
  10. while true
  11. do
  12. error=`tail -2 $POSTIOLOG | grep PrinterError`
  13. case "$error" in
  14. "") sleep 40
  15. ;;
  16. *)
  17. set "" `cat $LPSPOOL/queue/$LPDEST/*id | sort -u`; shift
  18. while [ "$1" != "" ]
  19. do
  20. echo "delivered $2 From nopaper (vwho)" >> /n/$1/$MAILLOG
  21. shift 2
  22. done
  23. sleep 200 # give someone a chance to fix it
  24. ;;
  25. esac
  26. done ) &
  27. WARN=$!
  28. ;;
  29. esac
  30. generic 'eval /usr/bin/postscript/postio -R2 -B4096 -l$OUTDEV -b$SPEED -L$PRINTLOG $LPDEST/$FILE' 'eval echo -d"$LPDEST" -pnoproc -M"$1" -u"$2" | cat - $LPDEST/$FILE | lpsend "$DEST_HOST"' 'eval grep -l $2 $LPDEST/*id | grep -v $LPDEST/${FILE}id > /dev/null 2>&1; case $? in 0) echo "delivered $2 From applemore (vwho)" >> /n/$1/$MAILLOG;; *) echo "delivered $2 From appledone (vwho)" >> /n/$1/$MAILLOG;esac'
  31. case "$THIS_HOST" in
  32. "$DEST_HOST")
  33. kill -9 $WARN;;
  34. esac