forked from MHSeals/mhseals_docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.mac.sh
More file actions
executable file
·60 lines (52 loc) · 1.91 KB
/
setup.mac.sh
File metadata and controls
executable file
·60 lines (52 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -euo pipefail
echo "Starting macOS installation..."
# Check for Homebrew
if ! command -v brew &> /dev/null; then
echo "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add brew to PATH for the session
eval "$(/opt/homebrew/bin/brew shellenv 2>/dev/null || /usr/local/bin/brew shellenv 2>/dev/null)"
else
echo "Homebrew already installed."
fi
echo "Installing packages..."
brew install --cask docker visual-studio-code
brew install jq hjson
# Start Docker Desktop if not running
if ! pgrep -x "Docker" > /dev/null; then
echo "Starting Docker Desktop..."
open -a Docker
# Wait until Docker is running
while ! docker system info > /dev/null 2>&1; do
echo "Waiting for Docker to start..."
sleep 5
done
fi
# Install VSCode extensions
if [[ -f .vscode/extensions.json ]]; then
echo "Installing VSCode extensions..."
extensions=$(jq -r '.recommendations[]' .vscode/extensions.json)
for extension in $extensions; do
if code --list-extensions | grep -q "$extension"; then
echo "Extension '$extension' is already installed, skipping..."
else
echo "Installing '$extension'..."
code --install-extension "$extension" || echo "Failed to install $extension"
fi
done
else
echo "No .vscode/extensions.json found. Skipping extensions."
fi
echo "Adding VSCode port forwarding configuration..."
VSC_DIR="$HOME/Library/Application Support/Code/User"
VSC_CONFIG="$VSC_DIR/settings.json"
mkdir -p "$VSC_DIR"
touch "$VSC_CONFIG"
hjson -j $VSC_CONFIG > $VSC_CONFIG.tmp \
&& mv $VSC_CONFIG.tmp $VSC_CONFIG \
&& jq '.["remote.autoForwardPorts"] = false' $VSC_CONFIG > $VSC_CONFIG.tmp \
&& mv $VSC_CONFIG.tmp $VSC_CONFIG
echo "Running prebuild script..."
bash .devcontainer/prebuild.sh
echo "macOS setup complete!"