#!/bin/sh
ORACLE_HOME="/opt/app/oracle/product/11.2.0/db_1"
DB_INST=`ps -ef | grep ora_pmon | grep -v "grep ora_pmon" | awk '{print($8)}' | sed 's/ora\_pmon\_//g'`
#echo "db instance name=${DB_INST}"
sed -i "/ORACLE_SID=ttv/d"  /home/oracle/.bash_profile
echo "export ORACLE_SID=${DB_INST}" >> /home/oracle/.bash_profile

sed -i "/define _editor=[.]*/d" ${ORACLE_HOME}/sqlplus/admin/glogin.sql
grep -q "^define _editor" ${ORACLE_HOME}/sqlplus/admin/glogin.sql
if [ $? -ne 0 ]; then
        echo "define _editor=vi" >> ${ORACLE_HOME}/sqlplus/admin/glogin.sql
fi

sed -i "/set sqlprompt [.]*/d" ${ORACLE_HOME}/sqlplus/admin/glogin.sql
grep -q "^set sqlprompt" ${ORACLE_HOME}/sqlplus/admin/glogin.sql
if [ $? -ne 0 ]; then
        echo "set sqlprompt \"_USER'@'_CONNECT_IDENTIFIER > \"" >> ${ORACLE_HOME}/sqlplus/admin/glogin.sql
fi
