-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.sh
More file actions
67 lines (58 loc) · 2.2 KB
/
common.sh
File metadata and controls
67 lines (58 loc) · 2.2 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
61
62
63
64
65
66
67
#!/bin/bash
# ============================================
# Common Helper Functions & Initial Setup
# ============================================
set -e
# ============================================
# sudo 세션 미리 활성화
# ============================================
echo "🔐 sudo 비밀번호 입력 (이후 자동 진행됨)..."
sudo -v
# sudo 타임아웃 방지
while true; do sudo -n true; sleep 60; kill -0 "$" || exit; done 2>/dev/null &
# ============================================
# Sleep 방지 (caffeinate)
# ============================================
caffeinate -disu &
CAFFEINATE_PID=$!
trap "kill $CAFFEINATE_PID 2>/dev/null" EXIT
# ============================================
# Helper Functions
# ============================================
add_to_zshrc() {
grep -qF "$1" ~/.zshrc 2>/dev/null || echo "$1" >> ~/.zshrc
}
brew_install() {
brew list "$1" &>/dev/null || brew install "$1"
}
brew_install_cask() {
brew list --cask "$1" &>/dev/null || brew install --cask "$1"
}
# ============================================
# Xcode Command Line Tools
# ============================================
echo "📦 Checking Xcode Command Line Tools..."
if ! xcode-select -p &>/dev/null; then
echo "Installing Xcode CLT..."
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
LABEL=$(softwareupdate -l 2>&1 | grep -E '^\s+\*.*Command Line|Label:.*Command Line' | head -n 1 | sed 's/^[^C]*//' | sed 's/.*Label: *//')
if [[ -n "$LABEL" ]]; then
softwareupdate -i "$LABEL" --verbose
else
echo "⚠️ Command Line Tools를 찾을 수 없음. 수동 설치 필요: xcode-select --install"
exit 1
fi
rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
fi
echo "✅ Xcode CLT ready"
# ============================================
# Homebrew
# ============================================
echo "🍺 Checking Homebrew..."
if ! command -v brew &>/dev/null; then
echo "Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval "$(/opt/homebrew/bin/brew shellenv)"
add_to_zshrc 'eval "$(/opt/homebrew/bin/brew shellenv)"'
echo "✅ Homebrew ready"