-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision.sh
executable file
·83 lines (68 loc) · 2.17 KB
/
provision.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
#!/bin/bash
readonly SCRIPT_DIR=/vagrant
readonly MEDIA=/vagrant
# load environment variables from .env
set -a
if [ -e "$SCRIPT_DIR"/.env ]; then
# shellcheck disable=SC1091
. "$SCRIPT_DIR"/.env
else
echo 'Environment file .env not found. Therefore, dotenv.sample will be used.'
# shellcheck disable=SC1091
. "$SCRIPT_DIR"/dotenv.sample
fi
set +a
readonly FILE="$MEDIA/V978967-01.zip"
if [[ ! -f "$FILE" ]]; then
echo "$FILE not found"
exit 1
fi
# Install Oracle Preinstallation RPM
yum -y install oracle-database-preinstall-18c
# Create directories
mkdir -p "$ORACLE_HOME"
chown -R oracle:oinstall "$ORACLE_BASE"/..
chmod -R 775 "$ORACLE_BASE"/..
# Set environment variables
cat <<EOT >>/home/oracle/.bash_profile
export ORACLE_BASE=$ORACLE_BASE
export ORACLE_HOME=$ORACLE_HOME
export ORACLE_SID=$ORACLE_SID
export PATH=\$PATH:\$ORACLE_HOME/bin:\$ORACLE_HOME/jdk/bin
EOT
# Install rlwrap and set alias
# shellcheck disable=SC1091
OS_VERSION=$(. /etc/os-release && echo "$VERSION")
readonly OS_VERSION
case ${OS_VERSION%%.*} in
7)
yum -y --enablerepo=ol7_developer_EPEL install rlwrap
cat <<EOT >>/home/oracle/.bashrc
alias sqlplus='rlwrap sqlplus'
EOT
;;
esac
# Set oracle password
echo oracle:"$ORACLE_PASSWORD" | chpasswd
TEMP_DIR=$(mktemp -d)
readonly TEMP_DIR
chmod 755 "$TEMP_DIR"
# Unzip downloaded Oracle Database software
su - oracle -c "unzip -d $ORACLE_HOME $FILE"
# Install Mo (https://github.com/tests-always-included/mo)
curl -sSL https://git.io/get-mo -o /usr/local/bin/mo
chmod +x /usr/local/bin/mo
# Install Oracle Database
/usr/local/bin/mo "$SCRIPT_DIR"/db_install.rsp.mustache >"$TEMP_DIR"/db_install.rsp
set +e +o pipefail
su - oracle -c "cd $ORACLE_HOME && ./runInstaller -silent \
-ignorePrereq -waitforcompletion -responseFile $TEMP_DIR/db_install.rsp"
set -e -o pipefail
"$ORACLE_BASE"/../oraInventory/orainstRoot.sh
"$ORACLE_HOME"/root.sh
# Create a listener using netca
su - oracle -c "netca -silent -responseFile $ORACLE_HOME/assistants/netca/netca.rsp"
# Create a database
/usr/local/bin/mo "$SCRIPT_DIR"/dbca.rsp.mustache >"$TEMP_DIR"/dbca.rsp
su - oracle -c "dbca -silent -createDatabase -responseFile $TEMP_DIR/dbca.rsp"
rm -rf "$TEMP_DIR"