#!/bin/bash # # # chkconfig: 2345 80 05 # description: This is a program that is responsible for taking care of # configuring the Oracle Database 10g Express Edition and its associated # services. # # processname: oracle-xe # config: /etc/conf.d/oracle-xe # # change log: # svaggu - creation 28-Sep-2005 ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server ORACLE_OWNER=oraclexe ORACLE_GROUP=dba ORACLE_SID=XE LSNR=$ORACLE_HOME/bin/lsnrctl SQLPLUS=$ORACLE_HOME/bin/sqlplus SU=/bin/su export ORACLE_HOME export ORACLE_SID export ORACLE_OWNER export ORACLE_GROUP export PATH=$ORACLE_HOME/bin:$PATH LOG="$ORACLE_HOME_LISTNER/listener.log" export LC_ALL=C if [ $(id -u) != "0" ] then echo "You must be root to run the configure script. Login as root and then run the configure script." exit 1 fi # # write_sysconfig() # # Writes the system configuration # write_sysconfig() { cat >/etc/conf.d/oracle-xe <> /etc/oratab else echo "XE:$ORACLE_HOME:N" >> /etc/oratab chown $ORACLE_OWNER:$ORACLE_GROUP /etc/oratab chmod 644 /etc/oratab fi echo Configuring Database... SQLPLUS="$ORACLE_HOME/bin/sqlplus" $SU $ORACLE_OWNER -c "$ORACLE_HOME/config/scripts/XE.sh" echo "alter user flows_020100 identified by \"$ORACLE_PASSWORD\";" | $SU $ORACLE_OWNER -c "$SQLPLUS -s / as sysdba" echo "alter user sys identified by \"$ORACLE_PASSWORD\";" | $SU $ORACLE_OWNER -c "$SQLPLUS -s / as sysdba" echo "alter user system identified by \"$ORACLE_PASSWORD\";" | $SU $ORACLE_OWNER -c "$SQLPLUS -s / as sysdba" echo "alter user flows_files identified by \"$ORACLE_PASSWORD\";" | $SU $ORACLE_OWNER -c "$SQLPLUS -s / as sysdba" echo "alter user anonymous identified by \"$ORACLE_PASSWORD\";" | $SU $ORACLE_OWNER -c "$SQLPLUS -s / as sysdba" $SU $ORACLE_OWNER -c "$ORACLE_HOME/bin/sqlplus -s /nolog @$ORACLE_HOME/config/scripts/stopdb.sql" chmod -R 640 /usr/lib/oracle/xe/oradata/XE chmod 750 /usr/lib/oracle/xe/oradata/XE chown -R oraclexe:dba /usr/lib/oracle/xe rm -fr $ORACLE_HOME/config/seeddb echo "Done." echo echo "To start oracle-xe, run:" echo "/etc/init.d/oracle-xe start" echo "and point your Browser to:" echo "http://localhost:$HTTP_PORT/apex/" echo echo "Log in using username system and the password you supplied..." echo } # #configure_ask() # # Ask configuration questions,setting the variables. # configure_ask() { cat < to accept the defaults. Ctrl-C will abort. EOF #get the http port value while : do while [ 1 ] do echo -n Specify the HTTP port that will be used for HTML DB [8080]: read LINE if [ -z $LINE ] then LINE=8080 fi port=`netstat -n --tcp --listen | grep :$LINE | awk '{print $4}' | cut -d':' -f2` if [ "$port" = "$LINE" ] then echo Port $port appears to be in use by another application.\ Please specify a different port. else break; fi done case "$LINE" in "") break ;; *[^0-9]*) echo "Invalid http port: $LINE" >&2 ;; *) HTTP_PORT=$LINE break ;; esac done #get the listener port value while : do echo while [ 1 ] do echo -n Specify a port that will be used for the database listener [1521]: read LINE if [ -z $LINE ] then LINE=1521 fi echo port=`netstat -n --tcp --listen | grep :$LINE | awk '{print $4}' | cut -d':' -f2` if [ "$port" = "$LINE" ] then echo Port $port appears to be in use by another application.\ Please specify a different port. else break; fi done case "$LINE" in "") break ;; *[^0-9]*) echo "Invalid port: $LINE" >&2 ;; *) LISTENER_PORT=$LINE break ;; esac done #get the database password while : do echo -n "Specify a password to be used for database accounts. Note that the same password will be used for SYS, SYSTEM and FLOWS_020100. Oracle recommends the use of different passwords for each database account. This can be done after initial configuration:" while [ 1 ] do stty -echo read LINE while [ -z $LINE ] do echo echo -n "Password can't be null. Enter password:" read LINE done if [ -n $LINE ] then echo echo -n "Confirm the password:" read LINE1 echo if [ "$LINE" != "$LINE1" ]; then echo echo -n "Passwords do not match. Enter the password:" else break; fi fi done case "$LINE" in *[^a-zA-Z0-9]*) echo "Invalid password: $LINE" >&2 ;; *) stty echo ORACLE_PASSWORD=$LINE break ;; esac done } configure() { configure_ask configure_perform CONFIGURE_RUN=true write_sysconfig } configure