zoukankan      html  css  js  c++  java
  • 自动化部署脚本之windows上执行批处理文件

    windows  .bat  批处理

    脚本路径如下:

    install-simo.bat文件内容:

    @ECHO OFF

    set scriptpath=%~dp0
    set logfile=%scriptpath%install-log.txt
    type license.txt | more
    :license-check
    echo Did you agree with this license(Y/N) :
    set/p "cho=>"
    if %cho%==Y goto start
    if %cho%==y goto start
    if %cho%==N call:notagree
    if %cho%==n call:notagree
    goto license-check

    :notagree
    echo "you do not agree with license install will exit now!"
    pause
    exit 1
    goto:eof

    :start
    echo "Start to install SIMO........" >> %logfile%
    echo %scriptpath%

    call:install-redis
    call:install-activemq
    call:init-database
    ping -n 120 127.0.0.1>nul
    call:run-simo




    echo  simo install finish..................
    pause

    exit 0

    :install-jdk
    mkdir %scriptpath%javajdk1.8
    call %scriptpath%install-java.bat %scriptpath%
    echo install-jdk finish
    goto:eof

    :install-redis
    start cmd /k %scriptpath%redis edis-server.exe %scriptpath%redis edis.windows.conf
    echo install-redis finish

    goto:eof

    :install-activemq
    start cmd /k %scriptpath%activemqinwin64activemq.bat
    echo install-activemq finish

    goto:eof

    :install-database
    echo install-database finish
    rem 判断windows/system32下是否有对应的mscrv120.dll文件

    goto:eof#运行完后 CMD 返回并等待下一条命令

    :init-database
    start cmd /k %scriptpath%init-postgres.bat %scriptpath%
    echo init-database finish

    goto:eof

    :run-simo
    start %scriptpath%simo-init.bat %scriptpath%
    echo run-simo finish

    goto:eof

    simo-init.bat脚本如下:

    @ECHO OFF

    rem unzip simo.zip
    call %17z7z.exe x %1simosimo.zip -o%1simo
    xcopy /Y %1simoapplication.properties %1simosimoscripts
    cd %1simosimoscripts
    rem enabledisable servicecenter
    start /b %1simosimoscripts unmodule.bat simo-servicecenter
    ping -n 10 127.0.0.1>nul
    rem enabledisable mc
    start /b %1simosimoscripts unmodule.bat simo-mc
    ping -n 10 127.0.0.1>nul
    rem enabledisable collector
    start /b %1simosimoscripts unmodule.bat simo-collector
    ping -n 10 127.0.0.1>nul
    rem enabledisable business
    start /b %1simosimoscripts unmodule.bat simo-business
    ping -n 10 127.0.0.1>nul
    rem enabledisable itsm
    start /b %1simosimoscripts unmodule.bat simo-itsm
    ping -n 10 127.0.0.1>nul
    rem enabledisable cmdb
    start /b %1simosimoscripts unmodule.bat simo-cmdb
    ping -n 10 127.0.0.1>nul
    rem enabledisable workflow
    start /b %1simosimoscripts unmodule.bat simo-workflow
    ping -n 10 127.0.0.1>nul
    rem enabledisable knowledgebase
    start /b %1simosimoscripts unmodule.bat simo-knowledgebase


    run-simo.bat脚本如下:

    @ECHO OFF
    echo **********************************************
    echo.
    echo     start to run simo
    echo.
    echo.
    echo **********************************************
    set scriptpath=%~dp0

    ping -n 10 127.0.0.1>nul
    call:start-redis
    ping -n 10 127.0.0.1>nul
    call:start-activemq
    ping -n 10 127.0.0.1>nul
    call:start-database
    ping -n 10 127.0.0.1>nul

    cd %scriptpath%simosimoscripts
    rem enabledisable servicecenter
    start /b %scriptpath%simosimoscripts unmodule.bat simo-servicecenter
    ping -n 10 127.0.0.1>nul
    rem enabledisable mc
    start /b %scriptpath%simosimoscripts unmodule.bat simo-mc
    ping -n 10 127.0.0.1>nul
    rem enabledisable collector
    start /b %scriptpath%simosimoscripts unmodule.bat simo-collector
    ping -n 10 127.0.0.1>nul
    rem enabledisable business
    start /b %scriptpath%simosimoscripts unmodule.bat simo-business
    ping -n 10 127.0.0.1>nul
    rem enabledisable itsm
    start /b %scriptpath%simosimoscripts unmodule.bat simo-itsm
    ping -n 10 127.0.0.1>nul
    rem enabledisable cmdb
    start /b %scriptpath%simosimoscripts unmodule.bat simo-cmdb
    ping -n 10 127.0.0.1>nul
    rem enabledisable workflow
    start /b %scriptpath%simosimoscripts unmodule.bat simo-workflow
    ping -n 10 127.0.0.1>nul
    rem enabledisable knowledgebase
    start /b %scriptpath%simosimoscripts unmodule.bat simo-knowledgebase

    cd %scriptpath%
    echo "DO NOT colse the window!"
    cmd /k echo.

    :start-redis
    start cmd /k %scriptpath%redis edis-server.exe %scriptpath%redis edis.windows.conf
    echo start-redis finish

    goto:eof

    :start-activemq
    start cmd /k %scriptpath%activemqinwin64activemq.bat
    echo start-activemq finish

    goto:eof

    :start-database
    start cmd /k %scriptpath%pgsqlinpg_ctl.exe -D "%scriptpath%data" -l logfile start
    echo start-database finish
    goto:eof

    init-postgres.bat  脚本如下:

    @ECHO OFF
    echo "Start to install postgres........"
    rem 检查系统依赖dll
    if not exist C:WindowsSystem32msvcr120.dll xcopy /Y %1msvcr120System32msvcr120.dll C:WindowsSystem32
    echo 检查系统依赖dll完成
    rem 修改数据文件夹权限
    echo Y|cacls %1data /c /p everyone:f
    ping -n 5 127.0.0.1>nul
    echo 修改数据文件夹权限
    call %1pgsqlininitdb.exe -D %1data -E UTF-8 --locale=chs -U uxsino --pwfile=%1postgresconfigpassword.txt
    ping -n 10 127.0.0.1>nul
    rem 修改配置文件
    xcopy /EY %1postgresconfig* %1data
    ping -n 5 127.0.0.1>nul
    echo config need comfirm
    call "pgsqlinpg_ctl" -D "%1data" -l logfile start
    ping -n 10 127.0.0.1>nul
    call %1pgsqlincreatedb.exe -U uxsino simo_dev
    ping -n 10 127.0.0.1>nul
    echo database init finish
    cmd /k echo.

    intall-java.bat  脚本如下:

    @ECHO OFF
    echo **********************************************
    echo.
    echo     start to install jdk
    echo.
    echo.
    echo **********************************************
    set scriptpath=%~dp0
    set logfile=%scriptpath%install-log.txt
    echo.
    echo installing.......jdk, do not close this windows
    echo.
    echo please wait about 3/4 mins until install finish
    echo.
    echo start to install jdk > %logfile%
    start /WAIT %scriptpath%javajdk-8u152-windows-x64.exe /qn INSTALLDIR=%scriptpath%javajdk1.8
    echo install finish start to config java
    echo install finish start to config java >> %logfile%
    echo.
    set JAVA_HOME=%scriptpath%javajdk1.8
    setx Path "%Path%;%JAVA_HOME%in" /M
    ping -n 30 127.0.0.1>nul
    echo install finish and config finish.
    echo you can close this window start to install simo
    echo java install finish >> %logfile%
    cmd /k echo.

    run-simo.bat  脚本如下:

    @ECHO OFF
    echo **********************************************
    echo.
    echo     start to run simo
    echo.
    echo.
    echo **********************************************
    set scriptpath=%~dp0

    ping -n 10 127.0.0.1>nul
    call:start-redis
    ping -n 10 127.0.0.1>nul
    call:start-activemq
    ping -n 10 127.0.0.1>nul
    call:start-database
    ping -n 10 127.0.0.1>nul

    cd %scriptpath%simosimoscripts
    rem enabledisable servicecenter
    start /b %scriptpath%simosimoscripts unmodule.bat simo-servicecenter
    ping -n 10 127.0.0.1>nul
    rem enabledisable mc
    start /b %scriptpath%simosimoscripts unmodule.bat simo-mc
    ping -n 10 127.0.0.1>nul
    rem enabledisable collector
    start /b %scriptpath%simosimoscripts unmodule.bat simo-collector
    ping -n 10 127.0.0.1>nul
    rem enabledisable business
    start /b %scriptpath%simosimoscripts unmodule.bat simo-business
    ping -n 10 127.0.0.1>nul
    rem enabledisable itsm
    start /b %scriptpath%simosimoscripts unmodule.bat simo-itsm
    ping -n 10 127.0.0.1>nul
    rem enabledisable cmdb
    start /b %scriptpath%simosimoscripts unmodule.bat simo-cmdb
    ping -n 10 127.0.0.1>nul
    rem enabledisable workflow
    start /b %scriptpath%simosimoscripts unmodule.bat simo-workflow
    ping -n 10 127.0.0.1>nul
    rem enabledisable knowledgebase
    start /b %scriptpath%simosimoscripts unmodule.bat simo-knowledgebase

    cd %scriptpath%
    echo "DO NOT colse the window!"
    cmd /k echo.

    :start-redis
    start cmd /k %scriptpath%redis edis-server.exe %scriptpath%redis edis.windows.conf
    echo start-redis finish

    goto:eof

    :start-activemq
    start cmd /k %scriptpath%activemqinwin64activemq.bat
    echo start-activemq finish

    goto:eof

    :start-database
    start cmd /k %scriptpath%pgsqlinpg_ctl.exe -D "%scriptpath%data" -l logfile start
    echo start-database finish
    goto:eof

  • 相关阅读:
    CF666E Forensic Examination SAM+倍增,线段树和并
    CQOI2018 九连环 打表找规律 fft快速傅里叶变换
    CF993E Nikita and Order Statistics 多项式卷积 快速傅里叶变换
    NOIP2016 天天爱跑步 线段树合并
    BZOJ 3123 SDOI2013 森林 启发式合并+主席树
    [USACO1.4]等差数列 Arithmetic Progressions
    [LUOGU] 1108 低价购买
    [HDU5807] Keep In Touch
    [一道在别人课件上看到的没有出处的题]
    [LUOGU] 4933 大师
  • 原文地址:https://www.cnblogs.com/zyy98877/p/9254376.html
Copyright © 2011-2022 走看看