Skip to content

Commit

Permalink
change ifconfig line to use /dev/urandom instead for the unique_id (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tylerjet authored Feb 27, 2024
1 parent eaaaa2f commit 74deda4
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,10 @@ fi
if [[ "$commit_email" != "" ]]; then
git config user.email "$commit_email"
else
# Get the MAC address of the first network interface for unique id
if ! command -v ifconfig &>/dev/null; then
mac_address=$(ipconfig | grep -o -E '([0-9a-fA-F]:?){6}' | head -n 1)
else
mac_address=$(ifconfig | grep -o -E '([0-9a-fA-F]:?){6}' | head -n 1)
fi
# Use the MAC address to generate a unique identifier
unique_id=$(echo "$mac_address" | sha256sum | cut -c 1-8)
git config user.email "$(whoami)@$(hostname --long)-$unique_id"
sed -i "s/^commit_email=.*/commit_email=\"$(whoami)@$(hostname --long)-$unique_id\"/" "$parent_path"/.env
unique_id=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 7 | head -n 1)
git config user.email "$(whoami)@$(hostname --short)-$unique_id"
sed -i "s/^commit_email=.*/commit_email=\"$(whoami)@$(hostname --short)-$unique_id\"/" "$parent_path"/.env
fi

# Check if remote origin already exists and create if one does not
Expand Down

0 comments on commit 74deda4

Please sign in to comment.