#!/bin/bash

Ip="10.10.10.81"
Port="60777"
User="upload"
Date=`date '+%Y%m%d'`
Time=`date '+%H%M%S'`
Path="/data/html/yunwei_asc/upload"
VersionPath="/data/html/yunwei_asc/upload_version"
config="/root/filelist.txt"
Md5="md5sum"
Cat="cat"
logfile="/root/upload.log"

if [ "$1" != "" ];then
    if [ "$2" != "" ];then
        if [ -d $2 ];then
            if [ -e $config ];then
                if [ "`grep " $1 " $config`" != "" ];then
                    if [ -e $2/$1 ];then
                        if [ -e $2/$1.md5 ];then
                            echo "
                            if [ ! -d $VersionPath/$1 ];then
                                mkdir -p $VersionPath/$1
                            fi
                            "|ssh -p$Port $User@$Ip
                            scp -r -P$Port $2/$1 $2/$1.md5 $User@$Ip:$VersionPath/$1
                        else
                            echo -e "\033[31m Upload the MD5 file does not exist. \033[0m"
                            exit 1
                        fi
                    else
                        echo -e "\033[31m Upload the war package file does not exist. \033[0m"
                        exit 1
                    fi
                    jg=$(echo "
                    if [ ! -e $VersionPath/$1 ];then
                        echo -e '\033[31m Failed to upload file.,\033[0m'
                    else
                        if [ \`$Md5 $VersionPath/$1/$1 | awk '{print \$1}'\` == \`$Cat $VersionPath/$1/$1.md5| tr [A-Z] [a-z]\` ];then
                            echo -e '\033[32m File upload success.,\033[0m'
                            echo -e '\033[32mCheck the correct MD5 file.,\033[0m'
                            /data/html/dbupload.sh $1 $Date$Time YES
                            if [ ! -d $Path/$1/$Date/$Timae ];then
                                mkdir -p $Path/$1/$Date/$Time
                            fi
                            rsync -a $VersionPath/$1/ $Path/$1/$Date/$Time/
                            /home/upload/cmd.sh
                            echo -e '\033[34mUpload Path:$Path/$1/$Date/$Time/ \033[0m'
                        else
                            echo -e '\033[31m MD5 file checksum is incorrect. Please re-package upload.,\033[0m'
                            /data/html/dbupload.sh $1 $Date$Time NO
                        fi
                    fi
                    "|ssh -p$Port $User@$Ip)
                    echo $jg|sed -n 's/,/\n/g;p'
                    if [ "`echo $jg|grep "Check the correct MD5 file"`" != "" ];then
                        echo "$Date-$Time Upload Path:$Path/$1/$Date/$Time/" >>$logfile
                    fi
                else
                    echo -e "\033[31m Upload files and projects do not match. Or contact the maintenance personnel. \033[0m"
                fi
            else
                echo -e "\033[31m The configuration file does not exist. \033[0m"
            fi
        else
            echo -e "\033[31m Enter a path that does not exist. \033[0m"
        fi
    else
        echo -e "\033[31m Usage: $0 [filename] \033[0m"
    fi
else
    echo -e "\033[31m Usage: $0 [filename] \033[0m"
fi
文档更新时间: 2019-07-09 10:58   作者:月影鹏鹏