首页 > 代码库 > 部署应用的小脚本
部署应用的小脚本
1 #!/bin/bash 2 # Author : standby 3 # Date : 2017-05-12 4 # Description : Deploy something. 5 6 . /etc/init.d/functions 7 8 # Usage... 9 function Usage()10 {11 echo -e "Usage: /bin/sh $0 arg1 arg2\n \12 - arg1 like this : data1 | data2 ...\n 13 - arg2 like this : tag"14 exit 215 }16 # The core deploy code block here...17 function deploy()18 {19 # Prepare something...20 # ...21 # Deploy some crontab and script...22 # ...23 }24 # Verificate the arguments.25 function verificate()26 {27 result=028 available=`df -m |grep $1$ |awk ‘{print $4}‘`29 [[ $available -lt 1000000 ]] && result=130 [[ $2 == x* ]] || result=231 #[ $2 == x* ] || result=232 echo $result33 }34 # Start something processes.35 function start_work()36 {37 if [ $1 -eq 1 ]38 then39 echo -e "\n"40 action "Deploy something successful." /bin/true41 echo -e "\nBegin to start something process...\n"42 # start something cmd here ...43 if [ $? -eq 0 ]44 then45 action "Start something successful." /bin/true46 else47 action "Start something failed." /bin/false48 fi49 elif [ $1 -eq 2 ]50 then51 action "Deploy something failed." /bin/false52 exit -153 else54 action "You are not expected to undestand this code block ->_->" /bin/true55 fi56 }57 # Main code body.58 function main()59 {60 [[ $1 == dat* ]] || Usage61 result=`verificate $1 $2`62 #echo $result63 if [ $result -eq 0 ]64 then65 #echo "Hello world!"66 deploy $1 $267 [ $? -eq 0 ] && start_work 1 || start_work 268 elif [ $result -eq 1 ]69 then70 echo "$1 have less than 1T space left"71 exit 172 elif [ $result -eq 2 ]73 then74 echo "The arg2 must start with ‘x‘, not $2"75 exit 276 fi77 }78 # Start here...79 if [ $# -ne 2 ]80 then81 Usage82 else83 main $1 $284 fi
部署应用的小脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。