-- NItil Installer v0.1

SET AUTOCOMMIT OFF


VARIABLE l_logfile CHAR (500);
VARIABLE l_tns     CHAR (30);
VARIABLE l_pass    CHAR (30);
VARIABLE g_tbl_spc_path CHAR(300);
VARIABLE g_web_dest CHAR(1000);

PROMPT Welcome to NItil Installer;

ACCEPT l_tns CHAR DEFAULT 'test' PROMPT "TNS Name of the target database instance:";
ACCEPT l_logfile CHAR DEFAULT 'nitil_install.log' PROMPT "Installer Log file:";
ACCEPT l_pass CHAR DEFAULT 'nitil' PROMPT "Password for NItil Administrator user:" HIDE;
ACCEPT g_tbl_spc_path CHAR DEFAULT '/var/oracle/oradata/test' PROMPT "Fully qualified OS directory of tablespace datafiles:";
ACCEPT g_web_dest CHAR PROMPT "Fully qualified path of Forms executables (.fmx, .mmx) (also can be SMB share):";
PROMPT;
PROMPT;

SPOOL &l_logfile

PROMPT Starting NItil installation...;
PROMPT Connecting to the &l_tns database as DBA...;

--  The OS path of the tablespaces is in the create_tablespace.sql script, and you can modify it there.

TIMING START
CONNECT SYS@&l_tns AS SYSDBA

@@drop_roles.sql
@@drop_synonyms.sql
@@drop_existing_nitil.sql
@create_tablespaces.sql &g_tbl_spc_path
@@create_users.sql &l_pass

DISCONNECT

CONNECT nitil/&l_pass@&l_tns

PROMPT Creating NItil Database Objects...;

CREATE SCHEMA AUTHORIZATION nitil
@@create_defs.sql
 
DISCONNECT

PROMPT Connecting to the &l_tns database as DBA...;

CONNECT SYS@&l_tns AS SYSDBA
@@create_synonyms.sql
@@create_roles.sql
GRANT NITIL_ADMIN TO nitil;

EXEC UTL_RECOMP.recomp_serial('NITIL');
/
DISCONNECT

CONNECT nitil/&l_pass@&l_tns

PROMPT Creating Starter data set...;
PROMPT NOTICE: This may take a lot of time, maybe hours. Be patient.;

@@lock_all_tables.sql

@@disable_all_fk.sql
/

@@create_metadatas.sql
/
COMMIT;

@client_install.sql &g_web_dest
/

@@lock_all_tables.sql

@@migrate_datas.sql

@@post_install.sql
/

COMMIT;

@@enable_all_fk.sql
/

PROMPT Installation is done.;

-- the end of this script
TIMING STOP

DISCONNECT
SPOOL OFF