#!/bin/sh
#
#
#      Network Queueing System (NQS)
#  This version of NQS is Copyright (C) 1992  John Roman
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 1, or (at your option)
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
#
#  PROJECT:     Network Queueing System
#  AUTHOR:      John Roman
#
#  Modification history:
#
#       Version Who     When            Description
#       -------+-------+---------------+-------------------------
#       V01.10  JRR     21-Jul-1993     Initial version.
#
#
#
# Script to install NQS on a moment's notice.
#
# This script depends on a make stage having been done previously
# to place the binaries of interest in the area $NQS_STAGE_LOC. 
# This script then checks the staging area and installs any files found
# there.  This could be run when the system boots up, before NQS
# is started.  
#

# The following 6 lines are modified by the "make stage" command
NQS_STAGE=/usr/lib/nqs/nqs-stage
NQS_USREXE=/usr/bin
NQS_LIBEXE=/usr/lib/nqs
NQS_GROUP=nqs_group
NQS_OWNER=nqs_owner
ROOT=root

QMGR_HELPFILE=$NQS_LIBEXE/qmgr.hlp


if [ -r  $NQS_STAGE/xlpserver ] 
then
    cp $NQS_STAGE/xlpserver $NQS_LIBEXE/lpserver
    chown $ROOT $NQS_LIBEXE/lpserver
    chgrp $NQS_GROUP $NQS_LIBEXE/lpserver
    chmod 555 $NQS_LIBEXE/lpserver
fi

if [ -r  $NQS_STAGE/xnetclient ] 
then
    cp $NQS_STAGE/xnetclient $NQS_LIBEXE/netclient
    chown $ROOT $NQS_LIBEXE/netclient
    chgrp $NQS_GROUP $NQS_LIBEXE/netclient
    chmod 100 $NQS_LIBEXE/netclient
fi

if [ -r  $NQS_STAGE/xpipeclient ] 
then
    cp $NQS_STAGE/xpipeclient $NQS_LIBEXE/pipeclient
    chown $ROOT $NQS_LIBEXE/pipeclient
    chgrp $NQS_GROUP $NQS_LIBEXE/pipeclient
    chmod 100 $NQS_LIBEXE/pipeclient
fi

if [ -r  $NQS_STAGE/xshlexefai ] 
then
    cp $NQS_STAGE/xshlexefai $NQS_LIBEXE/shlexefai
    chown $ROOT $NQS_LIBEXE/shlexefai
    chgrp $NQS_GROUP $NQS_LIBEXE/shlexefai
    chmod 6111 $NQS_LIBEXE/shlexefai
fi

if [ -r  $NQS_STAGE/xfinish_autoinst ] 
then
    cp $NQS_STAGE/xfinish_autoinst $NQS_LIBEXE/finish_autoinst
    chown $ROOT $NQS_LIBEXE/finish_autoinst
    chgrp $NQS_GROUP $NQS_LIBEXE/finish_autoinst
    chmod 6111 $NQS_LIBEXE/finish_autoinst
fi

if [ -r  $NQS_STAGE/xqcmplx ] 
then
    cp $NQS_STAGE/xqcmplx $NQS_USREXE/qcmplx
    chown $ROOT $NQS_USREXE/qcmplx
    chgrp $NQS_GROUP $NQS_USREXE/qcmplx
    chmod 6111 $NQS_USREXE/qcmplx
fi

if [ -r  $NQS_STAGE/xqdel ] 
then
    cp $NQS_STAGE/xqdel $NQS_USREXE/qdel
    chown $ROOT $NQS_USREXE/qdel
    chgrp $NQS_GROUP $NQS_USREXE/qdel
    chmod 6111 $NQS_USREXE/qdel
fi

