#!/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=""
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中即可
阅读(1224) | 评论(0) | 转发(0) |