.key logpassword,node1,node2
.bra {
.ket }

;;
;; Install script for LastUsers v2.5
;;
;; This script will install LastUsers for one or two nodes only.
;; Read the doc file for more information.
;; 
;; To run this script, execute it from CLI
;; This script needs OS version 3.0 or later.
;;
;; To use LastUsers on your system you must start
;; MT with the LOGPASSWORD=yourpass option.
;; Give this password as an argument to this script.
;;
;; Usage: Install.s LOGPASSWORD NODE1 NODE2

VERSION >NIL: graphics.library 39
IF NOT WARN
  VERSION >NIL: graphics.library 40
  IF WARN
    ECHO "This Script need OS 3.0 or later."
    QUIT
    ENDIF
  ENDIF

ECHO "*NThis will install *E[1mLastUsers*E[0m to your system."
ECHO "To use *E[1mLastUsers*E[0m on your system you must start"
ECHO "MT with the LOGPASSWORD=yourpass option."
ECHO "Give this password as an argument to this script."
ECHO "This script needs the XENOLINK: assign."
ECHO "This script will modify your XENOLINK:Scripts/Logout.1 script."
ECHO "*NYou might want to first run the script"
ECHO "Sample.s for sample *E[1mLastUsers*E[0m output."
ECHO "*NTo install *E[1mLastUsers*E[0m for one node run this"
ECHO "script like this: 'Install.s mypass 1' to install"
ECHO "*E[1mLastUsers*E[0m to your node number 1.*N"
ECHO "For two nodes: 'Install.s mypass 1 2' to install"
ECHO "*E[1mLastUsers*E[0m to your nodes 1 and 2.*N"
ASK "Press [Enter] to continue."

IF NOT {logpassword}
  ECHO "Usage: Install.s LOGPASSWORD NODE1 [NODE2]"
  QUIT
  ENDIF

IF NOT {node1}
  ECHO "Usage: Install.s LOGPASSWORD NODE1 [NODE2]"
  QUIT
  ENDIF

IF NOT WARN

  ECHO "*NNow select the form file to use.  Different form files"
  ECHO "produce different kinds of output."

  REQUESTFILE PATTERN=#?form#?gr1 TITLE="Select which form file to install" FILE=LastForm.gr1 DRAWER=Forms >ENV:lastu

  IF $lastu EQ ""
    SETENV lastu "LastForm.gr1"
    ENDIF

  COPY $lastu XENOLINK:LastForm.gr1

  COPY LastUsers C:

  COPY LastQuotes.txt XENOLINK:

  COPY NoLastUsers.txt XENOLINK:

  IF NOT {NODE2}
    ECHO >>XENOLINK:Scripts/Logout.1 "UnlockLogs {logpassword}"
    ECHO >>XENOLINK:Scripts/Logout.1 "LastUsers -o*"XENOLINK:Text/1/LastUsers*" -{NODE1} -aa -s"
    ECHO >>XENOLINK:Scripts/Logout.1 "LockLogs {logpassword}"
  ELSE
    ECHO >>XENOLINK:Scripts/Logout.1 "UnlockLogs {logpassword}"
    ECHO >>XENOLINK:Scripts/Logout.1 "LastUsers -o*"XENOLINK:Text/1/LastUsers*" -{NODE1} -{NODE2} -aa -s"
    ECHO >>XENOLINK:Scripts/Logout.1 "LockLogs {logpassword}"
    ECHO >>XENOLINK:Scripts/Logout.2 "UnlockLogs {logpassword}"
    ECHO >>XENOLINK:Scripts/Logout.2 "LastUsers -o*"XENOLINK:Text/1/LastUsers*" -{NODE2} -{NODE1} -aa -s"
    ECHO >>XENOLINK:Scripts/Logout.2 "LockLogs {logpassword}"
    ENDIF

  ECHO "*N*E[1mLastUsers*E[0m is now installed.*N"

  IF NOT {NODE2}
    ECHO "Every time a user logs off your node {NODE1}, two text files"
  ELSE
    ECHO "Every time a user logs off your node {NODE1} or node {NODE2}, two text files"
    ENDIF

  ECHO "XENOLINK:Text/1/LastUsers and XENOLINK:Text/0/LastUsers"
  ECHO "are created.  It is up to you to display these text files"
  ECHO "somewhere in your BBS.*N"

  ENDIF