if [ -r  $NQS_STAGE/xqsuspend ] 
then
    rm -f $NQS_USREXE/qresume
    cp $NQS_STAGE/xqsuspend $NQS_USREXE/qsuspend
    chown $ROOT $NQS_USREXE/qsuspend
    chgrp $NQS_GROUP $NQS_USREXE/qsuspend
    chmod 6111 $NQS_USREXE/qsuspend
    ln -s $NQS_USREXE/qsuspend $NQS_USREXE/qresume
fi

if [ -r  $NQS_STAGE/xqdev ] 
then
    cp $NQS_STAGE/xqdev $NQS_USREXE/qdev
    chown $ROOT $NQS_USREXE/qdev
    chgrp $NQS_GROUP $NQS_USREXE/qdev
    chmod 6111 $NQS_USREXE/qdev
fi

if [ -r  $NQS_STAGE/xqlimit ] 
then
    cp $NQS_STAGE/xqlimit $NQS_USREXE/qlimit
    chown $ROOT $NQS_USREXE/qlimit
    chgrp $NQS_GROUP $NQS_USREXE/qlimit
    chmod 6111 $NQS_USREXE/qlimit
fi

if [ -r  $NQS_STAGE/xqpr ] 
then
    cp $NQS_STAGE/xqpr $NQS_USREXE/qpr
    chown $ROOT $NQS_USREXE/qpr
    chgrp $NQS_GROUP $NQS_USREXE/qpr
    chmod 6111 $NQS_USREXE/qpr
fi

if [ -r  $NQS_STAGE/xqhold ] 
then
    cp $NQS_STAGE/xqhold $NQS_USREXE/qhold
    chown $ROOT $NQS_USREXE/qhold
    chgrp $NQS_GROUP $NQS_USREXE/qhold
    chmod 6111 $NQS_USREXE/qhold
fi

if [ -r  $NQS_STAGE/xqmsg ] 
then
    cp $NQS_STAGE/xqmsg $NQS_USREXE/qmsg
    chown $ROOT $NQS_USREXE/qmsg
    chgrp $NQS_GROUP $NQS_USREXE/qmsg
    chmod 6111 $NQS_USREXE/qmsg
fi

if [ -r  $NQS_STAGE/xqrls ] 
then
    cp $NQS_STAGE/xqrls $NQS_USREXE/qrls
    chown $ROOT $NQS_USREXE/qrls
    chgrp $NQS_GROUP $NQS_USREXE/qrls
    chmod 6111 $NQS_USREXE/qrls
fi

if [ -r  $NQS_STAGE/xqjob ] 
then
    cp $NQS_STAGE/xqjob $NQS_USREXE/qjob
    chown $ROOT $NQS_USREXE/qjob
    chgrp $NQS_GROUP $NQS_USREXE/qjob
    chmod 6111 $NQS_USREXE/qjob
fi

if [ -r  $NQS_STAGE/xqstatc ] 
then
    cp $NQS_STAGE/xqstatc $NQS_USREXE/qstatc
    chown $ROOT $NQS_USREXE/qstatc
    chgrp $NQS_GROUP $NQS_USREXE/qstatc
    chmod 6111 $NQS_USREXE/qstatc
fi

if [ -r  $NQS_STAGE/xqstat ] 
then
    cp $NQS_STAGE/xqstat $NQS_USREXE/qstat
    chown $ROOT $NQS_USREXE/qstat
    chgrp $NQS_GROUP $NQS_USREXE/qstat
    chmod 6111 $NQS_USREXE/qstat
fi

if [ -r  $NQS_STAGE/xqsub ] 
then
    cp $NQS_STAGE/xqsub $NQS_USREXE/qsub
    chown $ROOT $NQS_USREXE/qsub
    chgrp $NQS_GROUP $NQS_USREXE/qsub
    chmod 6111 $NQS_USREXE/qsub
fi

if [ -r  $NQS_STAGE/xnqsdaemon ] 
then
    mv -f $NQS_LIBEXE/nqsdaemon $NQS_LIBEXE/OLDnqsdaemon
    cp $NQS_STAGE/xnqsdaemon $NQS_LIBEXE/nqsdaemon
    chown $ROOT $NQS_LIBEXE/nqsdaemon
    chgrp $NQS_GROUP $NQS_LIBEXE/nqsdaemon
    chmod 2100 $NQS_LIBEXE/nqsdaemon
