码迷,mamicode.com
首页 > 其他好文 > 详细

shell脚本版本控制

时间:2014-08-26 19:51:38      阅读:325      评论:0      收藏:0      [点我收藏+]

标签:shell脚本版本控制

#!/bin/bash
#encode begin
#                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
#endcode end
#compile=true
#Author:birdman
#Create Date:2013-04-28
#Alter Date:2013-04-28
#Description:
#Usage:
function Birdman_Init()
{
        source /etc/profile >> /dev/null 2>&1
        ScriptName=`basename $0`
        export pid="${pid}-->$ScriptName"
        LogFile=`echo ${ScriptName}|awk -F. ‘{print $1}‘`.log
}
function Birdman_VersionCheck()

if `which curl >> /dev/null 2>&1`;then
:
else
yum install curl -y >> /dev/null 2>&1
fi
Md5_Server="http://192.168.1.88"
Version_File="BashVersion.txt"
File_Md5=`curl -s ${Md5_Server}/${Version_File}|awk ‘{if($2~"^‘"${ScriptName}"‘$")print}‘|awk ‘{print $1}‘`
Script_Md5=`md5sum ${ScriptName}|awk ‘{print $1}‘`
if [ -z ${File_Md5} ];then
echo "Md5 Server Version File is Error"
fi
if [ ${File_Md5} != ${Script_Md5} ];then
wget -N ${Md5_Server}/${ScriptName} >> /dev/null 2>&1
echo -e "\033[33;49;1m Please run again ${ScriptName}:\033[39;49;0m"
exit 1
fi


}
main()
{


        Birdman_Init
Birdman_VersionCheck
}
main


可将这个脚本写成一个函数,做为脚本自动更新使用。如果脚本更新后将文件加密后生成md5到BashVersion.txt中即可

本文出自 “我是一只小小鸟” 博客,请务必保留此出处http://2242558.blog.51cto.com/2232558/1545324

shell脚本版本控制

标签:shell脚本版本控制

原文地址:http://2242558.blog.51cto.com/2232558/1545324

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!