Created
November 14, 2024 13:05
-
-
Save timgentry/c6f7495fd60e5750100e618336a932e7 to your computer and use it in GitHub Desktop.
Fix macOS insecurities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# This zshell script check that homebrew and Xcode Command Line Tools are installed. | |
# If they are, and they still contain the insecure version of Python 3.9 that Apple | |
# bundles into the CL Tools, this script installs an up-to-date version of Python 3.9 | |
# using homebrew, repoints the symlink to the homebrew installation and removes the | |
# insecure version. | |
set -e | |
# Check if Homebrew is installed | |
if ! command -v brew &> /dev/null; then | |
echo "Homebrew is not installed." | |
# echo "Run this command: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" | |
exit 1 | |
else | |
# Update in brew now | |
brew update | |
brew upgrade | |
brew install [email protected] | |
brew cleanup | |
fi | |
# Check if xcode command line tools are installed | |
if ! xcode-select -p &> /dev/null; then | |
echo "Xcode Command Line Tools are not installed." | |
exit 1 | |
fi | |
# Define Command Line Tools Python framework path | |
CLT_PYTHON_FRAMEWORK_PATH="/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions" | |
if [ ! -d "$CLT_PYTHON_FRAMEWORK_PATH/3.9" ]; then | |
echo "Command Line Tools Python 3.9 already removed" | |
exit 1 | |
fi | |
echo "Xcode Command Line Tools are installed. Proceeding with fix..." | |
# Get the brew Python path | |
BREW_PYTHON_FRAMEWORK_PATH=$(brew --prefix [email protected])/Frameworks/Python.framework/Versions/3.9 | |
if [ ! -d "$BREW_PYTHON_FRAMEWORK_PATH" ]; then | |
echo "Could not find brew Python installation" | |
exit 1 | |
fi | |
cd "$CLT_PYTHON_FRAMEWORK_PATH" | |
sudo rm -f Current | |
sudo ln -s "$BREW_PYTHON_FRAMEWORK_PATH" Current | |
sudo rm -rf "3.9" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/bin/zsh -c "$(curl -fsSL https://gist.githubusercontent.com/timgentry/c6f7495fd60e5750100e618336a932e7/raw/cc3a8454d42e89e678807a94dfeffffa530450df/fix_command_line_tools_python.sh)"