diff options
-rw-r--r-- | .SRCINFO | 32 | ||||
-rw-r--r-- | PKGBUILD | 88 | ||||
-rw-r--r-- | oracle-xe-18c | 622 | ||||
-rw-r--r-- | oracle-xe-18c.conf | 18 | ||||
-rw-r--r-- | oracle-xe-18c.ld.so.conf | 1 | ||||
-rw-r--r-- | oracle-xe.install | 585 | ||||
-rw-r--r-- | oracle-xe.service | 20 |
7 files changed, 113 insertions, 1253 deletions
@@ -1,35 +1,27 @@ pkgbase = oracle-xe - pkgdesc = a non free DBMS - pkgver = 18.4.0_1.0 - pkgrel = 2 - url = http://www.oracle.com/ + pkgdesc = Oracle Database Express Edition + pkgver = 18.4.0.0.0 + pkgrel = 1 + url = https://www.oracle.com/database/ install = oracle-xe.install arch = x86_64 license = custom - depends = libaio>=0.3.112-2 - depends = gcc>=9.3.0-1 - depends = binutils>=2.34-2.1 - depends = make>=4.3-1 - depends = glibc>=2.31-2 - depends = bc - depends = net-tools - provides = oracle-xe - conflicts = oracle-xe + depends = bzip2 + depends = expat + depends = gcc-libs + depends = glibc + depends = libaio options = !strip source = https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm source = oracle_env.csh source = oracle_env.sh - source = oracle-xe-18c - source = oracle-xe-18c.conf - source = oracle-xe-18c.ld.so.conf + source = oracle-xe.install source = oracle-xe.service sha256sums = 4df0318d72a0b97f5468b36919a23ec07533f5897b324843108e0376566d50c8 sha256sums = 5472f8ea19a2b33780146bc95e5dc9263bb9c05b18150d24d08a85f04ed86b84 sha256sums = 9b584b6403ec0a3c8567d1720347769c92ba9f02ee460979506d641a5aa32f8b - sha256sums = 5e8296afc2c6402146cec06c3c1f73516e340f3104581c59e0f66af12f80b8e8 - sha256sums = 2d96e23869665f3648e54c85f004bf1b99f22ca227d7b148727b239135ae0e6b - sha256sums = 067e68295e4e2bcefe290ba0b8fcbe6594adc89de66875cc79c5e9f1190f8932 - sha256sums = dc59dd2abd55678abd4566af7b0cabfe7837d5c43db6612905c3f8c7b498c992 + sha256sums = bc5cb49b6e8809b5f69aaef144b23d3a00e00cd10dbadee22d6b8adffb1d4872 + sha256sums = 332a48069e5019ef5b9efb2308da2738e37d46d848b7e0f993f76a125c48c5fc pkgname = oracle-xe @@ -1,4 +1,5 @@ # Maintainer: Maxim Kurnosenko <asusx2@mail.ru> +# Co-Maintainer: William Tang <ttan0037@student.monash.edu> # Contributor: RonaldMcDaddy <wannes.demeyer@protonmail.com> # Contributor: Tinh Truong <xuantinh at gmail dot com> # Contributor: Cedric Sougne <cedric@sougne.name> @@ -8,76 +9,41 @@ # Contributor: JuliusTZM <julius dot tzm at gmail dot com> pkgname=oracle-xe -pkgver=18.4.0_1.0 -pkgrel=2 -pkgdesc="a non free DBMS" -url="http://www.oracle.com/" +pkgver=18.4.0.0.0 +pkgrel=1 +pkgdesc='Oracle Database Express Edition' +url='https://www.oracle.com/database/' license=('custom') arch=('x86_64') -conflicts=('oracle-xe') -provides=('oracle-xe') -options=('!strip') -depends=('libaio>=0.3.112-2' 'gcc>=9.3.0-1' 'binutils>=2.34-2.1' 'make>=4.3-1' 'glibc>=2.31-2' 'bc' 'net-tools') -install='oracle-xe.install' -source=( - 'https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm' - 'oracle_env.csh' - 'oracle_env.sh' - 'oracle-xe-18c' - 'oracle-xe-18c.conf' - 'oracle-xe-18c.ld.so.conf' - 'oracle-xe.service' -) +depends=('bzip2' 'expat' 'gcc-libs' 'glibc' 'libaio') +source=('https://download.oracle.com/otn-pub/otn_software/db-express/oracle-database-xe-18c-1.0-1.x86_64.rpm' + 'oracle_env.csh' + 'oracle_env.sh' + 'oracle-xe.install' + 'oracle-xe.service') sha256sums=('4df0318d72a0b97f5468b36919a23ec07533f5897b324843108e0376566d50c8' - '5472f8ea19a2b33780146bc95e5dc9263bb9c05b18150d24d08a85f04ed86b84' - '9b584b6403ec0a3c8567d1720347769c92ba9f02ee460979506d641a5aa32f8b' - '5e8296afc2c6402146cec06c3c1f73516e340f3104581c59e0f66af12f80b8e8' - '2d96e23869665f3648e54c85f004bf1b99f22ca227d7b148727b239135ae0e6b' - '067e68295e4e2bcefe290ba0b8fcbe6594adc89de66875cc79c5e9f1190f8932' - 'dc59dd2abd55678abd4566af7b0cabfe7837d5c43db6612905c3f8c7b498c992') + '5472f8ea19a2b33780146bc95e5dc9263bb9c05b18150d24d08a85f04ed86b84' + '9b584b6403ec0a3c8567d1720347769c92ba9f02ee460979506d641a5aa32f8b' + 'bc5cb49b6e8809b5f69aaef144b23d3a00e00cd10dbadee22d6b8adffb1d4872' + '332a48069e5019ef5b9efb2308da2738e37d46d848b7e0f993f76a125c48c5fc') -build() { - cd $srcdir -# bsdtar -xf oracle-xe-18.4.0-1.0.x86_64.rpm -} +options=('!strip') +install='oracle-xe.install' package() { - cd $srcdir - - mkdir -p $pkgdir/etc/rc.d - cp $srcdir/oracle-xe-18c $pkgdir/etc/rc.d/ - chmod +x $pkgdir/etc/rc.d/oracle-xe-18c - - #Fix for ***[FATAL] [DBT-50000] Unable to check for available memory.**** - corr1="s_-sampleSchema_-J-Doracle.assistants.dbca.validate.ConfigurationParams=false -sampleSchema_g" - sed -i "${corr1}" $pkgdir/etc/rc.d/oracle-xe-18c - - mkdir -p $pkgdir/etc/sysconfig - cp $srcdir/oracle-xe-18c.conf $pkgdir/etc/sysconfig - - mkdir -p $pkgdir/opt - mv $srcdir/opt/oracle $pkgdir/opt - - find $pkgdir -exec chmod 755 {} \; - - # Export environment variables - mkdir -p $pkgdir/etc/profile.d - cp $srcdir/oracle_env.* $pkgdir/etc/profile.d/ - chmod +x $pkgdir/etc/profile.d/oracle_env.* + mv opt usr $pkgdir/ - # Desktop files - cp -a $srcdir/usr $pkgdir + # Install Environment Files + install -D -m 744 oracle_env.csh $pkgdir/etc/profile.d/oracle_env.csh + install -D -m 744 oracle_env.sh $pkgdir/etc/profile.d/oracle_env.sh - # LD_LIBRARY_PATH - mkdir -p $pkgdir/etc/ld.so.conf.d/ - cp $srcdir/oracle-xe-18c.ld.so.conf $pkgdir/etc/ld.so.conf.d/oracle-xe-18c.conf + # Install Systemd Service File + install -D -m 644 oracle-xe.service $pkgdir/usr/lib/systemd/system/oracle-xe.service - # License - mkdir -p $pkgdir/usr/share/licenses/custom/$pkgname - cp $srcdir/usr/share/doc/oracle-xe-18c/LICENSE $pkgdir/usr/share/licenses/custom/$pkgname + # Create oratab File + touch $pkgdir/etc/oratab - # For systemd - mkdir -p $pkgdir/etc/systemd/system - cp $srcdir/oracle-xe.service $pkgdir/etc/systemd/system + # Create oracle Home Directory + mkdir -p $pkgdir/var/lib/oracle } diff --git a/oracle-xe-18c b/oracle-xe-18c deleted file mode 100644 index cb8f60ab924d..000000000000 --- a/oracle-xe-18c +++ /dev/null @@ -1,622 +0,0 @@ -#!/bin/bash -# -# chkconfig: 2345 80 05 -# description: This script is responsible for taking care of configuring the RPM Oracle XE Database and its associated services. -# -# processname: oracle-xe-18c -# Red Hat or SuSE config: /etc/sysconfig/oracle-xe-18c -# -# change log: -# ivalopez 12/13/17 - Creation -# mstalin 04/30/18 - DB configuration changes -# rfgonzal 05/14/28 - Enh 27965960 & 27965939 - Enable service and clean env vars when launching dbca -# rfgonzal 05/14/18 - Enh 27965960 & 27965939 - Enable service and clean env vars when launching dbca -# mstalin 05/20/18 - 21261445 RTI, disable the checks -# mstalin 05/29/18 - 28121518 password handling and connection string handling -# mstalin 06/07/18 - Add memory distribution logic -# rfgonzal 07/09/18 - Bug 28243127 - Cannot start/stop DB after fresh installation -# mstalin 07/18/18 - 28243186 Print EM configuration URL -# mstalin 07/06/18 - Add sample schema to XE -# mstalin 08/02/18 - 28353388 Add delete option to the usage text -# mstalin 08/02/18 - 28242894 Reduce verbose of the script -# mstalin 10/06/18 - 28735641 Fix duplicate success messages and product name -# - - -# Set path if path not set -case $PATH in - "") PATH=/bin:/usr/bin:/sbin:/etc - export PATH ;; -esac - -# Check if the root user is running this script -if [ $(id -u) != "0" ] -then - echo "You must be root user to run the configure script. Login as root user and then run the configure script." - exit 1 -fi - -# DB defaults -export ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE -export ORACLE_SID=XE -export TEMPLATE_NAME=XE_Database.dbc -export PDB_NAME=XEPDB1 -export LISTENER_NAME=LISTENER -export NUMBER_OF_PDBS=1 -export CREATE_AS_CDB=true - -# General exports and vars -export PATH=$ORACLE_HOME/bin:$PATH -LSNR=$ORACLE_HOME/bin/lsnrctl -SQLPLUS=$ORACLE_HOME/bin/sqlplus -NETCA=$ORACLE_HOME/bin/netca -DBCA=$ORACLE_HOME/bin/dbca -ORACLE_OWNER=oracle -RETVAL=0 -CONFIG_NAME="oracle-xe-18c.conf" -CONFIGURATION="/etc/sysconfig/$CONFIG_NAME" -ORACLE_HOME_NAME="OraHomeXE" -MINIMUM_MEMORY=1048576 -MAXIMUM_MEMORY=2097152 -MINIMUM_MEMORY_STR="1GB" - -MINIMUM_SPACE=4718592 -MINIMUM_SPACE_STR="4.5GB" - -# Commands -if [ -z "$SU" ];then SU=/bin/su; fi -if [ -z "$AWK" ];then AWK=/bin/awk; fi -if [ -z "$DF" ];then DF=/bin/df; fi -if [ -z "$GREP" ]; then GREP=/usr/bin/grep; fi -if [ ! -f "$GREP" ]; then GREP=/bin/grep; fi -if [ -z "$TAIL" ]; then TAIL=/usr/bin/tail; fi -if [ ! -f "$TAIL" ]; then TAIL=/bin/tail; fi -HOSTNAME_CMD="/bin/hostname" -MKDIR_CMD="/bin/mkdir" - -# To start the DB -start() -{ - check_for_configuration - RETVAL=$? - if [ $RETVAL -eq 1 ] - then - echo "The Oracle Database is not configured. You must run '/etc/init.d/oracle-xe-18c configure' as the root user to configure the database." - exit - fi - # Check if the DB is already started - pmon=`ps -ef | egrep pmon_$ORACLE_SID'\>' | $GREP -v grep` - if [ "$pmon" = "" ]; - then - # Unset the proxy env vars before calling sqlplus - unset_proxy_vars - echo "Starting Oracle Net Listener." - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR start $LISTENER_NAME" > /dev/null 2>&1 - RETVAL=$? - if [ $RETVAL -eq 0 ] - then - echo "Oracle Net Listener started." - fi - - echo "Starting Oracle Database instance $ORACLE_SID." - $SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog << EOF - connect / as sysdba - startup - alter pluggable database all open - exit; - EOF" > /dev/null 2>&1 - RETVAL1=$? - if [ $RETVAL1 -eq 0 ] - then - echo "Oracle Database instance $ORACLE_SID started." - fi - else - echo "The Oracle Database instance $ORACLE_SID is already started." - exit 0 - fi - - echo - if [ $RETVAL -eq 0 ] && [ $RETVAL1 -eq 0 ] - then - return 0 - else - echo "Failed to start Oracle Net Listener using $ORACLE_HOME/bin/tnslsnr and Oracle Database using $ORACLE_HOME/bin/sqlplus." - exit 1 - fi -} - -# To stop the DB -stop() -{ - check_for_configuration - RETVAL=$? - if [ $RETVAL -eq 1 ] - then - echo "The Oracle Database is not configured. You must run '/etc/init.d/oracle-xe-18c configure' as the root user to configure the database." - exit 1 - fi - # Check if the DB is already stopped - pmon=`ps -ef | egrep pmon_$ORACLE_SID'\>' | $GREP -v grep` - if [ "$pmon" = "" ] - then - echo "Oracle Database instance $ORACLE_SID is already stopped." - exit 1 - else - # Unset the proxy env vars before calling sqlplus - unset_proxy_vars - echo "Shutting down Oracle Database instance $ORACLE_SID." - $SU -s /bin/bash $ORACLE_OWNER -c "$SQLPLUS -s /nolog << EOF - connect / as sysdba - shutdown immediate - exit; - EOF" > /dev/null 2>&1 - RETVAL=$? - if [ $RETVAL -eq 0 ] - then - echo "Oracle Database instance $ORACLE_SID shut down." - fi - - echo "Stopping Oracle Net Listener." - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR stop $LISTENER_NAME" > /dev/null 2>&1 - RETVAL1=$? - if [ $RETVAL1 -eq 0 ] - then - echo "Oracle Net Listener stopped." - fi - fi - - echo - if [ $RETVAL -eq 0 ] && [ $RETVAL1 -eq 0 ] - then - return 0 - else - echo "Failed to stop Oracle Net Listener using $ORACLE_HOME/bin/tnslsnr and Oracle Database using $ORACLE_HOME/bin/sqlplus." - exit 1 - fi -} - -configure_delete() -{ - # Unset the proxy env vars before deleting the db - unset_proxy_vars - ORABASE=`$ORACLE_HOME/bin/orabase` - NETCA_LOG_DIR="$ORABASE/cfgtoollogs/netca" - if [ ! -d "$NETCA_LOG_DIR" ] - then - $SU -s /bin/bash $ORACLE_OWNER -c "$MKDIR_CMD -p $NETCA_LOG_DIR" - fi - NETCA_LOG="$NETCA_LOG_DIR/netca_deinst_out.log" - - echo "Deleting Oracle Listener." - - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR stop $LISTENER_NAME" > /dev/null 2>&1 - - $SU -s /bin/bash $ORACLE_OWNER -c "$NETCA /deinst >>$NETCA_LOG" - - echo "Deleting Oracle Database $ORACLE_SID." - - $SU -s /bin/bash $ORACLE_OWNER -c "$DBCA -silent -deleteDatabase -sourceDB $ORACLE_SID -skipSYSDBAPasswordPrompt true" - -} -# To call DBCA to configure the DB -configure_perform() -{ - - DBFILE_CONSTRUCT="" - if [ "x$DBFILE_DEST" != "x" ] - then - DBFILE_CONSTRUCT="-storageType FS -datafileDestination $DBFILE_DEST" - fi - - LSNRPORT_CONSTRUCT="" - if [ "x$LISTENER_PORT" != "x" ] - then - LSNRPORT_CONSTRUCT="/lisport $LISTENER_PORT" - fi - - # Unset the proxy env vars before calling DBCA and NETCA - unset_proxy_vars - - MEMORY_CONSTRUCT="" - mem=`cat /proc/meminfo |grep MemTotal` - # Total physical memory - if [ "x$mem" != "x" ] - then - - #Convert into string array - - OLDIFS="$IFS" - IFS=' ' - str=($mem) - IFS=$OLDIFS - - #40 percent of physical memory - dbmem=$(( 40*${str[1]}/100 )) - - #Oracle memory is less than 2GB distribute to pga and sga - if [ "$dbmem" -lt "$MAXIMUM_MEMORY" ] - then - memory=$(( $dbmem/1024 )) - pga=$(( $memory/4 )) - sga=$(( 3*$memory/4 )) - MEMORY_CONSTRUCT="-initParams sga_target=${sga}M,pga_aggregate_target=${pga}M" - fi - - fi - ## Adding env var to disable custom scripts run post db creation - # - SQLSCRIPT_CONSTRUCT="-customScripts $ORACLE_HOME/assistants/dbca/postdb_creation.sql" - if [ "x$NO_POSTSCRIPT" != "x" ] - then - SQLSCRIPT_CONSTRUCT="" - fi - - echo "Configuring Oracle Listener." - - ORABASE=`$ORACLE_HOME/bin/orabase` - NETCA_LOG_DIR="$ORABASE/cfgtoollogs/netca" - if [ ! -d "$NETCA_LOG_DIR" ] - then - $SU -s /bin/bash $ORACLE_OWNER -c "$MKDIR_CMD -p $NETCA_LOG_DIR" - fi - NETCA_LOG="$NETCA_LOG_DIR/netca_configure_out.log" - - $SU -s /bin/bash $ORACLE_OWNER -c "$NETCA /orahome $ORACLE_HOME /instype typical /inscomp client,oraclenet,javavm,server,ano /insprtcl tcp /cfg local /authadp NO_VALUE /responseFile $ORACLE_HOME/network/install/netca_typ.rsp /silent /orahnam $ORACLE_HOME_NAME /listenerparameters DEFAULT_SERVICE=XE $LSNRPORT_CONSTRUCT >> $NETCA_LOG" - - RETVALNETCA=$? - if [ $RETVALNETCA -eq 0 ] - then - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR start $LISTENER_NAME > /dev/null" - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR status $LISTENER_NAME > /dev/null" - RETVALLSNRCTL=$? - if [ $RETVALLSNRCTL -eq 0 ] - then - echo "Listener configuration succeeded." - else - echo "Listener configuration failed. Check logs under '$NETCA_LOG_DIR'." - exit 1 - fi - else - echo "Listener configuration failed. Check log '$NETCA_LOG' for more details." - exit 1 - fi - - - echo "Configuring Oracle Database $ORACLE_SID." - - - $SU -s /bin/bash $ORACLE_OWNER -c "(echo '$ORACLE_PASSWORD'; echo '$ORACLE_PASSWORD'; echo '$ORACLE_PASSWORD') | $DBCA -silent -createDatabase -gdbName $ORACLE_SID -templateName $TEMPLATE_NAME -characterSet $CHARSET -createAsContainerDatabase $CREATE_AS_CDB -numberOfPDBs $NUMBER_OF_PDBS -pdbName $PDB_NAME -sid $ORACLE_SID -emConfiguration DBEXPRESS -emExpressPort $EM_EXPRESS_PORT -J-Doracle.assistants.dbca.validate.DBCredentials=false -sampleSchema true $SQLSCRIPT_CONSTRUCT $DBFILE_CONSTRUCT $MEMORY_CONSTRUCT" - - RETVAL=$? - - echo - if [ $RETVAL -eq 0 ] - then - print_success_connect - return 0 - else - echo "Database configuration failed. Check logs under '$ORABASE/cfgtoollogs/dbca'." - exit 1 - fi - return 0 -} -print_success_connect() -{ - - connectstr=`$ORACLE_HOME/bin/lsnrctl status $LISTENER_NAME |grep Connecting` - if [ "x$connectstr" != "x" ] - then - str1=($connectstr) - portfound=0 - i=0 - for str in "${str1[@]}" - do - istr=`echo $str` - if [ "$portfound" = "1" ] - then - break - else - if [ "x$istr" != "x" ] - then - if [ "$istr" != "${istr/\(PORT/}" ] - then - portfound=1 - index=$i - fi - fi - fi - i=$(( $i+1 )) - done - fi - if [ index = 0 ] - then - portv="PORT" - else - finalstr="${str1[index]}" - finalstr=`echo $finalstr |cut -d'=' -f 6` - portv="${finalstr/\)*/}" - fi - if [ "x$portv" = "x" ] - then - portv="PORT" - fi - hostname=`$HOSTNAME_CMD` - if [ "x$portv" = "x1521" ] - then - connectstr1="$hostname" - connectstr2="$hostname/$PDB_NAME" - else - connectstr1="$hostname:$portv" - connectstr2="$hostname:$portv/$PDB_NAME" - fi - - echo "Connect to Oracle Database using one of the connect strings:" - echo ' Pluggable database: '$connectstr2'' - echo ' Multitenant container database: '$connectstr1'' - em_url="https://localhost:$EM_EXPRESS_PORT/em" - echo 'Use '$em_url' to access Oracle Enterprise Manager for Oracle Database XE' - -} - -# Enh 27965939 - Unsets the proxy env variables -unset_proxy_vars() -{ - if [ "$http_proxy" != "" ] - then - unset http_proxy - fi - - if [ "$HTTP_PROXY" != "" ] - then - unset HTTP_PROXY - fi - - if [ "$https_proxy" != "" ] - then - unset https_proxy - fi - - if [ "$HTTPS_PROXY" != "" ] - then - unset HTTPS_PROXY - fi -} - -# Check if the DB is already configured -check_for_configuration() -{ - configfile=`$GREP --no-messages $ORACLE_SID:$ORACLE_HOME /etc/oratab` > /dev/null 2>&1 - if [ "$configfile" = "" ] - then - return 1 - fi - return 0 -} - -read_config_file() -{ - if [ -f "$CONFIGURATION" ] - then - . "$CONFIGURATION" - else - echo "The Oracle Database is not configured. Unable to read the configuration file '$CONFIGURATION'" - exit 1; - fi -} - -# Validation method to check for the port availability for Oracle DB listener -check_port_availability() -{ - if [ "x$SKIP_VALIDATIONS" = "xtrue" ] - then - return 0 - fi - if [ "x$LISTENER_PORT" = "x" ] - then - return 0 - fi - - $SU -s /bin/bash $ORACLE_OWNER -c "$LSNR status LISTENER" > /dev/null 2>&1 - RETVAL=$? - if [ $RETVAL -eq 0 ] - then - echo "Oracle Net Listener configured." - return 0 - fi - port=`netstat -n --tcp --listen | $GREP :$LISTENER_PORT` - if [ "$port" != "" ] - then - echo "Port $LISTENER_PORT appears to be in use by another application. Specify a different port in the configuration file '$CONFIGURATION'" - exit 1; - fi -} - -# Validation method to check for port availability for Oracle EM Express -check_em_express_port_availability() -{ - - if [ "x$SKIP_VALIDATIONS" = "xtrue" ] - then - return 0 - fi - if [ "x$EM_EXPRESS_PORT" = "x" ] - then - EM_EXPRESS_PORT="5500" - fi - port=`netstat -n --tcp --listen | $GREP :$EM_EXPRESS_PORT` - if [ "$port" != "" ] - then - echo "Port $EM_EXPRESS_PORT appears to be in use by another application. Specify a different Oracle EM Express port in the configuration file '$CONFIGURATION'" - exit 1; - fi -} - -check_memory() -{ - if [ "x$SKIP_VALIDATIONS" = "xtrue" ] - then - return 0 - fi - mem=`cat /proc/meminfo |grep MemFree` - if [ "x$mem" != "x" ] - then - str=($mem) - echo "Free memory available in the system ${str[1]}" - if [ "${str[1]}" -lt "$MINIMUM_MEMORY" ] - then - echo "Free memory available is not enough for database configuration" - echo "Need at least $MINIMUM_MEMORY_STR free for database configuration" - exit 1 - fi - fi -} - -check_space() -{ - if [ "x$SKIP_VALIDATIONS" = "xtrue" ] - then - return 0 - fi - - DBF_DEST_VALID=$DBFILE_DEST - if [ "x$DBF_DEST_VALID" = "x" ] - then - DBF_DEST_VALID=`$ORACLE_HOME/bin/orabase` - fi - if [ "x$DBF_DEST_VALID" != "x" ] - then - dspace=`$DF -k $DBF_DEST_VALID --direct | $TAIL -n 1| $AWK '{print $4}'` - dspace="${dspace//[$'\t\r\n ']}" - if [ "x$dspace" != "x" ] - then - if [ "$dspace" -lt "$MINIMUM_SPACE" ] - then - echo "The location '$DBF_DEST_VALID' specified for database files has insufficient space." - echo "Database creation needs at least '$MINIMUM_SPACE_STR' disk space." - echo "Specify a different database file destination that has enough space in the configuration file '$CONFIGURATION'." - exit 1 - fi - fi - fi -} - - -# Entry point to configure the DB -configure() -{ - check_for_configuration - RETVAL=$? - if [ $RETVAL -eq 0 ] - then - echo "Oracle Database instance $ORACLE_SID is already configured." - exit 1 - fi - read_config_file - check_space - check_port_availability - check_em_express_port_availability - configure_ask - configure_perform -} - - - -configure_ask() -{ - if [ "x$ORACLE_PASSWORD" != "x" ] - then - return 0 - fi - - #get the database password - while : - do - echo -n "Specify a password to be used for database accounts. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9]. Note that the same password will be used for SYS, SYSTEM and PDBADMIN accounts:" - while [ 1 ] - do - /bin/stty -echo > /dev/null 2>&1 - temp=`echo $IFS` - export IFS="\n" - while [ 1 ] - do - read LINE - while [ -z "$LINE" ] - do - echo - echo -n "Password cannot be null. Enter password:" - read LINE - done - - result=`expr index "$LINE" [\!\@\%\^\&\*\(\)\+\=\\|~\[\]{}\;\:\'\"\,\<\>\/\?]` - if [ $result != 0 ]; - then - echo - echo -n "The password you entered contains invalid characters. Enter password:" - else - break - fi - done - echo - echo -n "Confirm the password:" - read LINE1 - echo - if [ "$LINE" != "$LINE1" ]; - then - if [ ! -z $1 ] - then - echo - echo "Passwords do not match. Specify the same password for both ORACLE_PASSSWORD and -ORACLE_CONFIRM_PASSWORD, and retry the configuration." - trap "rm -fr $1" exit - exit - fi - echo - echo -n "Passwords do not match. Enter the password:" - else - break - fi - done - /bin/stty echo > /dev/null 2>&1 - ORACLE_PASSWORD=$LINE - export IFS=$temp - break; - done - -} - -restart() -{ - # Check if the DB is already stopped - pmon=`ps -ef | egrep pmon_$ORACLE_SID'\>' | $GREP -v grep` - if [ "$pmon" = "" ] - then - start - else - stop - start - fi -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - configure) - configure - ;; - delete) - configure_delete - ;; - restart) - restart - ;; - *) - echo $"Usage: $0 {start|stop|restart|configure|delete}" - exit 1 - ;; -esac - -exit 0 diff --git a/oracle-xe-18c.conf b/oracle-xe-18c.conf deleted file mode 100644 index e7a36e2eaf06..000000000000 --- a/oracle-xe-18c.conf +++ /dev/null @@ -1,18 +0,0 @@ -#This is a configuration file to setup the Oracle Database. -#It is used when running '/etc/init.d/oracle-xe-18c configure'. - -# LISTENER PORT used Database listener, Leave empty for automatic port assignment -LISTENER_PORT= - -# EM_EXPRESS_PORT Oracle EM Express URL port -EM_EXPRESS_PORT=5500 - -# Character set of the database -CHARSET=AL32UTF8 - -# Database file directory -# If not specified, database files are stored under Oracle base/oradata -DBFILE_DEST= - -# SKIP Validations, memory, space -SKIP_VALIDATIONS=false diff --git a/oracle-xe-18c.ld.so.conf b/oracle-xe-18c.ld.so.conf deleted file mode 100644 index 7d49a2def487..000000000000 --- a/oracle-xe-18c.ld.so.conf +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/oracle/product/18c/dbhomeXE/lib
\ No newline at end of file diff --git a/oracle-xe.install b/oracle-xe.install index 3cb6f3e37bb8..60bbf043043e 100644 --- a/oracle-xe.install +++ b/oracle-xe.install @@ -1,539 +1,70 @@ -pre_install(){ - #Create the corresponding log for the RPM installation - RPM_LOG_LOCATION=/var/log/oracle-database-xe-18c/results - RPM_LOG_FILE=$RPM_LOG_LOCATION/oraInstall.log - - mkdir -p $RPM_LOG_LOCATION - #Start the logging og the installation - echo '[INFO] Starting the installation process of the Oracle Database...' >> $RPM_LOG_FILE - echo $(date +%x-%r) >> $RPM_LOG_FILE - - # Do not execute %pre section during upgrade - RPM_ORCL_USR='oracle' - RPM_ORCL_USR_ID='54321' - - #Declare the arrays required to validate and create if necessary the required user groups - declare -a USER_GROUP_NAMES=('oinstall' 'dba' 'oper' 'backupdba' 'dgdba' 'kmdba' 'racdba') - declare -a USER_GROUP_IDS=('54321' '54322' '54323' '54324' '54325' '54326' '54330') - - #User group data organized for Oracle home owner creation - PRIMARY_USER_GROUP_NAME='oinstall' - SECONDARY_USER_GROUPS_NAMES='dba,oper,backupdba,dgdba,kmdba,racdba' - - # Identify platform on which this script is running, it might happen that it is running - # on a platform where rpm logic doesn't work as the rpm might have been converted to other - # installation media. - DISTRO='' - - if [ -f /etc/debian_version ]; then - DISTRO='DEBIAN' - elif [ -f /etc/ubuntu_version ]; then - DISTRO='UBUNTU' - elif [ -f /etc/redhat-release ]; then - DISTRO='REDHAT' - elif [ -f /etc/lsb-release ]; then - DISTRO_NAME=$(lsb_release -si) - DISTRO="$(tr [a-z] [A-Z] <<< $DISTRO_NAME)" - else - DISTRO=$(uname -s) - fi - - # User must be root - - if [ $(id -u) != "0" ]; then - echo "[SEVERE] You must be the root user to install the software" >&2 - exit 1 - fi - - # ORACLE_BASE must be unset - if `env | grep -q ORACLE_BASE`; then - unset ORACLE_BASE - fi - #check if the required user groups exists, if not then they are created. - - USER_GROUP_INDEX=0 - #Declare an array to store the detected remote groups during the pre check installation - declare -a REMOTE_GROUP_LIST=(); - - for TARGET_USER_GROUP in "${USER_GROUP_NAMES[@]}" - do - getent group "${TARGET_USER_GROUP}" >> /dev/null - if [ "$?" -ne "0" ]; then - #In case that the group is there, but not a primary one, then we lastly check locally - grep "^${TARGET_USER_GROUP}:" -q /etc/group - if [ "$?" -ne "0" ]; then - #group doesn't exist create it - groupadd -g "${USER_GROUP_IDS[USER_GROUP_INDEX]}" "${TARGET_USER_GROUP}" - if [ "$?" -ne "0" ]; then - echo "[SEVERE] Unable to create group $TARGET_USER_GROUP" - exit 1 - fi - fi - else - REMOTE_GROUP_LIST+=("${TARGET_USER_GROUP}") - fi - ((USER_GROUP_INDEX++)) - done - - #check if rpm_oracle user exist, if not, create it - id "${RPM_ORCL_USR}" > /dev/null 2>&1; - if [ "$?" -ne "0" ]; then - #user doesn't exist, create it - useradd --uid "${RPM_ORCL_USR_ID}" --gid "${PRIMARY_USER_GROUP_NAME}" -G "${SECONDARY_USER_GROUPS_NAMES}" -M "${RPM_ORCL_USR}" - - if [ "$?" -ne "0" ]; then - echo "[SEVERE] Unable to create user $RPM_ORCL_USR" - exit 1 - fi - else - #If the user does exist then we check for the added groups - for TARGET_GROUP_NAME in "${USER_GROUP_NAMES[@]}" - do - getent group "${TARGET_GROUP_NAME}" | grep -w "${RPM_ORCL_USR}" > /dev/null - if [ "$?" -ne "0" ]; then - #If the user name is not currently part of the determined group,then we add it - /usr/sbin/usermod -a -G "${TARGET_GROUP_NAME}" "${RPM_ORCL_USR}" - - #Check for operation status - if [ "$?" -ne "0" ]; then - echo "[WARNING] Unable to add ${RPM_ORCL_USR} to $TARGET_GROUP_NAME group. Verify and add it manually. Not doing so may cause some features to not work properly due incorrect user privileges on the system." - fi - fi - done - fi - - #Verify that all the detected remote user groups were indeed added to the target user. Otherwise we flag the warning - for DETECTED_USER_GROUP in "${REMOTE_GROUP_LIST[@]}" - do - groups "${RPM_ORCL_USR}" | grep -q "\b${DETECTED_USER_GROUP}\b" - if [ "$?" -ne "0" ]; then - #The target user is not currently part not was added to a given remote group, therefore we need to flag it to the user - #It can proceed with no issues. - echo "[WARNING] The ${RPM_ORCL_USR} user couldn't be added to the ${DETECTED_USER_GROUP} group because such group is defined in a remote directory. It is recommended to complete this operation manually, not doing so may cause some features to not work properly due incorrect user privileges on the system." - fi - done - - if [ -f '/etc/oraInst.loc' ]; then - INVENTORY_GROUP_NAME=`cat /etc/oraInst.loc | grep -o ^inst_group=.* | sed -e 's/^inst_group=//'` - - echo "[INFO] Existing Oracle inventory detected. Currently owned by ${INVENTORY_GROUP_NAME}" >> $RPM_LOG_FILE - - #if the user name is not currently part of the determined group,then we add it - /usr/sbin/usermod -a -G "${INVENTORY_GROUP_NAME}" "${RPM_ORCL_USR}" - - #Check if indeed the user group was added to the oracle user - groups "${RPM_ORCL_USR}" | grep -q "\b${INVENTORY_GROUP_NAME}\b" - if [ "$?" -ne "0" ]; then - #The user group could not be added using the local command, therefore, we need to confirm that indeed is a remote (LDAP) group - getent group "${INVENTORY_GROUP_NAME}" >> /dev/null - if [ "$?" -eq "0" ]; then - echo "[WARNING] The ${RPM_ORCL_USR} user couldn't be added to the ${INVENTORY_GROUP_NAME} group because such group is defined in a remote directory. Verify and try again to register manually the Oracle home into the existing inventory." - else - echo "[WARNING] There was an issue when attempting to register the Oracle home into the existing inventory" - fi - fi - fi - - # Check and disallow installation of 12.2, if oracle home directory - # exists and is not empty - - if [ -d /opt/oracle/product/18c/dbhomeXE ]; then - if [ X"`ls -A /opt/oracle/product/18c/dbhomeXE`" != "X" ]; then - echo "[SEVERE] The install cannot proceed because the directory \"/opt/oracle/product/18c/dbhomeXE\" - is not empty. Remove its contents and retry the installation." - echo - exit 1 - fi - fi - - # Check and disallow if ORACLE_BASE directory /opt/oracle exists and not owned by oracle:oinstall - - if [ -d /opt/oracle ]; then - if [ "`ls -ld /opt/oracle | grep ^d | awk '{ print $3}'`" != "${RPM_ORCL_USR}" ]; then - echo - echo "[SEVERE] The install cannot proceed because ORACLE_BASE directory (/opt/oracle) -is not owned by \"${RPM_ORCL_USR}\" user. You must change the ownership of ORACLE_BASE - directory to \"$RPM_ORCL_USR\" user and retry the installation." - echo - exit 1 - fi - fi - - if [ -d /opt/oracle ]; then - if [ "`ls -ld /opt/oracle | grep ^d | awk '{ print $4}'`" != "${PRIMARY_USER_GROUP_NAME}" ]; then - echo - echo "[SEVERE] The install cannot proceed because ORACLE_BASE directory (/opt/oracle) -is not owned by \"${PRIMARY_USER_GROUP_NAME}\" group. You must change the ownership of - ORACLE_BASE directory to \"${PRIMARY_USER_GROUP_NAME}\" group and retry the installation." - echo - exit 1 - fi - fi - - # Check and change directory permissions to 755 if it is less at all the levels of the Oracle home path. - - if [ -d /opt/oracle ]; then - if test `stat -c "%a" /opt` -lt 755; then - chmod 755 /opt - fi - fi - - if [ -d /opt/oracle ]; then - if test `stat -c "%a" /opt/oracle` -lt 755; then - chmod 755 /opt/oracle - fi - fi - - if [ -d /opt/oracle/product ]; then - if test `stat -c "%a" /opt/oracle/product` -lt 755; then - chmod 755 /opt/oracle/product - fi - fi - - if [ -d /opt/oracle/product/18c ]; then - if test `stat -c "%a" /opt/oracle/product/18c` -lt 755; then - chmod 755 /opt/oracle/product/18c - fi - fi - - if [ -d /opt/oracle/product/18c/dbhomeXE ]; then - if test `stat -c "%a" /opt/oracle/product/18c/dbhomeXE` -lt 755; then - chmod 755 /opt/oracle/product/18c/dbhomeXE - fi - fi - - # Check and disallow for the required diskspace is not present on the system - if [ -d /opt/oracle ] - then - diskspace=`df -Pk /opt/oracle | grep % | tr -s " " | cut -d" " -f4 | tail -1` - diskspace=`expr $diskspace / 1024` - if [ $diskspace -lt 7680 ] - then - echo "[SEVERE] You have insufficient diskspace in the destination directory (/opt/oracle) -to install Oracle Database 18c Express Edition. The installation requires at - least 7680 MB free on this disk." - exit 1 - fi -elif [ -d /opt ] - then - diskspace=`df -k /opt | grep % | tr -s " " | cut -d" " -f4 | tail -1` - diskspace=`expr $diskspace / 1024` - if [ $diskspace -lt 7680 ] - then - echo "[SEVERE] You have insufficient diskspace in the destination directory (/opt) to -install Oracle Database 18c Express Edition. The installation requires at - least 7680 MB free on this disk." - exit 1 - fi - else - diskspace=`df -Pk / | grep % | tr -s " " | cut -d" " -f4 | tail -1` - diskspace=`expr $diskspace / 1024` - if [ $diskspace -lt 7680 ] - then - echo "[SEVERE] You have insufficient diskspace to install Oracle Database 18c Express Edition. - The installation requires at least 7680 MB free diskspace." - exit 1 - - fi - fi - - # Check and disallow install, if RAM is less than 1 GB - space=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $2}'` - PhyMem=`expr $space / 1024` - swapspace=`free -m | grep Swap | awk '{print $4}'` - - if [ $PhyMem -lt 1024 ] - then - echo "[SEVERE] Oracle Database 18c Express Edition requires a minimum of 1GB of physical -memory (RAM). This system has $PhyMem MB of RAM and does not meet minimum - requirements." - echo - exit 1 - fi +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 +} - # Finally, we check for the docker-based installs that we disable the hard memlock parameter for the oracle user - # to assure that the post installation and database lifecycle in the environment. - if `env | grep -q ORACLE_DOCKER_INSTALL` - then - echo "[INFO] Container installation detected, adjusting corresponding parameters..." >> $RPM_LOG_FILE - target_security_file=/etc/security/limits.d/oracle-database-preinstall-18c.conf +post_install() { + # Fix Permissions + chown -R oracle:oinstall /opt/oracle /etc/oratab /var/lib/oracle - if [ -f $target_security_file ] - then - # Proceed to update the corresponding parameter - target_txt=`cat $target_security_file | grep -e 'oracle *hard *memlock*'` - `sed -i "/^$target_txt/ c#$target_txt" $target_security_file` - echo "[INFO] Container related settings updated" >> $RPM_LOG_FILE - else - echo "[WARNING] Container parameters not found, skipping parameters modification" - fi - fi + # 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' - # At the end we need to check that the RPM_ORCL_USR has the required su privilegies for the post install and - # further configuration actions for the Oracle Database. - su $RPM_ORCL_USR -c "echo Testing..." >> /dev/null - if [ $? -ne "0" ] - then - echo "[SEVERE] The su command is not configured properly or the $RPM_ORCL_USR user does not have the required privileges to install the Oracle database. If you are running in a Docker environment, ensure to set the environment variable ORACLE_DOCKER_INSTALL=true and try again."; - exit 1 - fi -} + # Create Default Pluggable Database + cat <<- 'EOF' -post_install(){ - RPM_LOG_FILE=/var/log/oracle-database-xe-18c/results/oraInstall.log; - INVENTORY_SETUP_ALREADY=false; - if [ -f '/etc/oraInst.loc' ]; then - INVENTORY_LOC=`cat /etc/oraInst.loc | grep -o ^inventory_loc=.* | sed -e 's/^inventory_loc=//'`; - echo "[INFO] Inventory located at: ${INVENTORY_LOC}" >> $RPM_LOG_FILE; - INVENTORY_SETUP_ALREADY=true; - else - INVENTORY_LOC='/opt/oracle/oraInventory'; - fi - INVENTORY_FILE="${INVENTORY_LOC}/ContentsXML/inventory.xml"; - SEQ=1; - MAX_VAL=0; - ORA_HOME_NAME_PREFIX='OraHome_'; - NEW_ORA_HOME_NAME='OraHomeXE'; - if [ -f "${INVENTORY_FILE}" ]; then - LAST_ORA_HOME_NAME=`cat ${INVENTORY_FILE} | grep -o 'NAME=['"'"'"][^"'"'"']*['"'"'"]' | sed -e 's/^NAME=["'"'"']//' -e 's/["'"'"']$//' | sort | uniq | tail -n 1`; - if [ ! -z "${LAST_ORA_HOME_NAME}" ]; then - MAX_VAL="${LAST_ORA_HOME_NAME//[!0-9]/}"; - if [ -z "${MAX_VAL}" ]; then - ORA_HOME_NAME_PREFIX="${LAST_ORA_HOME_NAME}_" - fi - SEQ="$(($MAX_VAL + 1))" - fi - NEW_ORA_HOME_NAME="$ORA_HOME_NAME_PREFIX$SEQ" - echo "[INFO] Oracle home name defined as: ${NEW_ORA_HOME_NAME}" >> $RPM_LOG_FILE; - fi - chown -R oracle:oinstall /opt/oracle - echo "[INFO] Registering Oracle home to the Oracle inventory..." >> $RPM_LOG_FILE; - su -c "/opt/oracle/product/18c/dbhomeXE/oui/bin/runInstaller.sh -silent -ignoreSysPrereqs -detachHome ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE ORACLE_BASE=/opt/oracle ORACLE_HOME_NAME=${NEW_ORA_HOME_NAME} INVENTORY_LOCATION=${INVENTORY_LOC} " >> /dev/null -m oracle - su -c "/opt/oracle/product/18c/dbhomeXE/oui/bin/runInstaller.sh -silent -ignoreSysPrereqs -attachHome ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE ORACLE_BASE=/opt/oracle ORACLE_HOME_NAME=${NEW_ORA_HOME_NAME} INVENTORY_LOCATION=${INVENTORY_LOC} " >> /dev/null -m oracle - if [ $? -ne "0" ]; then - echo "[SEVERE] An error occurred while registering the Oracle home. Verify logs in ${RPM_LOG_FILE} and ${INVENTORY_LOC} for more details and try again." - exit 1 - fi - echo "[INFO] Oracle home registered to the Oracle inventory." >> $RPM_LOG_FILE; - echo "[INFO] Executing post installation scripts...">> $RPM_LOG_FILE; - echo "[INFO] Executing post installation scripts..."; - if [ "$INVENTORY_SETUP_ALREADY" = "false" ]; then - echo "[INFO] Setting up inventory as it has not been setup on this machine." >> $RPM_LOG_FILE; - if [ -f "${INVENTORY_LOC}/orainstRoot.sh" ] - then - ${INVENTORY_LOC}/orainstRoot.sh >> /dev/null - fi - fi - /opt/oracle/product/18c/dbhomeXE/root.sh >> /dev/null - chmod 6751 /opt/oracle/product/18c/dbhomeXE/bin/oracle >> /dev/null - if [ "$INVENTORY_SETUP_ALREADY" = "false" ]; then - if [ -f "/etc/oratab" ] - then - chown -R oracle:oinstall /etc/oratab - fi - fi - echo "[INFO] Configuring ADR directories..." >> $RPM_LOG_FILE; - su -c "/opt/oracle/product/18c/dbhomeXE/bin/diagsetup clustercheck=false basedir=/opt/oracle oraclehome=/opt/oracle/product/18c/dbhomeXE " >> /dev/null -m oracle - if [ $? -ne "0" ]; then - echo "[SEVERE] An error occurred while configuring the ADR directories for the Oracle home. Verify the execution of the following command: /opt/oracle/product/18c/dbhomeXE/bin/diagsetup clustercheck=false basedir=/opt/oracle oraclehome=/opt/oracle/product/18c/dbhomeXE " - exit 1 - fi - echo "[INFO] ADR directories configured." >> $RPM_LOG_FILE; - echo "[INFO] Post installation scripts executed successfully." >> $RPM_LOG_FILE; + [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' - echo "[INFO] Oracle home installed successfully and ready to be configured." >> $RPM_LOG_FILE; - echo "[INFO] Oracle home installed successfully and ready to be configured."; - echo "To configure Oracle Database XE, optionally modify the parameters in '/etc/sysconfig/oracle-xe-18c.conf' and then execute '/etc/init.d/oracle-xe-18c configure' as root." + EOF } -pre_remove(){ - RPM_LOG_FILE=/var/log/oracle-database-xe-18c/results/oraInstall.log; - echo "[PRE-UNINSTALL]" >> $RPM_LOG_FILE; - echo "[INFO] Performing uninstall actions on Oracle home..." >> $RPM_LOG_FILE; - echo "$(date +%x-%r)" >> $RPM_LOG_FILE; - TMP_FOLDER='/tmp'; - FOLDER_NAME_FRM="deinstall_rsp_"; - SEQ=1; - IS_ENV_CLEAN=false; - SEARCH_RES=`find $TMP_FOLDER -maxdepth 1 -type d -name $FOLDER_NAME_FRM* | sort -t'_' -n -k3 | tail -n 1`; - if [ ! -z "$SEARCH_RES" ]; then - MAX_VAL="${SEARCH_RES//[!0-9]/}"; - SEQ="$(($MAX_VAL + 1))"; - fi - DEINST_FOLDER="$FOLDER_NAME_FRM$SEQ"; - mkdir -p "$TMP_FOLDER"/"$DEINST_FOLDER" - chmod -R 777 "$TMP_FOLDER" - echo "[INFO] Discovering configuration in Oracle home ..." >> $RPM_LOG_FILE; - if [ -f "/opt/oracle/product/18c/dbhomeXE/deinstall/deinstall" ]; then - su -c "/opt/oracle/product/18c/dbhomeXE/deinstall/deinstall -silent -checkonly -tmpdir $TMP_FOLDER/$DEINST_FOLDER > /dev/null" -m oracle - if [ $? -ne "0" ]; then - echo "[SEVERE] An error occured while discovering the configuration of the Oracle home. Verify the deinstall logs for more details." - exit 1 - fi - echo "[INFO] Configuration discovering completed ..." >> $RPM_LOG_FILE; - DEINST_SPEC_FILE=`find $TMP_FOLDER/$DEINST_FOLDER -type f -name *.rsp`; - if [ ! -z "$DEINST_SPEC_FILE" ]; then - LISTENERS_VALUE=`awk -F= -v key="NETCA_LOCAL_LISTENERS" '$1==key {print $2}' $DEINST_SPEC_FILE`; - DBS_VALUE=`awk -F= -v key="DB_UNIQUE_NAME_LIST" '$1==key {print $2}' $DEINST_SPEC_FILE`; - if [ -z "$LISTENERS_VALUE" ] && [ -z "$DBS_VALUE" ] - then - IS_ENV_CLEAN=true; - fi - else - echo "[SEVERE] Deinstall parameter file not found. Automatic deinstallation cannot proceed."; - exit 1 - fi - if [ "$IS_ENV_CLEAN" = true ]; then - echo "[INFO] Proceeding with RPM deinstallation ..." >> $RPM_LOG_FILE; - su -c "/opt/oracle/product/18c/dbhomeXE/oui/bin/detachHome.sh > /dev/null" -m oracle - if [ $? -ne "0" ]; then - echo "[SEVERE] An error occured while detaching the Oracle home from the inventory. Verify and try again." - exit 1 - fi - else - echo "[SEVERE] Database or a listener exists. To delete the database and the listener run '/etc/init.d/oracle-xe-18c delete' as root."; - exit 1 - fi - else - echo "[INFO] Oracle home software not found ..." >> $RPM_LOG_FILE - fi - echo "[INFO] Oracle home software removed successfully." >> $RPM_LOG_FILE +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(){ - if [ -f '/etc/oraInst.loc' ]; then - #Existing inventory found!! - INVENTORY_LOCATION=`cat /etc/oraInst.loc | grep -o ^inventory_loc=.* | sed -e 's/^inventory_loc=//'`; - INVENTORY_FILE="${INVENTORY_LOCATION}/ContentsXML/inventory.xml"; - #First validate if the inventory is already empty - if `grep -q '<HOME *NAME=' $INVENTORY_FILE`; then - #Registered homes found - if `grep -v '<HOME *NAME=.*LOC=\"/opt/oracle/.*REMOVED=\"T\"' $INVENTORY_FILE | grep -q '<HOME *NAME=.*LOC=\"/opt/oracle/'`; then - #Remove everything under RPM home; - rm -rf /opt/oracle/product/18c/dbhomeXE >> /dev/null; - grep -v '<HOME *NAME=.*LOC=\"/opt/oracle/product/18c.*REMOVED=\"T\"' $INVENTORY_FILE | grep -q '<HOME *NAME=.*LOC=\"/opt/oracle/product/18c' - if [ $? != 0 ];then - #Remove up to version location since there are no more homes registered to that product version - rm -rf /opt/oracle/product/18c >> /dev/null; - fi - else - #Cleaning oracle base with exception of oraInventory - rm -rf /opt/oracle/product/18c/dbhomeXE >> /dev/null; - ADMIN_FOLDER=/opt/oracle/admin; - if [ -d "$ADMIN_FOLDER" ] && [ -z "$(ls -A $ADMIN_FOLDER)" ]; then - rm -rf $ADMIN_FOLDER >> /dev/null; - fi - AUDIT_FOLDER=/opt/oracle/audit; - if [ -d "$AUDIT_FOLDER" ] && [ -z "$(ls -A $AUDIT_FOLDER)" ]; then - rm -rf $AUDIT_FOLDER >> /dev/null; - fi - CFGTOOLLOGS_FOLDER=/opt/oracle/cfgtoollogs; - if [ -d "$CFGTOOLLOGS_FOLDER" ] && [ -z "$(ls -A $CFGTOOLLOGS_FOLDER)" ]; then - rm -rf $CFGTOOLLOGS_FOLDER >> /dev/null; - fi - CHECKPOINTS_FOLDER=/opt/oracle/checkpoints; - if [ -d "$CHECKPOINTS_FOLDER" ] && [ -z "$(ls -A $CHECKPOINTS_FOLDER)" ]; then - rm -rf $CHECKPOINTS_FOLDER >> /dev/null; - fi - DIAG_FOLDER=/opt/oracle/diag; - #Using files to assure cross console env compatibility - if [ -d "$DIAG_FOLDER" ]; then - DIAG_EMPTY_LOG=/tmp/diag_empty_folders.tmp; - DIAG_FOLDER_LOG=/tmp/diag_folders.tmp; - find $DIAG_FOLDER/* -type d -empty > $DIAG_EMPTY_LOG; - find $DIAG_FOLDER/* -type d > $DIAG_FOLDER_LOG; - if [ -z "$(diff $DIAG_EMPTY_LOG $DIAG_FOLDER_LOG)" ]; then - rm -rf $DIAG_FOLDER >> /dev/null; - fi - rm -rf $DIAG_EMPTY_LOG >> /dev/null; - rm -rf $DIAG_FOLDER_LOG >> /dev/null; - fi - FRA_FOLDER=/opt/oracle/fast_recovery_area; - if [ -d "$FRA_FOLDER" ] && [ -z "$(ls -A $FRA_FOLDER)" ]; then - rm -rf $FRA_FOLDER >> /dev/null; - fi - ORADATA_FOLDER=/opt/oracle/oradata; - if [ -d "$ORADATA_FOLDER" ] && [ -z "$(ls -A $ORADATA_FOLDER)" ]; then - rm -rf $ORADATA_FOLDER >> /dev/null; - fi - PRODUCT_FOLDER=/opt/oracle/product; - #Using files to assure cross console env compatibility - if [ -d "$PRODUCT_FOLDER" ]; then - PRODUCT_EMPTY_LOG=/tmp/product_empty_folders.tmp; - PRODUCT_FOLDER_LOG=/tmp/product_folders.tmp; - find $PRODUCT_FOLDER/* -type d -empty > $PRODUCT_EMPTY_LOG; - find $PRODUCT_FOLDER/* -type d > $PRODUCT_FOLDER_LOG; - if [ -z "$(diff $PRODUCT_EMPTY_LOG $PRODUCT_FOLDER_LOG)" ]; then - rm -rf $PRODUCT_FOLDER >> /dev/null; - fi - rm -rf $PRODUCT_EMPTY_LOG >> /dev/null; - rm -rf $PRODUCT_FOLDER_LOG >> /dev/null; - fi - fi - else - #Can wipe everything - rm -rf /opt/oracle/product/18c/dbhomeXE >> /dev/null; - ADMIN_FOLDER=/opt/oracle/admin; - if [ -d "$ADMIN_FOLDER" ] && [ -z "$(ls -A $ADMIN_FOLDER)" ]; then - rm -rf $ADMIN_FOLDER >> /dev/null; - fi - AUDIT_FOLDER=/opt/oracle/audit; - if [ -d "$AUDIT_FOLDER" ] && [ -z "$(ls -A $AUDIT_FOLDER)" ]; then - rm -rf $AUDIT_FOLDER >> /dev/null; - fi - CFGTOOLLOGS_FOLDER=/opt/oracle/cfgtoollogs; - if [ -d "$CFGTOOLLOGS_FOLDER" ] && [ -z "$(ls -A $CFGTOOLLOGS_FOLDER)" ]; then - rm -rf $CFGTOOLLOGS_FOLDER >> /dev/null; - fi - CHECKPOINTS_FOLDER=/opt/oracle/checkpoints; - if [ -d "$CHECKPOINTS_FOLDER" ] && [ -z "$(ls -A $CHECKPOINTS_FOLDER)" ]; then - rm -rf $CHECKPOINTS_FOLDER >> /dev/null; - fi - DIAG_FOLDER=/opt/oracle/diag; - #Using files to assure cross console env compatibility - if [ -d "$DIAG_FOLDER" ]; then - DIAG_EMPTY_LOG=/tmp/diag_empty_folders.tmp; - DIAG_FOLDER_LOG=/tmp/diag_folders.tmp; - find $DIAG_FOLDER/* -type d -empty > $DIAG_EMPTY_LOG; - find $DIAG_FOLDER/* -type d > $DIAG_FOLDER_LOG; - if [ -z "$(diff $DIAG_EMPTY_LOG $DIAG_FOLDER_LOG)" ]; then - rm -rf $DIAG_FOLDER >> /dev/null; - fi - rm -rf $DIAG_EMPTY_LOG >> /dev/null; - rm -rf $DIAG_FOLDER_LOG >> /dev/null; - fi - FRA_FOLDER=/opt/oracle/fast_recovery_area; - if [ -d "$FRA_FOLDER" ] && [ -z "$(ls -A $FRA_FOLDER)" ]; then - rm -rf $FRA_FOLDER >> /dev/null; - fi - ORADATA_FOLDER=/opt/oracle/oradata; - if [ -d "$ORADATA_FOLDER" ] && [ -z "$(ls -A $ORADATA_FOLDER)" ]; then - rm -rf $ORADATA_FOLDER >> /dev/null; - fi - PRODUCT_FOLDER=/opt/oracle/product; - #Using files to assure cross console env compatibility - if [ -d "$PRODUCT_FOLDER" ]; then - PRODUCT_EMPTY_LOG=/tmp/product_empty_folders.tmp; - PRODUCT_FOLDER_LOG=/tmp/product_folders.tmp; - find $PRODUCT_FOLDER/* -type d -empty > $PRODUCT_EMPTY_LOG; - find $PRODUCT_FOLDER/* -type d > $PRODUCT_FOLDER_LOG; - if [ -z "$(diff $PRODUCT_EMPTY_LOG $PRODUCT_FOLDER_LOG)" ]; then - rm -rf $PRODUCT_FOLDER >> /dev/null; - fi - rm -rf $PRODUCT_EMPTY_LOG >> /dev/null; - rm -rf $PRODUCT_FOLDER_LOG >> /dev/null; - fi - - rm -rf $INVENTORY_LOCATION >> /dev/null; +post_remove() { + # Oracle Group Names and GIDs + ORACLE_GROUP_NAMES=('oinstall' 'dba' 'oper' 'backupdba' 'dgdba' 'kmdba' 'racdba') - ORACLE_BASE=/opt/oracle; - if [ -z "$(ls -A $ORACLE_BASE)" ]; then - rm -rf $ORACLE_BASE >> /dev/null; - fi - fi - fi + # Remove Oracle Users and Groups + userdel oracle + for gp in ${ORACLE_GROUP_NAMES[@]};do + groupdel $gp + done - #Also remove the corresponding RPM log location - rm -rf /var/log/oracle-database-xe-18c >> /dev/null - rm -fr /usr/share/doc/oracle-xe-18c >> /dev/null + # Remove Database Files + rm -rf /opt/oracle /var/lib/oracle } diff --git a/oracle-xe.service b/oracle-xe.service index e84e5e6b72b0..a9d2c6774a84 100644 --- a/oracle-xe.service +++ b/oracle-xe.service @@ -1,8 +1,20 @@ [Unit] -Description=Oracle XE +Description=Oracle Database Express Edition [Service] +Environment=ORACLE_HOME=/opt/oracle/product/18c/dbhomeXE +Environment=ORACLE_SID=XE +User=oracle +Group=oinstall +LimitNOFILE=65536 +LimitNPROC=16384 +LimitSTACK=33554432 +LimitMEMLOCK=134217728 Type=oneshot -ExecStart=/etc/rc.d/oracle-xe-18c start -ExecStop=/etc/rc.d/oracle-xe-18c stop -RemainAfterExit=yes +ExecStartPre=/opt/oracle/product/18c/dbhomeXE/bin/lsnrctl start LISTENER +ExecStart=bash -c 'echo -e "connect / as sysdba\nstartup\nalter pluggable database all open\nexit;" | /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s /nolog' +ExecStop=bash -c 'echo -e "connect / as sysdba\nshutdown immediate\nexit;" | /opt/oracle/product/18c/dbhomeXE/bin/sqlplus -s /nolog' +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target |