因拉取代码时,需要用另一个系统用户来拉取。而

git config --global credential.helper store

保存在root用户下(应该也可以通过修改权限等方式来解决,这里不讨论这个方案)。

#!/bin/bash

user_name="xxxx@163.com"
pwd="123456"

cd /var/www/html/kangaroo

/usr/bin/expect << FLAGEOF

set timeout 10

spawn sudo -u apache git pull origin
expect "*Username*"
send "${user_name}\r"
expect "*Password*"
send "${pwd}\r"
expect eof

FLAGEOF

需要安装expect:yum -y install expect

然后执行即可:sh git-pull.sh

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-21
  • 2021-04-12
  • 2022-01-19
  • 2022-12-23
  • 2021-08-22
  • 2021-05-28
猜你喜欢
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案