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

  • 相关阅读:
    埋点功能测试
    jmeter提取A接口返回值传入B接口
    css(2)---倒角阴影 框模型
    css(1)
    node 练习
    学习过程中遇到的问题及解决方法
    node.js(5)——mysql、连接池
    node.js(4)——中间件
    node.js(3)——express
    node.js(2)
  • 原文地址:https://www.cnblogs.com/dayin1/p/12263462.html
Copyright © 2011-2022 走看看