Skip to content

[BUG]建议shell 脚本同时增加是否开启 set -x #3933

@wang-qa

Description

@wang-qa

联系方式

No response

1Panel 版本

v1.9.6

问题描述

使用定时计划更新git仓库,提示

fatal: detected dubious ownership in repository at '/home/kubuntu/git/projectName'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/kubuntu/git/projectName

执行 su kubuntu ,通过whoami``id -u验证,也无法切换到普通用户

重现步骤

  1. 拉取一个仓库
  2. 创建一个定时任务
su kubuntu
whoami
id -u
cd $HOME
for dir in git/*; do
  echo -e "\n更新项目--> $dir"
  if [ -d "$dir" ]; then
    cd "$dir"
    echo -e "进入目录: $(pwd)"
    echo -e "git pull 拉取项目" && git pull
    cd "$current_path"
    echo -e "返回目录: $current_path"
  fi
done
  1. 检查定时任务的报告

期待的正确结果

  1. git仓库正常更新,没有报错
  2. 可以切换到普通用户执行而非默认root用户

相关日志输出

root
0
/home/kubunu
当前路径为 /home/kubunu


更新项目--> git/bats-core
进入目录: /home/kubunu/git/bats-core
/home/kubunu/git/bats-core
git pull 拉取项目
fatal: detected dubious ownership in repository at '/home/kubunu/git/bats-core'
To add an exception for this directory, call:

	git config --global --add safe.directory /home/kubunu/git/bats-core
返回目录: /home/kubunu

附加信息

No response

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions