Skip to content

Commit

Permalink
cleanup final git error re safe.directory
Browse files Browse the repository at this point in the history
  • Loading branch information
wade ~ Pack3tL0ss committed Jul 7, 2023
1 parent 96cbee0 commit 9ca208c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions installer/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -630,12 +630,17 @@ missing_param(){

do_safe_dir(){
# Prevent fatal: detected dubious ownership in repository at '/etc/ConsolePi'
# common is not loaded yet, hence the need to define the local vars
local iam=${SUDO_USER:-$(who -m | awk '{ print $1 }')}
local tmp_log="/tmp/consolepi_install.log"
local final_log="/var/log/ConsolePi/install.log"
[ -f "$final_log" ] && local log_file=$final_log || local log_file=$tmp_log
if ! git config --global -l | grep -q "safe.directory=/etc/ConsolePi"; then
logit "Adding /etc/ConsolePi as git safe.directory globally"
echo "$(date +"%b %d %T") [$$][INFO][Verify git safe.directory] Adding /etc/ConsolePi as git safe.directory globally" | tee -a $log_file
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"
echo "$(date +"%b %d %T") [$$][INFO][Verify git safe.directory] Adding /etc/ConsolePi as git safe.directory globally for user $iam" | tee -a $log_file
sudo -u $iam git config --global --add safe.directory /etc/ConsolePi 2>>$log_file
fi
}
Expand Down
2 changes: 1 addition & 1 deletion src/consolepi-commands/consolepi-upgrade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

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")
[ ! "$branch" == "master" ] && echo -e "Script updating ${branch} branch.\n You are on a development branch."

local_dev=false
Expand Down

0 comments on commit 9ca208c

Please sign in to comment.