zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    filter
    列表生成式
    迭代
    切片:练习
    Python FAQ
    活在深圳
    “30岁年薪20万算不算很失败?”人民日报这样回答
    ASP.NET Core 运行原理解剖[1]:Hosting
    Kotlin 初窥门径[2]:流程控制
    Kotlin 初窥门径[1]:基础概念
  • 原文地址:https://www.cnblogs.com/26JRS/p/6515695.html
Copyright © 2011-2022 走看看