Bash shell-Generic Project Upgrade script

Source: Internet
Author: User

#!/bin/bash################################################################################# Filename:upgrade_ Project.SH# Summary: Project Upgrade Script # LICENSE:GPL # Version:1.0# Author:jet bi# Email:1207501666@qq. com# Date: ./ ,/ ,# Note: #1requires project support for SVN upgrade mode and is equipped with svn#2need restart_tomcat.sh to exist #3. Use description # Upgrade:./upgrade_project.SH-P Project Path-T Tomcat path # rollback:./upgrade_project.SH-r version number-p Project path-T Tomcat path ###################################################################### ######### #project_path=""# project Path project_version=""# project Version Tomcat_path=""# tomcat Path Restart_script="/local/script/restart_tomcat.sh"# Restart script path Log_file="/local/script/logs/upgrade.log"# log file path # Get parameters and assign values to variables whileGetopts'p:r:t:'OPT; Do     Case${OPT}inchp) Project_path=${optarg};; R) Project_version=${optarg};; T) Tomcat_path=${optarg};; Esac Done# Check if the project path and Tomcat path are setEcho${project_path:?"- P option:missing Project Path"} >/dev/NULLEcho${tomcat_path:?"- t option:missing Tomcat Path"} >/dev/NULL# See if there is a Tomcat restart scriptif[!-e ${restart_script}]; Then    Echo "Can ' t find/local/script/restart_tomcat.sh"Exit1fi# See if you have permission to execute scriptsif[!-x ${restart_script}]; Then    chmodu+x ${restart_script}fi# Determine if the project directory is legalif[[!-D ${project_path}]; Then    Echo "${project_path} is not a directory!"Exit2fi# See if there is a log directory, there is no createif[[!-E $ (dirname${log_file})]; Then    Echo "No Directory of Upgrade.log: $ (dirname ${log_file})"    mkdir$(dirname${log_file}) # Exit3fi# start the upgradeEcho---------------------------------------------------------------------------->>${log_file}Echo "upgrade_title:$ (Date +%y-%m-%d" "%h:%m:%s) svn up ${project_path}">>${log_file}Echo-E"upgrade_content:\c">>${log_file}if[${project_version}]; ThenSVN up-R ${optarg} ${project_path} >> ${log_file}2>&1&&${restart_script} ${tomcat_path}Elsesvn up ${project_path}>> ${log_file}2>&1&&${restart_script} ${tomcat_path}fiEcho---------------------------------------------------------------------------->>${log_file}exit0

Bash shell-Generic Project Upgrade script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.