From 96cbee0e0bf081a312338f33b60e0c165228bed8 Mon Sep 17 00:00:00 2001 From: wade ~ Pack3tL0ss Date: Fri, 7 Jul 2023 13:38:02 -0500 Subject: [PATCH] move safe.directory prevents some initial errors, no impact, but prevents those errors. --- installer/common.sh | 9 --------- installer/install.sh | 15 ++++++++++++++- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/installer/common.sh b/installer/common.sh index 48fbc650..5a0f3295 100755 --- a/installer/common.sh +++ b/installer/common.sh @@ -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}" diff --git a/installer/install.sh b/installer/install.sh index bb91b1c3..7fb7564a 100755 --- a/installer/install.sh +++ b/installer/install.sh @@ -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 @@ -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"