feat: Add test to check if software is already installed

This commit is contained in:
Louis Gallet 2023-06-13 18:30:44 +02:00
parent adf5746178
commit 1c0c6909f1
Signed by: lgallet
SSH Key Fingerprint: SHA256:qnW7pk4EoMRR0UftZLZQKSMUImbEFsiruLC7jbCHJAY

42
macos-setup.sh Normal file → Executable file
View File

@ -1,10 +1,26 @@
#! /usr/bin/env bash #! /usr/bin/env bash
# Setup script for setting up a new macos machine # Setup script for setting up a new macos machine
# Check if system is macos
if [ "$(uname)" != "Darwin" ]; then
echo "Sorry bro, this script is only for macos"
exit 1
fi
echo "Starting setup" echo "Starting setup"
# Install xcode CLI # Check if xcode CLI is installed
xcode-select --install if ! xcode-select --print-path &> /dev/null; then
echo "Installing xcode CLI"
xcode-select --install &> /dev/null
# Wait until xcode CLI is installed
until xcode-select --print-path &> /dev/null; do
sleep 5
done
echo "Xcode CLI installed"
else
echo "Xcode CLI already installed"
fi
# Install homebrew # Install homebrew
# Check if homebrew is installed # Check if homebrew is installed
@ -24,8 +40,15 @@ PACKAGES=(
zsh zsh
) )
echo "Installing packages..." # Check if packages are installed
brew install ${PACKAGES[@]} for package in ${PACKAGES[@]}; do
if brew list $package > /dev/null 2>&1; then
echo "$package already installed"
else
echo "Installing $package"
brew install $package
fi
done
# Link readline # Link readline
brew link --force readline brew link --force readline
@ -51,7 +74,14 @@ CASKS=(
nordvpn nordvpn
) )
echo "Installing cask apps..." # Check if cask apps are installed
brew install --cask ${CASKS[@]} for cask in ${CASKS[@]}; do
if brew list --cask $cask > /dev/null 2>&1; then
echo "$cask already installed"
else
echo "Installing $cask"
brew install --cask $cask
fi
done
echo "Macbook setup complete" echo "Macbook setup complete"