/* ************************************************************************************************************
   *   Description:
   *   ============
   *   Script for installation of LogFileMgr in a separate schema
   *
   *   File:            install_akitools_logfilemgr.sql
   *   Modified at:     $Date: 2020-01-01 08:00:00 +0200 (Mi, 01 Jan 2020) $
   *   Checked in by:   $Author: AKielhorn $
   *   Revision:        $Revision: 100 $
   *   Author:          Andy Kielhorn
   *   Company:         AkiCom
   ************************************************************************************************************
   *   Installation :
   *   ~~~~~~~~~~~~~~
   *
   *   1. Edit file install_akitools_logfilemgr.sql
   *         Replace <Password> with a password of your choise
   *         Replace <Tablespace> with an existing tablespace in your database
   *         Save the file.
   *   2. Start sqlplus, Login as SYS
   *   3. Run script with: @install_akitools_logfilemgr.sql
   ************************************************************************************************************
 */

set serveroutput on
set verify off
set feedback off
 /* ===========================================================================================================
                                             Definition Section
    ===========================================================================================================
*/
-- global information  ******************************************************************
DEFINE VERSION             = "1.0.0.0"
DEFINE VERSION_DESCRIPTION = "Base Version"
DEFINE AKITOOLS_USER       = AKITOOLS
DEFINE AKITOOLS_PROFILE    = DEFAULT
DEFINE AKITOOLS_PASSWORD   = "<Password>"

-- TBS Definition Section ***************************************************************
DEFINE TBS_USER            = <Tablespace>           -- Tablespace for &AKITOOLS_USER.
DEFINE TBS_TEMP            = TEMP                   -- Temporary TBS for &AKITOOLS_USER.


 /* ===========================================================================================================
                                          End of Definition Section
    ===========================================================================================================
*/	


CREATE USER &AKITOOLS_USER.
  IDENTIFIED BY "&AKITOOLS_PASSWORD."
  DEFAULT TABLESPACE &TBS_USER.
  TEMPORARY TABLESPACE TEMP
  PROFILE &AKITOOLS_PROFILE.
  ACCOUNT UNLOCK;
  
WHENEVER SQLERROR CONTINUE

alter session set current_schema=&AKITOOLS_USER.;
  
ALTER USER &AKITOOLS_USER. QUOTA UNLIMITED ON &TBS_USER.;

--  Roles for &AKITOOLS_USER. 
GRANT CONNECT TO &AKITOOLS_USER.;
GRANT SELECT_CATALOG_ROLE TO &AKITOOLS_USER.;
ALTER USER &AKITOOLS_USER. DEFAULT ROLE ALL;

-- System Privileges for &AKITOOLS_USER. 
GRANT CREATE ANY DIRECTORY TO &AKITOOLS_USER.;
GRANT CREATE CLUSTER TO &AKITOOLS_USER.;
GRANT CREATE JOB TO &AKITOOLS_USER.;
GRANT CREATE MATERIALIZED VIEW TO &AKITOOLS_USER.;
GRANT CREATE PROCEDURE TO &AKITOOLS_USER.;
GRANT CREATE PUBLIC SYNONYM TO &AKITOOLS_USER.;
GRANT CREATE SEQUENCE TO &AKITOOLS_USER.;
GRANT CREATE SESSION TO &AKITOOLS_USER.;
GRANT CREATE SYNONYM TO &AKITOOLS_USER.;
GRANT CREATE TABLE TO &AKITOOLS_USER.;
GRANT CREATE TRIGGER TO &AKITOOLS_USER.;
GRANT CREATE TYPE TO &AKITOOLS_USER.;
GRANT CREATE VIEW TO &AKITOOLS_USER.;
GRANT SELECT ANY TABLE TO &AKITOOLS_USER.;

-- Object Privileges for &AKITOOLS_USER. 
GRANT SELECT ON SYS.DBA_DIRECTORIES TO &AKITOOLS_USER.;
-- GRANT SELECT ON SYS.CDB_DIRECTORIES TO &AKITOOLS_USER.;

@pkg_akitools_logfilemgr.sql

CREATE OR REPLACE PUBLIC SYNONYM logFileMgr for  &AKITOOLS_USER..logFileMgr;
GRANT  EXECUTE ON &AKITOOLS_USER..logFileMgr TO PUBLIC;

exit;
