linux发布环境初始化脚本
作者:互联网
#参数配置 homeDir=$(pwd) tomcatDir=$homeDir/tomcat logDir=$homeDir/tomcat/logs backUpDir=$homeDir/backup warBackDir=$homeDir/backup/warBack pidDir=$homeDir/pid scriptDir=$homeDir/sh/script configDir=$homeDir/sh/config serverName=test #创建目录 tomcat backup pid logs sh/script sh/config mkdir -p $tomcatDir $logDir $backUpDir $warBackDir $pidDir mkdir -p $scriptDir $configDir #创建用户组,用户 groupadd tomcat useradd -g tomcat -d $tomcatDir tomcat #创建启动脚本 if [ -f $scriptDir/start.sh ]; then rm -rf $scriptDir/start.sh else echo 创建文件$scriptDir/start.sh touch $scriptDir/start.sh fi cat >$scriptDir/start.sh<< ! echo 启动服务$serverName sh $tomcatDir/tomcat-$serverName/bin/startup.sh ! #创建停止脚本 if [ -f $scriptDir/shutdown.sh ]; then rm -rf $scriptDir/shutdown.sh else echo 创建文件$scriptDir/shutdown.sh touch $scriptDir/shutdown.sh fi cat >$scriptDir/shutdown.sh<< ! echo 停止服务$serverName kill -9 \`cat $pidDir/$serverName.pid\` ! #创建发布脚本 if [ -f $scriptDir/publish.sh ]; then rm -rf $scriptDir/publish.sh else echo 创建文件$scriptDir/publish.sh touch $scriptDir/publish.sh fi # cat >$scriptDir/publish.sh<< ! #!/bin/sh backDir=$backUpDir configDir=$configDir tomcatDir=$tomcatDir warBackDir=$warBackDir scriptDir=$scriptDir currentTime=\`date +%Y%m%d%H%M%S\` #停止tomcat sh \$scriptDir/shutdown.sh $serverName #清除webapps rm -rf \$tomcatDir/webapps/* #清除日志 rm -rf \$tomcatDir/logs/* #解压war包 unzip \$backDir/Bonade-Contract-Service.war -d \$tomcatDir/webapps/Bonade-Contract-Service unzip \$backDir/Bonade-Contract-Web.war -d \$tomcatDir/webapps/Bonade-Contract-Web #创建目录 mkdir \$tomcatDir/webapps/Bonade-Contract-Web/WEB-INF/classes/config #复制配置 \cp -rf \$configDir/system.properties \$tomcatDir/webapps/Bonade-Contract-Service/WEB-INF/classes/config \cp -rf \$configDir/jdbc.properties \$tomcatDir/webapps/Bonade-Contract-Service/WEB-INF/classes/config \cp -rf \$configDir/system.properties \$tomcatDir/webapps/Bonade-Contract-Web/WEB-INF/classes/config \cp -rf \$configDir/contract-web.xml \$tomcatDir/webapps/Bonade-Contract-Web/WEB-INF/web.xml #备份包 mv \$backDir/Bonade-Contract-Service.war \$warBackDir/"Bonade-Contract-Service_\$currentTime".war mv \$backDir/Bonade-Contract-Web.war \$warBackDir/"Bonade-Contract-Web_\$currentTime".war #启动服务 \$scriptDir/start.sh $serverName ! #文件授权 chown -R tomcat:tomcat $tomcatDir chown -R tomcat:tomcat $backUpDir chown -R tomcat:tomcat $pidDir chown -R tomcat:tomcat $homeDir/sh chown -R tomcat:tomcat $logDir echo script execute complete
然后
设置密码
passwd tomcat
设置tomcat jdk pid 配置文件
标签:脚本,初始化,homeDir,tomcat,pid,scriptDir,start,sh,linux 来源: https://www.cnblogs.com/yun965861480/p/10735203.html