#! /bin/sh
# Copyright (c) 1986-1993 Frame Technology Corp. All rights reserved.
#
# $Id: lwrestart,v 1.2 1992/11/06 05:39:37 adl Exp $
# 
# To "unhang" the LaserWriter, run this shell script as super-user.
# This shell script finds all processes named psif and kills them dead.

echo "lwrestart: This procedure unhangs the LaserWriter queue. This routine
can be used to restart the queue on your local machine if it is not
sending files to a remote printer (lpq will say "Sending to..."
if this is the case), or it can be used to restart the queue on the 
print server machine (the machine physically connected to the printer).

In order to work, you MUST be logged in as super-user on the machine 
with the hung queue (which is usually the print server machine). 
"

# First try to do it the clean way.  However, this almost always does
# nothing except print a bogus message that the daemon was killed.
lpc abort ps

# Do the real killing of the psif processes. A normal kill doesn't work.
kill -9 `ps ax | grep " psif " | awk '{print $1}'`

# Restart the daemon
lpc start ps

echo "
The LaserWriter should work now.  If it still isn't working right, 
cycle its power and try again.
"