fi

if [ -r  $NQS_STAGE/xlogdaemon ] 
then
    mv -f $NQS_LIBEXE/logdaemon $NQS_LIBEXE/OLDlogdaemon
    cp $NQS_STAGE/xlogdaemon $NQS_LIBEXE/logdaemon
    chown $ROOT $NQS_LIBEXE/logdaemon
    chgrp $NQS_GROUP $NQS_LIBEXE/logdaemon
    chmod 100 $NQS_LIBEXE/logdaemon
fi

if [ -r  $NQS_STAGE/xloaddaemon ] 
then
    mv -f $NQS_LIBEXE/loaddaemon $NQS_LIBEXE/OLDloaddaemon
    cp $NQS_STAGE/xloaddaemon $NQS_LIBEXE/loaddaemon
    chown $ROOT $NQS_LIBEXE/loaddaemon
    chgrp $NQS_GROUP $NQS_LIBEXE/loaddaemon
    chmod 100 $NQS_LIBEXE/loaddaemon
fi

if [ -r  $NQS_STAGE/xnetdaemon ] 
then
    mv -f $NQS_LIBEXE/netdaemon $NQS_LIBEXE/OLDnetdaemon
    cp $NQS_STAGE/xnetdaemon $NQS_LIBEXE/netdaemon
    chown $ROOT $NQS_LIBEXE/netdaemon
    chgrp $NQS_GROUP $NQS_LIBEXE/netdaemon
    chmod 100 $NQS_LIBEXE/netdaemon
fi

if [ -r  $NQS_STAGE/xnetserver ] 
then
    mv -f $NQS_LIBEXE/netserver $NQS_LIBEXE/OLDnetserver
    cp $NQS_STAGE/xnetserver $NQS_LIBEXE/netserver
    chown $ROOT $NQS_LIBEXE/netserver
    chgrp $NQS_GROUP $NQS_LIBEXE/netserver
    chmod 111 $NQS_LIBEXE/netserver
fi

if [ -r  $NQS_STAGE/xqmgr ] 
then
    cp $NQS_STAGE/xqmgr $NQS_USREXE/qmgr
    chown $ROOT $NQS_USREXE/qmgr
    chgrp $NQS_GROUP $NQS_USREXE/qmgr
    chmod 6111 $NQS_USREXE/qmgr
    if [ -r $NQS_STAGE/qmgr.hlp ]
    then
        cp $NQS_STAGE/qmgr.hlp $QMGR_HELPFILE
        chown $ROOT $QMGR_HELPFILE
        chgrp $NQS_GROUP $QMGR_HELPFILE
        chmod 0444 $QMGR_HELPFILE
    fi
fi

if [ -r  $NQS_STAGE/xnmapmgr ] 
then
    cp $NQS_STAGE/xnmapmgr $NQS_USREXE/nmapmgr
    chown $ROOT $NQS_USREXE/nmapmgr
    chgrp $NQS_GROUP $NQS_USREXE/nmapmgr
    chmod 755 $NQS_USREXE/nmapmgr
fi

if [ -r  $NQS_STAGE/xqacct ] 
then
    cp $NQS_STAGE/xqacct $NQS_USREXE/qacct
    chown $ROOT $NQS_USREXE/qacct
    chgrp $NQS_GROUP $NQS_USREXE/qacct
    chmod 755 $NQS_USREXE/qacct
fi

if [ -r  $NQS_STAGE/xqcat ] 
then
    cp $NQS_STAGE/xqcat $NQS_USREXE/qcat
    chown $ROOT $NQS_USREXE/qcat
    chgrp $NQS_GROUP $NQS_USREXE/qcat
    chmod 6111 $NQS_USREXE/qcat
fi

