blob: 60bbf043043eb65e0fd1faf9affa94e3bf2937e3 (
plain)
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
|
pre_install() {
# Oracle Group Names and GIDs
ORACLE_GIDS=('54321' '54322' '54323' '54324' '54325' '54326' '54330')
ORACLE_GROUP_NAMES=('oinstall' 'dba' 'oper' 'backupdba' 'dgdba' 'kmdba' 'racdba')
# Check if All the Users and Groups exist
if getent passwd oracle || getent passwd 54321;then
echo "The user oracle with uid 54321 exists!" >&2
exit 1
fi
for ((i = 0; i < ${#ORACLE_GIDS[@]}; ++i));do
if getent group ${ORACLE_GROUP_NAMES[i]} || getent group ${ORACLE_GIDS[i]};then
echo "The group ${ORACLE_GROUP_NAMES[i]} with gid ${ORACLE_GIDS[i]} exists!" >&2
exit 2
fi
done
# Create All Required Users and Groups
for ((i = 0; i < ${#ORACLE_GIDS[@]}; ++i));do
groupadd --system --gid ${ORACLE_GIDS[i]} ${ORACLE_GROUP_NAMES[i]}
done
useradd --system --uid 54321 --gid 54321 --home-dir /var/lib/oracle \
--groups $(echo ${ORACLE_GROUP_NAMES[@]:1:${#ORACLE_GROUP_NAMES[@]}} | sed 's/ /,/g') oracle
}
post_install() {
# Fix Permissions
chown -R oracle:oinstall /opt/oracle /etc/oratab /var/lib/oracle
# Create Default Database Listener
su -s /bin/bash oracle -c '/opt/oracle/product/18c/dbhomeXE/bin/netca -silent \
-orahome /opt/oracle/product/18c/dbhomeXE -instype typical -inscomp client,oraclenet,javavm,server,ano \
-responseFile /opt/oracle/product/18c/dbhomeXE/network/install/netca_typ.rsp -insprtcl tcp -cfg local \
-authadp NO_VALUE -orahnam OraHomeXE -listenerparameters DEFAULT_SERVICE=XE'
# Create Default Pluggable Database
cat <<- 'EOF'
[Info] Use the following with root command to set password and create default pluggable database:
su -s /bin/bash oracle -c '/opt/oracle/product/18c/dbhomeXE/bin/dbca -silent \
-createDatabase -gdbName XE -templateName XE_Database.dbc -characterSet AL32UTF8 \
-createAsContainerDatabase true -numberOfPDBs 1 -sid XE -pdbName XEPDB1 \
-J-Doracle.assistants.dbca.validate.ConfigurationParams=false -emConfiguration DBEXPRESS \
-emExpressPort 5500 -J-Doracle.assistants.dbca.validate.DBCredentials=false -sampleSchema true \
-customScripts /opt/oracle/product/18c/dbhomeXE/assistants/dbca/postdb_creation.sql'
EOF
}
pre_remove() {
# Terminate All Processes
PIDs=$(ps aux | grep -E '^oracle' | grep -v grep | awk '{print $2}')
if [ "$PIDs" ];then
kill -SIGKILL $PIDs
fi
}
post_remove() {
# Oracle Group Names and GIDs
ORACLE_GROUP_NAMES=('oinstall' 'dba' 'oper' 'backupdba' 'dgdba' 'kmdba' 'racdba')
# Remove Oracle Users and Groups
userdel oracle
for gp in ${ORACLE_GROUP_NAMES[@]};do
groupdel $gp
done
# Remove Database Files
rm -rf /opt/oracle /var/lib/oracle
}
|