• 宝塔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

  • 相关阅读:
    记录JavaScript的util.js类库
    Shiro登录中遇到了问题
    【转载】JavaScript导出Excel
    react-router
    react 表单
    html5定位getLocation()
    html5存储方式localstorage和sessionStorage
    position导致Safari工具栏不自动隐藏
    input type="datetime-local" 时placeholder不显示
    vuex(1.0版本写法)
  • 原文地址:https://www.cnblogs.com/dayin1/p/12263462.html
Copyright © 2020-2023  润新知