/*******************************************************/
/*           Secure Entry Tutorial Installation        */
/*******************************************************/

say 'IBM SecureEntry for OS/2 Version 3'
say '5793-R46 (C) Copyright IBM Corp. 1996'
say 'All Rights reserved. US Government Users Restricted Rights -'
say 'Use, duplication or disclosure restricted by GSA ADP '
say 'Schedule Contract with IBM Corp. '
say 'Licensed Materials - Property of IBM.'
say

If RxFuncQuery('SysLoadFuncs') Then
Do
  Call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  Call SysLoadFuncs
End

SGM_SHELL = value('SGM_SHELL',,'OS2ENVIRONMENT')
sefilepath=SGM_SHELL

if SGM_SHELL='' then
do
  say 'ERROR: SecureEntry not installed'
  return 1
end

/* Verify Administrator privilege */

if rxfuncquery('rxedyucm_getuser') then
do
  call rxfuncadd 'RxEdyUcmLoadFuncs', 'RXUCM','RxEdyUcmLoadFuncs'
  call RxEdyUcmLoadFuncs
end

isadmin=1
if rxfuncquery('rxedyucm_getuser')=0 then
do
   gu=rxedyucm_getuser()
   parse var gu other'ADMIN:'isadmin
end
if isadmin=0 then
do
  say 'ERROR: Administrator privilege required'
  return 1
end

address cmd '@'sefilepath'\INSTALL\unpack32 SETUTOR.PAK 'sefilepath'\TUTORIAL /P /C'
if rc=0 then
do
   address cmd '@copy 'sefilepath'\TUTORIAL\EDYOPOBJ.EXE 'sefilepath'\EXEC\EDYOPOBJ.EXE & del 'sefilepath'\TUTORIAL\EDYOPOBJ.EXE'
   if rc=0 then
   do
       address cmd '@copy 'sefilepath'\TUTORIAL\UNINSTUT.CMD 'sefilepath'\INSTALL\UNINSTUT.CMD & del 'sefilepath'\TUTORIAL\UNINSTUT.CMD'
       if rc=0 then
       do
           address cmd '@cmd /c 'sefilepath'\TUTORIAL\EDYCRTUT.CMD'
           say ''
           say 'INSTALLATION ENDED SUCCESSFULLY'
           return 0
       end
       else
         say 'Error: Installing UNINSTUT.CMD'
   end
   else
      say 'Error: Installing EDYOPOBJ.EXE'
end
else
  say 'Error: Unpacking SETUTOR.PAK'

address cmd '@'sefilepath'\INSTALL\EDYDD.EXE 'sefilepath'\TUTORIAL /N 1>nul 2>&1'
address cmd '@Del 'sefilepath'\EXEC\EDYOPOBJ.EXE 1>nul 2>&1'
address cmd '@Del 'sefilepath'\INSTALL\UNINSTUT.CMD 1>nul 2>&1'

return 1 
