zoukankan      html  css  js  c++  java
  • 宝塔webHook自动同步代码的使用

    #!/bin/bash
    echo ""
    #输出当前时间
    date --date='0 days ago' "+%Y-%m-%d %H:%M:%S"
    echo "Start"
    #判断宝塔WebHook参数是否存在
    if [ ! -n "$1" ]; then
                    echo "param参数错误"
            echo "End"
            exit
    fi
    #git项目路径
    gitPath="/www/wwwroot/$1"
    #git 网址
    gitHttp="https://git.xxxxx.net/abc/$1.git"

    echo "Web站点路径:$gitPath"

    #判断项目路径是否存在
    if [ -d "$gitPath" ]; then
            cd $gitPath
            #判断是否存在git目录
            if [ ! -d ".git" ]; then
                    echo "在该目录下克隆 git"
                    sudo git clone $gitHttp gittemp
                    sudo mv gittemp/.git .
                    sudo rm -rf gittemp
            fi
            echo "拉取最新的项目文件"
            sudo git reset --hard origin/master
            sudo git pull        
            echo "设置目录权限"
            sudo chown -R www:www $gitPath
            echo "End"
            exit
    else
            echo "该项目路径不存在"
                    echo "新建项目目录"
            mkdir $gitPath
            cd $gitPath
            #判断是否存在git目录
            if [ ! -d ".git" ]; then
                    echo "在该目录下克隆 git"
                    sudo git clone $gitHttp gittemp
                    sudo mv gittemp/.git .
                    sudo rm -rf gittemp
            fi
            echo "拉取最新的项目文件"
            sudo git reset --hard origin/master
            sudo git pull
            echo "设置目录权限"
            sudo chown -R www:www $gitPath
            echo "End"
            exit
    fi

  • 相关阅读:
    app 后端技术
    别为大公司拼命
    ifconfig 工具
    route工具
    ping 和 traceroute 命令
    IP路由选择
    TCP的那些事儿(下)
    TCP的那些事儿(上)
    Openresty 与 Tengine
    Excel.Application SaveAs 把excel转换为html
  • 原文地址:https://www.cnblogs.com/dayin1/p/12263462.html
Copyright © 2011-2022 走看看