home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1999 March B
/
SCO_CASTOR4RRT.iso
/
base
/
root.15
/
usr
/
lib
/
hpnp
/
cfg
/
option6
/
option6~
Wrap
Text File
|
1998-08-19
|
9KB
|
344 lines
#!/bin/ksh
#ident "@(#)option6 1.3"
# copyright "%c%"
#
# (c)Copyright Hewlett-Packard Company 1991. All Rights Reserved.
# (c)Copyright 1983 Regents of the University of California
# (c)Copyright 1988, 1989 by Carnegie Mellon University
#
# RESTRICTED RIGHTS LEGEND
# Use, duplication, or disclosure by the U.S. Government is subject to
# restrictions as set forth in sub-paragraph (c)(1)(ii) of the Rights in
# Technical Data and Computer Software clause in DFARS 252.227-7013.
#
# Hewlett-Packard Company
# 3000 Hanover Street
# Palo Alto, CA 94304 U.S.A.
#
# CHANGE HISTORY:
#
# 15-05-97 Paul Cunningham ul97-13201 and ul97-13202
# Changed so that if the "printer type" and "context type" questions
# are defaulted, the correct default values are used instead of
# leaving them blank.
#
INTFDIR="/usr/spool/lp/admins/lp/interfaces"
PRINTERTYPE="unknown"
CONTEXTTYPE="simple"
SPOOLNAME="$1"
PERIPHNAME="$1"
if [ ! -f "$HPNP/hpnpf" ]
then
echo "\nThe spooler software must not have been installed since"
echo "$HPNP/hpnpf does not exist. Install the NPI"
echo "spooler software before configuring the spooler."
echo "\nPress the return key to return to the main menu ... $NL"
read -r RESP
exit 1
fi
#
# Only use the first label if we have a domain name
#
SPOOLNAME=`echo $SPOOLNAME | awk -F. '{print $1}'`
getspoolname "option6hp" "$SPOOLNAME" ""
if [ $? -ne 0 ]
then
exit 1
fi
SPOOLNAME=`cat -- $TMP/SPOOLNM`
rm -- "$TMP/SPOOLNM"
#
# The peripheral name may not be the same as the name known by
# the spooler.
#
if [ -z "$PERIPHNAME" ]
then
PERIPHNAME="$SPOOLNAME"
fi
getname "option6hp" "$PERIPHNAME"
if [ $? -ne 0 ]
then
exit 1
fi
PERIPHNAME=`cat -- $TMP/NAME`
rm -f -- "$TMP/NAME"
if [ ! -d "$INTFDIR/model.orig" ]
then
echo "Creating directory $INTFDIR to hold the original model script" >> $LOG
echo "" >> $LOG
echo mkdir $INTFDIR/model.orig >> $LOG
mkdir -- "$INTFDIR/model.orig"
echo chown lp:lp $INTFDIR/model.orig >> $LOG
chown lp:lp "$INTFDIR/model.orig"
echo chmod ug=rwx,o=rx $INTFDIR/model.orig >> $LOG
chmod ug=rwx,o=rx "$INTFDIR/model.orig"
echo "" >> $LOG
fi
# Check if this peripheral is already set up in spooler. If so give message
# and exit.
if [ -f "$INTFDIR/$SPOOLNAME" -a -f "$INTFDIR/model.orig/$SPOOLNAME" ]
then
grep 'HP-UX Network Peripheral Model Script' "$INTFDIR/$SPOOLNAME" > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "\nNetwork printer $SPOOLNAME is already part of spooler system."
echo "Press the return key to continue ... $NL"
read -r RESP
exit 1
fi
fi
if [ -f "$INTFDIR/$SPOOLNAME" ]
then
grep 'HP-UX Network Peripheral Model Script' $INTFDIR/$SPOOLNAME > /dev/null 2>&1
if [ $? -ne 0 ]
then
# The peripheral is part of spooler system. The model file however is not
# the HP-UX Network Peripheral Model Script so convert it to a network
# peripheral. Move the existing model file to the model.orig subdirectory
# and add network script to interface directory.
echo "" >> $LOG
echo "Converting $SPOOLNAME from a direct connect to a network printer" >> $LOG
echo "" | tee -a -- $LOG
echo mv -f $INTFDIR/$SPOOLNAME $INTFDIR/model.orig/$SPOOLNAME | tee -a -- $LOG
mv -f -- "$INTFDIR/$SPOOLNAME" "$INTFDIR/model.orig/$SPOOLNAME"
if [ "$PERIPHNAME" != "$SPOOLNAME" ]
then
echo sed -e "s/^PERIPH=/PERIPH=$PERIPHNAME/" $HPNP/hpnp.model \> $INTFDIR/$SPOOLNAME | tee -a -- $LOG
sed -e "s/^PERIPH=/PERIPH=$PERIPHNAME/" "$HPNP/hpnp.model" > "$INTFDIR/$SPOOLNAME"
else
echo cp -fp $HPNP/hpnp.model $INTFDIR/$SPOOLNAME | tee -a -- $LOG
cp -fp -- "$HPNP/hpnp.model" "$INTFDIR/$SPOOLNAME"
fi
echo "" | tee -a -- $LOG
echo "Converted $SPOOLNAME from a direct connect to a network printer."
echo "Press the return key to continue ... $NL"
read -r RESP
exit 1
fi
fi
typeset -u UPPERCASE
while [ 0 ]
do
echo "\nEnter printer type: (default=$PRINTERTYPE) $NL"
read -r USERINPUT
UPPERCASE="$USERINPUT"
if [ -z "$UPPERCASE" ]
then
# Set default printer type
USERINPUT="$PRINTERTYPE"
break
fi
if [ "$UPPERCASE" = "Q" ]
then
exit 1
fi
if [ "$UPPERCASE" = "?" ]
then
echo "\nThis is the type name as in the terminfo database.\n"
$QUITHELP
continue
fi
# Check if in terminfo
/usr/bin/infocmp "$USERINPUT" 2>&1 1>/dev/null
if [ $? -ne 0 ]
then
echo "\nThe printer type \"$USERINPUT\" is not in the terminfo"
echo "database."
echo "Please check your spelling and try again."
echo "\nPress the return key to continue ... $NL"
read -r RESP
continue
fi
break
done
PRINTERTYPE="$USERINPUT"
while [ 0 ]
do
echo "\nEnter context-type for printer (default=$CONTEXTTYPE) $NL"
read -r USERINPUT
UPPERCASE="$USERINPUT"
if [ -z "$UPPERCASE" ]
then
# Set default context type
USERINPUT="$CONTEXTTYPE"
break
fi
if [ "$UPPERCASE" = "Q" ]
then
exit 1
fi
if [ "$UPPERCASE" = "?" ]
then
echo "\nThe context-type is the type the printer can handle"
echo "print requests for directly. That is to say, the type"
echo "that is sent to the printer after any filter has been"
echo "performed.\n"
$QUITHELP
continue
fi
if [ "$UPPERCASE" == "PCL" ]
then
USERINPUT="pcl"
break
fi
if [ "$UPPERCASE" == "PS" ]
then
USERINPUT="PS"
break
fi
if [ "$UPPERCASE" == "SIMPLE" ]
then
USERINPUT="simple"
break
fi
echo "\nContext-type must be; \"PCL\", \"PS\" or \"simple\""
done
CONTEXTTYPE="$USERINPUT"
CLASS=""
CLASSOPT=""
getspoolname "option6hp" "" "class"
RETCODE=$?
if [ $RETCODE -eq 1 ]
then
exit 1
fi
if [ $RETCODE -eq 0 ]
then
CLASS=`cat -- $TMP/SPOOLNM`
CLASSOPT="-c $CLASS"
rm -- "$TMP/SPOOLNM"
fi
while [ 0 ]
do
echo "\nWill this be the default printer? (y/n/q default=n) $NL"
read -r DEFAULT
if [ "$DEFAULT" = "n" -o -z "$DEFAULT" ]
then
break
fi
if [ "$DEFAULT" = "y" ]
then
break
fi
if [ "$DEFAULT" = "q" ]
then
exit 1
fi
if [ "$DEFAULT" = "?" ]
then
echo "\nEnter \"y\" to make the printer be the default destination."
echo "\nEnter \"n\" to add the printer as the non-default destination."
echo "\nEnter \"q\" or to return to the main menu."
fi
done
echo "\nReady to shut down the spooling system, configure the new destination,"
echo "and start the spooling system again. When the spooling system is shut"
echo "down all printing will stop. Any print requests that are currently"
echo "printing will be reprinted in their entirety when the spooling system"
echo "is restarted."
while [ 0 ]
do
echo "\nOK to continue? (y/n/q default=y) $NL"
read -r OK
if [ -z "$OK" -o "$OK" = "y" ]
then
break
fi
if [ "$OK" = "n" -o "$OK" = "q" ]
then
exit 1
fi
if [ "$OK" = "?" ]
then
echo "\nEnter \"y\" to add the spooler destination."
echo "\nEnter \"q\" or \"n\" to return to the main menu."
fi
done
echo "" | tee -a -- $LOG
echo "Adding $SPOOLNAME to spooler" >> $LOG
echo "" >> $LOG
STARTLP=0
echo /usr/sbin/lpshut | tee -a -- $LOG
/usr/sbin/lpshut
if [ $? -eq 0 ]
then
STARTLP=1
fi
echo /usr/sbin/lpadmin -p $SPOOLNAME -v /dev/null -f "allow:all" -u "allow:all" -I $CONTEXTTYPE -T $PRINTERTYPE $CLASSOPT | tee -a -- $LOG
/usr/sbin/lpadmin -p $SPOOLNAME -v /dev/null -f "allow:all" -u "allow:all" -I "$CONTEXTTYPE" -T "$PRINTERTYPE" $CLASSOPT | tee -a -- $LOG
if [ "$DEFAULT" = "y" ]
then
echo /usr/sbin/lpadmin -d $SPOOLNAME | tee -a -- $LOG
/usr/sbin/lpadmin -d $SPOOLNAME
fi
echo mv $INTFDIR/$SPOOLNAME $INTFDIR/model.orig/$SPOOLNAME | tee -a -- $LOG
mv -f -- "$INTFDIR/$SPOOLNAME" "$INTFDIR/model.orig/$SPOOLNAME"
if [ "$PERIPHNAME" != "$SPOOLNAME" ]
then
echo sed -e "s/^PERIPH=/PERIPH=$PERIPHNAME/" $HPNP/hpnp.model \> $INTFDIR/$SPOOLNAME | tee -a -- $LOG
sed -e "s/^PERIPH=/PERIPH=$PERIPHNAME/" "$HPNP/hpnp.model" > "$INTFDIR/$SPOOLNAME"
chmod u=rwx,go=rx "$INTFDIR/$SPOOLNAME"
chown lp:lp "$INTFDIR/$SPOOLNAME"
else
echo cp -p $HPNP/hpnp.model $INTFDIR/$SPOOLNAME | tee -a -- $LOG
cp -p -- "$HPNP/hpnp.model" "$INTFDIR/$SPOOLNAME"
fi
if [ $STARTLP -eq 1 ]
then
echo /usr/lib/lp/lpsched | tee -a -- $LOG
/usr/lib/lp/lpsched
else
echo scheduler was not restarted | tee -a -- $LOG
fi
echo /usr/sbin/accept $SPOOLNAME | tee -a -- $LOG
/usr/sbin/accept "$SPOOLNAME"
if [ -n "$CLASS" ]
then
echo /usr/sbin/accept $CLASS | tee -a -- $LOG
/usr/sbin/accept "$CLASS"
fi
echo /usr/bin/enable $SPOOLNAME | tee -a -- $LOG
/usr/bin/enable "$SPOOLNAME"
echo "" >> $LOG
echo "\nThe spooler destination $SPOOLNAME has been added to the spooler."
echo "Press the return key to continue ... $NL"
read -r RESP
exit 0