-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·144 lines (130 loc) · 3.98 KB
/
bootstrap.sh
File metadata and controls
executable file
·144 lines (130 loc) · 3.98 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
set -euo pipefail
export DEBIAN_FRONTEND=noninteractive
export PATH="$HOME/.local/bin:$PATH"
# Bootstrap script for trobz_local (tlc)
# Installs prerequisites: git, gh, uv, and trobz_local CLI
# Note: Tool installation (Odoo, PostgreSQL, etc.) is done separately via `tlc install-tools`
echo "=== Bootstrap trobz_local ==="
# Check not running as root
if [ "$(id -u)" -eq 0 ]; then
echo "Error: Do not run this script as root."
echo "Please run as a regular user with sudo access."
exit 1
fi
# Check if user can sudo
check_sudo() {
if ! sudo -v &>/dev/null; then
echo "Error: This script requires sudo privileges."
echo "Please run as a user with sudo access."
exit 1
fi
}
check_sudo
# Detect OS
detect_os() {
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if [ -f /etc/debian_version ]; then
echo "debian"
elif [ -f /etc/fedora-release ]; then
echo "fedora"
elif [ -f /etc/arch-release ]; then
echo "arch"
else
echo "linux"
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "macos"
else
echo "unknown"
fi
}
OS=$(detect_os)
echo "Detected OS: $OS"
# Install git
install_git() {
if command -v git &>/dev/null; then
echo "git is already installed"
return
fi
echo "Installing git..."
case $OS in
debian) sudo apt-get update && sudo apt-get install -y git ;;
fedora) sudo dnf install -y git ;;
arch) sudo pacman -S --noconfirm git ;;
macos) brew install git ;;
*) echo "Please install git manually"; exit 1 ;;
esac
}
# Install gh (GitHub CLI)
install_gh() {
if command -v gh &>/dev/null; then
echo "gh is already installed"
return
fi
echo "Installing gh (GitHub CLI)..."
case $OS in
debian)
sudo mkdir -p -m 755 /etc/apt/keyrings
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt-get update && sudo apt-get install -y gh
;;
fedora) sudo dnf install -y gh ;;
arch) sudo pacman -S --noconfirm github-cli ;;
macos) brew install gh ;;
*) echo "Please install gh manually from https://cli.github.com/"; exit 1 ;;
esac
}
# Install uv
install_uv() {
if command -v uv &>/dev/null; then
echo "uv is already installed"
return
fi
echo "Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
}
# Setup SSH known_hosts for GitHub
setup_github_ssh() {
echo "Setting up SSH known_hosts for GitHub..."
mkdir -p ~/.ssh
chmod 700 ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
echo "GitHub added to known_hosts"
}
# Install trobz_local
install_trobz_local() {
echo "Installing trobz_local..."
uv tool install git+https://github.com/trobz/local.py.git
echo "trobz_local installed (CLI: tlc)"
}
# Main execution
install_git
install_gh
install_uv
setup_github_ssh
install_trobz_local
echo ""
echo "=== Bootstrap complete ==="
echo ""
echo "Prerequisites installed successfully!"
echo " ✓ git"
echo " ✓ gh (GitHub CLI)"
echo " ✓ uv"
echo " ✓ trobz_local (tlc command available)"
echo ""
echo "Next steps:"
echo ""
echo " 1. Install development tools (Odoo, PostgreSQL, etc.):"
echo " tlc install-tools"
echo ""
echo " 2. Initialize your development environment:"
echo " tlc init # Create directory structure"
echo " tlc pull-repos # Clone repositories"
echo " tlc create-venvs # Create virtual environments"
echo ""
echo " 3. Get help:"
echo " tlc --help"
echo ""