-
Notifications
You must be signed in to change notification settings - Fork 4
/
19c_apex.sh
104 lines (94 loc) · 2.95 KB
/
19c_apex.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/bash
#
# Tested CentOS 7
# Apex installation, run as root user
#
# What does this script do
#
# make pdb read-write
# make pdb state saved
# create APEX tablespace
# install APEX 19.1 - apexins.sql
# change APEX admin password
# configure embedded PL/SQL Gateway - apex_epg_config.sql
# unlock and change password of user ANONYMOUS
# unlock and change password of user APEX_PUBLIC_USER by $APEX_PASS
# create ACL to allow traffic out - DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE
# configure Oracle REST Data Services - apex_rest_config.sql
# Source env
if [ -f `dirname $0`/env ]; then
. `dirname $0`/env
else
echo "env file not found in `dirname $0`, run setup to create env file"
echo "cd `dirname $0`;bash `dirname $0`/setup env"
exit 1
fi
# Create a new tablespace to act as the default tablespace for APEX.
echo "--ALTER SYSTEM SET MEMORY_TARGET='$APEX_DB_MEMORY' SCOPE=spfile;
--STARTUP FORCE
ALTER PLUGGABLE DATABASE $PDB OPEN READ WRITE;
alter pluggable database $PDB save state;
alter session set container=$PDB;
ALTER SYSTEM SET db_create_file_dest = '$ORACLE_DB';
CREATE TABLESPACE $APEX_TABLESPACE DATAFILE SIZE 100M AUTOEXTEND ON NEXT 1M;
-- @apexins.sql tablespace_apex tablespace_files tablespace_temp images
@apexins.sql $APEX_TABLESPACE $APEX_TABLESPACE TEMP /i/
BEGIN
APEX_UTIL.set_security_group_id( 10 );
APEX_UTIL.create_user(
p_user_name => 'ADMIN',
p_email_address => '[email protected]',
p_web_password => 'changeme123',
p_developer_privs => 'ADMIN' );
APEX_UTIL.set_security_group_id( null );
COMMIT;
END;
/
@apex_epg_config.sql $APEX_HOME
conn / as sysdba
DECLARE
l_passwd VARCHAR2(40);
BEGIN
l_passwd := DBMS_RANDOM.string('a',10) || DBMS_RANDOM.string('x',10) || '1#';
-- Remove CONTAINER=ALL for non-CDB environments.
EXECUTE IMMEDIATE 'ALTER USER anonymous IDENTIFIED BY ' || l_passwd || ' ACCOUNT UNLOCK CONTAINER=ALL';
END;
/
alter session set container=$PDB;
ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;
ALTER USER APEX_PUBLIC_USER IDENTIFIED BY $APEX_PASS;
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => '*',
ace => xs\$ace_type(privilege_list => xs\$name_list('connect'),
principal_name => 'APEX_190100',
principal_type => xs_acl.ptype_db));
END;
/
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'localhost',
ace => xs\$ace_type(privilege_list => xs\$name_list('connect'),
principal_name => 'APEX_190100',
principal_type => xs_acl.ptype_db));
END;
/
exit" > ${SCRIPT_DIR}/inst_apex.sql
echo "ORAENV_ASK=NO
. oraenv
# Create directories
mkdir $APEX_HOME
# unzip Apex software
cd $APEX_HOME
unzip -oq $APEX_SW
cd apex
$ORACLE_HOME/bin/sqlplus / as sysdba @${SCRIPT_DIR}/inst_apex.sql
$ORACLE_HOME/bin/sqlplus / as sysdba<<EOF
alter session set container=$PDB;
@apex_rest_config.sql $APEX_PASS $APEX_PASS
exit;
EOF" > ${SCRIPT_DIR}/run_apex
chmod a+x ${SCRIPT_DIR}/run_apex
su - $O_USER -c ${SCRIPT_DIR}/run_apex
rm -f ${SCRIPT_DIR}/run_apex
rm -f ${SCRIPT_DIR}/inst_apex.sql