Skip to content

Commit

Permalink
move safe.directory
Browse files Browse the repository at this point in the history
prevents some initial errors, no impact, but prevents those errors.
  • Loading branch information
wade ~ Pack3tL0ss committed Jul 7, 2023
1 parent 206f5ee commit 96cbee0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
9 changes: 0 additions & 9 deletions installer/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -509,15 +509,6 @@ get_pi_info_pretty() {
# Gather Some info about the Pi useful in triage of issues
get_pi_info() {
process="Collect Pi Info"
# Prevent fatal: detected dubious ownership in repository at '/etc/ConsolePi'
if ! git config --global -l | grep -q "safe.directory=/etc/ConsolePi"; then
logit "Adding /etc/ConsolePi as git safe.directory globally"
git config --global --add safe.directory /etc/ConsolePi 2>>$log_file
fi
if ! sudo -u $iam git config --global -l | grep -q "safe.directory=/etc/ConsolePi"; then
logit "Adding /etc/ConsolePi as git safe.directory globally for user $iam"
sudo -u $iam git config --global --add safe.directory /etc/ConsolePi 2>>$log_file
fi
[ ! -z $branch ] && [ $branch != "master" ] && logit "Running alternate branch: ${_green}$branch${_norm}"
git_rem=$(pushd /etc/ConsolePi >/dev/null 2>&1 && git remote -v | head -1 | cut -d '(' -f-1 ; popd >/dev/null 2>&1)
[[ ! -z $git_rem ]] && [[ $(echo $git_rem | awk '{print $2}') != $consolepi_source ]] && logit "Using alternative repo: ${_green}$git_rem${_norm}"
Expand Down
15 changes: 14 additions & 1 deletion installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -628,8 +628,20 @@ missing_param(){
exit 1
}

do_safe_dir(){
# Prevent fatal: detected dubious ownership in repository at '/etc/ConsolePi'
if ! git config --global -l | grep -q "safe.directory=/etc/ConsolePi"; then
logit "Adding /etc/ConsolePi as git safe.directory globally"
git config --global --add safe.directory /etc/ConsolePi 2>>$log_file
fi
if ! sudo -u $iam git config --global -l | grep -q "safe.directory=/etc/ConsolePi"; then
logit "Adding /etc/ConsolePi as git safe.directory globally for user $iam"
sudo -u $iam git config --global --add safe.directory /etc/ConsolePi 2>>$log_file
fi
}

process_args() {
branch=$(pushd /etc/ConsolePi >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD && popd >/dev/null || echo "master")
branch=$(pushd /etc/ConsolePi >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD 2>/dev/null && popd >/dev/null || echo "master")
silent=false
local_dev=false
dopip=true
Expand Down Expand Up @@ -747,6 +759,7 @@ main() {
if [ "${script_iam}" = "root" ]; then
set +H # Turn off ! history expansion
cmd_line="$@"
do_safe_dir # Ensures /etc/ConsolePi is git safe.directory
process_args "$@"
get_common # get and import common functions script
[ -n "$cmd_line" ] && logit -L -t "ConsolePi Installer" "Called with the following args: $cmd_line"
Expand Down

0 comments on commit 96cbee0

Please sign in to comment.