-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun.sh
More file actions
executable file
·108 lines (91 loc) · 2.94 KB
/
run.sh
File metadata and controls
executable file
·108 lines (91 loc) · 2.94 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
set -e
# Colors for output
RED='\033[0;31m'
CYAN='\033[0;36m'
ORANGE='\033[0;33m'
GREEN='\033[0;32m'
NC='\033[0m'
print_notice() {
echo -e "${CYAN}${@}${NC}"
}
detect_os() {
if [[ "$(uname)" == "Darwin"* ]]; then
echo "macos"
elif [[ "$(uname)" == "Linux"* ]]; then
echo "linux"
else
echo "unknown"
fi
}
if [ -n "$1" ]; then
OS="$1"
print_notice "Using provided OS: ${OS}"
else
OS=$(detect_os)
print_notice "Detected OS: ${OS}"
fi
# Install Python and uv
install_python() {
if [[ "$OS" == "macos" ]]; then
if ! command -v brew &> /dev/null; then
print_notice "Homebrew not found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
if ! command -v curl &> /dev/null; then
print_notice "Installing curl using Homebrew"
brew install curl
fi
elif [[ "$OS" == "linux" ]]; then
if ! command -v curl &> /dev/null; then
# Detect package manager
if command -v apt-get &> /dev/null; then
print_notice "Using apt package manager"
sudo apt-get update
sudo apt-get install -y curl
elif command -v dnf &> /dev/null; then
print_notice "Using dnf package manager"
sudo dnf install -y curl
elif command -v pacman &> /dev/null; then
print_notice "Using pacman package manager"
sudo pacman -Syu --noconfirm curl
else
echo -e "${RED}Unsupported Linux distribution. Please install curl manually.${NC}"
exit 1
fi
fi
else
echo -e "${RED}Unsupported OS. This script supports macOS and Linux.${NC}"
echo -e "${RED}For Windows, please run bootstrap_windows.ps1 instead.${NC}"
exit 1
fi
if ! command -v uv &> /dev/null; then
print_notice "Installing uv"
curl -LsSf https://astral.sh/uv/install.sh | sh
fi
uv venv --python 3.12
uv pip install ansible
}
run_playbook() {
source .venv/bin/activate
# ansible-vault decrypt files/ssh/id_ed25519_ansible_gempir.vault --output files/ssh/id_ed25519_ansible_gempir
# Run the main playbook
print_notice "Running main playbook"
ansible-playbook --limit "$OS" playbook.yml
# Run macos_defaults playbook only if RUN_MACOS_DEFAULTS is set
if [ -n "$RUN_MACOS_DEFAULTS" ]; then
print_notice "Running macos_defaults playbook"
ansible-playbook --limit "$OS" macos_defaults.yml
else
print_notice "Skipping macos_defaults (set RUN_MACOS_DEFAULTS=1 to enable)"
fi
}
if [ ! -f ".venv/bin/ansible" ]; then
install_python
fi
if [[ "$OS" == "install" ]]; then
source .venv/bin/activate
ansible-galaxy collection install -r requirements.yml -p ./collections
exit 0
fi
run_playbook