
# HPUX_ID: @(#)29.1   86/07/04
#          @(#)install	29.1      86/04/23     

# Script to install an LP spooler remote model script.

# Usage:  install printer model logfile

# Must be run as root or lp to succeed.
# Printername is relative to the local system.
# The script must already be localized to contain the proper remote system
# name and remote printer name.  It's name is relative to the pwd.
# Logfile will be created in $destdir and catch output from $script.


# Initialize, check args:

	if [ $# != 3 ]			# wrong number.
	then
	    echo "usage: $0 printername scriptname logfile"
	    exit 1
	fi

	destdir=/usr/spool/lp		# where to put $logfile.
	log="$destdir/$3"
	#srcdir=/usr/contrib/lib/remote	# where remote spooling models are.
	srcdir=.	# where remote spooling models are.
	srcmodel=$srcdir/$2
	tmpmodel=/tmp/model$$
	printer=$1

# customize the model script:
	echo "Enter the name of the system to which you are spooling? \c"
	read remsystem
	echo "Enter the printer name on the remote system (default: $printer)? \c"
	read response
	if [ "$response" = "" ]
	then
		remprinter=$printer
	else
		remprinter=$response
	fi
	echo "Customizing $srcmodel"
	sed -e "s/hpfclo/$remsystem/g" \
	    -e "s/laser/$remprinter/g" < $srcmodel > $tmpmodel

# Install the script and set up environment:

	set -x				# make visible.

	/usr/lib/lpshut			# turn off scheduler.
	touch $log		# create logfile.
	chown lp $log	# be sure it's writable.
	# install model:
	/usr/lib/lpadmin -p$printer -i$tmpmodel -v$log
	/usr/lib/accept $printer	# accept printing requests.
	/usr/bin/enable $printer	# enable printing requests.
	/usr/lib/lpsched		# turn scheduler back on.

	set +x
	rm -f $tmpmodel
	echo "\n\007Remember to configure the appropriate copy mechanism" \
		"for this model."
	echo "	(i.e. ndscopy, uucp, srm)"
	echo "If using srm, remember to add receive.srm to 'lp's crontab."
	echo "Remember to make /usr/spool/lp/receive/`hostname` on" \
		"the remote system."
