shell编程~学习笔记

shell编程,涉及文件的修改,sql文件的执行,表空间和用户的创建

#!/bin/sh
#tabase initialized

cd
mkdir orcldata
cd -
echo "Hello, Please create your ODS user and password!"
echo "Enter your ODS user:"
read odsuser
echo "Enter your ODS password:"
read odspassword
echo "You created odsUser:${odsuser},odsPassword:${odspassword}"
chmod +x *
find -name 'ods.sql'|xargs perl -pi -e 's|xiaoming|'${odsuser}'|g'
find -name 'ods.sql'|xargs perl -pi -e 's|888888|'${odspassword}'|g'
export ORACLE_SID=ods
sqlplus sys/sys as sysdba <<EOF
@ods.sql
EOF
echo "Database initialization completed"

 脚本ods.sql

CREATE TABLESPACE ODSMES DATAFILE '/home/oracle/orcldata/odsmes.dbf' SIZE 50M AUTOEXTEND ON NEXT 50M MAXSIZE UNLIMITED;
CREATE TEMPORARY TABLESPACE ODSMES_TEMP TEMPFILE '/home/oracle/orcldata/odsmes_temp.dbf' SIZE 50M AUTOEXTEND ON NEXT 50M MAXSIZE 5G;
create user xiaoming identified by "888888" DEFAULT TABLESPACE ODSMES TEMPORARY TABLESPACE ODSMES_TEMP;
GRANT dba TO xiaoming;
GRANT CONNECT TO xiaoming;
GRANT RESOURCE TO xiaoming;
GRANT CREATE VIEW TO xiaoming;
GRANT CREATE TABLE TO xiaoming;
GRANT create sequence TO xiaoming;
GRANT UNLIMITED TABLESPACE TO xiaoming;
exit;

shell执行Tomcat初始化

#!/bin/sh
#Application server Start
# time:2017-02-16
echo "Hello, about to start the server and the initial interface!"
echo "Before you start the server, configure the database connection!"
echo "Enter your ODS user?"
read odsuser
echo "Enter your ODS password?"
read odspassword
echo "Enter ODS url?"
read odsurl
echo "Enter your ODS InstanceName?"
read oInstanceName
echo "Enter your ODS PortNumber?"
read oPortNumber
echo "Enter your WIP user?"
read wipuser
echo "Enter your WIP password?"
read wippassword
echo "Enter your WIP url?"
read wipurl
echo "Enter your WIP InstanceName?"
read wInstanceName
echo "Enter your WIP PortNumber?"
read wPortNumber
echo "You entered odsUser:${odsuser},odsPassword:${odspassword},odsUrl:${odsurl},odsInstanceName:${oInstanceName},odsPortNumber:${oPortNumber}"
echo "You entered wipUser:${wipuser},wipPassword:${wippassword},wipUrl:${wipurl},wipInstanceName:${wInstanceName},wipPortNumber:${wPortNumber}"
echo "If correct, please enter: y; Otherwise, the input: n"
read input
enter1="y"
enter2="n"
while [ ${input} == ${enter2} ]
do
echo "Enter your ODS user?"
read odsuser
echo "Enter your ODS password?"
read odspassword
echo "Enter ODS url?"
read odsurl
echo "Enter your ODS InstanceName?"
read oInstanceName
echo "Enter your ODS PortNumber?"
read oPortNumber
echo "Enter your WIP user?"
read wipuser
echo "Enter your WIP password?"
read wippassword
echo "Enter your WIP url?"
read wipurl
echo "Enter your WIP InstanceName?"
read wInstanceName
echo "Enter your WIP PortNumber?"
read wPortNumber
echo "You entered odsUser:${odsuser},odsPassword:${odspassword},odsUrl:${odsurl},odsInstanceName:${oInstanceName},odsPortNumber:${oPortNumber}"
echo "You entered wipUser:${wipuser},wipPassword:${wippassword},wipUrl:${wipurl},wipInstanceName:${wInstanceName},wipPortNumber:${wPortNumber}"
echo "If correct, please enter: y; Otherwise, the input: n"
read input
done
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|192.168.2.101|'${odsurl}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|1111|'${oPortNumber}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|orcl1|'${oInstanceName}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|odsUser|'${odsuser}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|7777777|'${odspassword}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|192.168.2.102|'${wipurl}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|2222|'${wPortNumber}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|orcl2|'${wInstanceName}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|wipUser|'${wipuser}'|g'
find -name 'jdbc@ifactory.properties'|xargs perl -pi -e 's|8888888|'${wippassword}'|g'
cd apache-tomcat-8.0/webapps/ifactory/WEB-INF/classes
rm -f jdbc@ifactory.properties
cd -
cp jdbc@ifactory.properties apache-tomcat-8.0/webapps/ifactory/WEB-INF/classes
#Start Tomcat Server
echo "The database connection configuration is complete. Do you want to start the server?"
echo " Determine, enter: y; Otherwise, enter: n"
read input2
if [ ${input2} == ${enter1} ]
then
cd apache-tomcat-8.0/bin
chmod +x *
sh startup.sh
cd ..
cd logs
tail -f catalina.out
else
exit
fi

 

posted @ 2017-03-07 17:05  26键的人生  阅读(204)  评论(0编辑  收藏  举报