#!/bin/sh # # Control the line-printer daemon PATH=/usr/sbin:/usr/bin:/sbin:/bin export PATH LPD_TRY='/usr/sms/share/LPRng/sbin/lpd /usr/sms/share/LPRng/bin/lpd' case "$1" in 'start') LPD= for X in $LPD_TRY; do if [ -f "$X" ]; then LPD="$X" break fi done if [ "X$LPD" = "X" ]; then echo "No lpd binary found (cannot start): no file(s)" echo " $LPD_TRY" exit 1 fi if $LPD; then echo "Printer service started: $LPD" else echo "Printer service failed: $LPD" fi ;; 'stop') found=none while :; do pattern='lpd (MAIN|START|STOP)' for X in $LPD_TRY; do pattern="$pattern|$X" done pattern=" (root|lprngd) *($pattern)" pid=`ps -A -o pid,user,command | grep -E "$pattern" | sed -e 's/^ *//' -e 's/ .*//' | head -1` if [ "X$pid" = "X" ]; then break; fi found=some echo "About to kill process $pid:" ps u --pid $pid kill $pid done while :; do pattern=" (root|lprngd) *lpd" pid=`ps -A -o pid,user,command | grep -E "$pattern" | sed -e 's/^ *//' -e 's/ .*//' | head -1` if [ "X$pid" = "X" ]; then break; fi found=some echo "... but NOT killing process $pid:" ps u --pid $pid break done if [ "$found" = 'none' ]; then echo "No lpd found" exit 1 fi ;; *) echo "usage: $0 {start|stop}" ;; esac