共计 657 个字符,预计需要花费 2 分钟才能阅读完成。
#!/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
if [ $1 != "666" ]
then
echo "通讯密码错误"
echo "End"
exit
fi
#git项目路径
gitPath="/www/wwwroot/hnfp.net"
#git 网址
gitHttp="xxx.com/hainanfp.git"
#git 账号
gitAccount=""
#git 密码
gitPassword=""
#git 分支
gitBranch="dev"
echo "Web站点路径:$gitPath"
#判断项目路径是否存在
if [ -d "$gitPath" ]; then
cd $gitPath
#判断是否存在git目录
if [ ! -d ".git" ]; then
echo "在该目录下克隆 git"
git clone -b $gitBranch http://$gitAccount:$gitPassword@$gitHttp gittemp
mv gittemp/.git .
rm -rf gittemp
fi
#拉取最新的项目文件
git reset --hard origin/$gitBranch
git pull
#设置目录权限
chown -R www:www $gitPath
echo "执行完成"
echo "End"
exit
else
echo "该项目路径不存在"
echo "End"
exit
fi
正文完