##
## Make sure LPHOME environment variable set
##
if [ "$LPHOME"x = x ]
then
   echo -e "The LPHOME environment variable must be set to run this"
   echo -e "script. If you have just installed LP Plus, log off and"
   echo -e "back on to set it."
   exit 1
fi

#
# Set umask off
#
umask 000


## 
## Save a copy of lp and link lp to dcclp if it's not an update
##
if [ ! -f /usr/bin/lp.lpp ]
then
   if [ -f /usr/bin/lp ]
   then
      mv /usr/bin/lp /usr/bin/lp.lpp
   fi
fi
ln -s $LPHOME/bin/dcclp /usr/bin/lp

##
## Replace lpstat with LPPlus lpstat module
##
if [ ! -f /usr/bin/lpstat.lpp ]
then
   if [ -f /usr/bin/lpstat ]
   then
      mv /usr/bin/lpstat /usr/bin/lpstat.lpp
   fi
fi
ln  -s $LPHOME/bin/lpstat /usr/bin/lpstat

##
## Replace lpadmin with LPPlus lpadmin module
##
if [ -f /usr/sbin/lpadmin ]
then
    if [ ! -f /usr/sbin/lpadmin.lpp ]
    then
       mv /usr/sbin/lpadmin /usr/sbin/lpadmin.lpp
    fi
fi
ln  -s $LPHOME/bin/lpadmin /usr/sbin/lpadmin
##
##  Replace enable with LPPlus enable script
##

if [ ! -f /usr/bin/enable.lpp ]
then
   if [ -f /usr/bin/enable ]
   then
      mv /usr/bin/enable /usr/bin/enable.lpp
   fi
fi
ln -s $LPHOME/bin/enable /usr/bin/enable

##
##  Replace disable with LPPlus disable script
##

if [ ! -f /usr/bin/disable.lpp ]
then
   if [ -f /usr/bin/disable ]
   then
      mv /usr/bin/disable /usr/bin/disable.lpp
   fi
fi
ln -s $LPHOME/bin/disable /usr/bin/disable


##
## If LPPlus to LPPlus, modify S80lp+ startup script
##
if [ ! -f /etc/rc.d/init.d/lpd.ppp ]
   then
   if [ -f /etc/rc.d/init.d/lpd ]
      then
      mv /etc/rc.d/init.d/lpd /etc/rc.d/init.d/lpd.lpp
   fi
fi
cp $LPHOME/shells/S80lp+ /etc/rc.d/init.d/lp+
cp $LPHOME/shells/K20lp+ /etc/rc.d/init.d/klp+
if [ -d /etc/rc.d/rc3.d ]
   then
   ln -s /etc/rc.d/init.d/lp+ /etc/rc.d/rc3.d/S80lp+
fi
if [ -d /etc/rc.d/rc0.d ]
   then
   ln -s /etc/rc.d/init.d/klp+ /etc/rc.d/rc0.d/K20lp+
fi
grep "#$LPHOME/bin/dccbkst" /etc/rc.d/rc3.d/S80lp+ >/tmp/LPDTMP
if [ ! -s /tmp/LPDTMP ]
   then
   sed s."#\$LPHOME/bin/dccbkst"."\$LPHOME/bin/dccbkst". \
       </etc/rc.d/rc3.d/S80lp+>/tmp/S80lp+
   cp /tmp/S80lp+ /etc/rc.d/rc3.d
   rm /tmp/S80lp+
fi
rm /tmp/LPDTMP

##
## If they want the remote print server, update rc scripts
##
if [ -d /etc/rc.d/rc3.d ]
   then
   cp $LPHOME/shells/S80lpd+ /etc/rc.d/init.d/lpd+
   ln -s /etc/rc.d/init.d/lpd+ /etc/rc.d/rc3.d/S80lpd+
fi
if [ -d /etc/rc.d/rc0.d ]
   then
   cp $LPHOME/shells/K20lpd+ /etc/rc.d/init.d/klpd+
   ln -s /etc/rc.d/init.d/klpd+ /etc/rc.d/rc0.d/K20lpd+
fi
echo -e ""
echo -e "Only one print daemon at a time may use the tcp/ip printer port."
echo -e "Therefore, if you have an existing network print daemon, you must"
echo -e "disable it. Consult your operating system documentation for this"
echo -e "procedure."
echo -e ""

exit 0 
