support pi
This commit is contained in:
144
install.sh
144
install.sh
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Mac Setup Script - Install Git, Node.js, and Python
|
# Cross-Platform Setup Script - Install Git, Node.js, and Python
|
||||||
# This script will install essential development tools on macOS
|
# This script will install essential development tools on macOS and Raspberry Pi (Linux ARM)
|
||||||
|
|
||||||
set -e # Exit on any error
|
set -e # Exit on any error
|
||||||
|
|
||||||
@@ -34,20 +34,45 @@ command_exists() {
|
|||||||
command -v "$1" >/dev/null 2>&1
|
command -v "$1" >/dev/null 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to check if running on macOS
|
# Function to detect operating system
|
||||||
check_macos() {
|
detect_os() {
|
||||||
if [[ "$OSTYPE" != "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
print_error "This script is designed for macOS only"
|
OS="macos"
|
||||||
|
print_status "Detected: macOS"
|
||||||
|
elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
|
# Check if it's Raspberry Pi
|
||||||
|
if [[ $(uname -m) == "armv"* ]] || [[ $(uname -m) == "aarch64" ]] || grep -q "Raspberry Pi" /proc/cpuinfo 2>/dev/null; then
|
||||||
|
OS="raspi"
|
||||||
|
print_status "Detected: Raspberry Pi (Linux ARM)"
|
||||||
|
else
|
||||||
|
OS="linux"
|
||||||
|
print_status "Detected: Linux (x86/x64)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
print_error "Unsupported operating system: $OSTYPE"
|
||||||
|
print_status "This script supports macOS and Raspberry Pi only"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install Homebrew if not present
|
# Function to update package manager
|
||||||
install_homebrew() {
|
update_packages() {
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
if command_exists brew; then
|
if command_exists brew; then
|
||||||
print_success "Homebrew is already installed"
|
|
||||||
print_status "Updating Homebrew..."
|
print_status "Updating Homebrew..."
|
||||||
brew update
|
brew update
|
||||||
|
fi
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
print_status "Updating package lists..."
|
||||||
|
sudo apt update
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install package manager (Homebrew for Mac)
|
||||||
|
install_package_manager() {
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
|
if command_exists brew; then
|
||||||
|
print_success "Homebrew is already installed"
|
||||||
else
|
else
|
||||||
print_status "Installing Homebrew..."
|
print_status "Installing Homebrew..."
|
||||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||||
@@ -58,6 +83,8 @@ install_homebrew() {
|
|||||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
# For Raspberry Pi, apt is already available
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to install Git
|
# Function to install Git
|
||||||
@@ -66,7 +93,11 @@ install_git() {
|
|||||||
print_success "Git is already installed: $(git --version)"
|
print_success "Git is already installed: $(git --version)"
|
||||||
else
|
else
|
||||||
print_status "Installing Git..."
|
print_status "Installing Git..."
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
brew install git
|
brew install git
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
sudo apt install -y git
|
||||||
|
fi
|
||||||
print_success "Git installed successfully: $(git --version)"
|
print_success "Git installed successfully: $(git --version)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -75,11 +106,16 @@ install_git() {
|
|||||||
install_nodejs() {
|
install_nodejs() {
|
||||||
if command_exists node; then
|
if command_exists node; then
|
||||||
print_success "Node.js is already installed: $(node --version)"
|
print_success "Node.js is already installed: $(node --version)"
|
||||||
print_status "Node.js version: $(node --version)"
|
|
||||||
print_status "npm version: $(npm --version)"
|
print_status "npm version: $(npm --version)"
|
||||||
else
|
else
|
||||||
print_status "Installing Node.js..."
|
print_status "Installing Node.js..."
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
brew install node
|
brew install node
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
# Install Node.js from NodeSource repository for better ARM support
|
||||||
|
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
|
||||||
|
sudo apt install -y nodejs
|
||||||
|
fi
|
||||||
print_success "Node.js installed successfully: $(node --version)"
|
print_success "Node.js installed successfully: $(node --version)"
|
||||||
print_status "npm version: $(npm --version)"
|
print_status "npm version: $(npm --version)"
|
||||||
fi
|
fi
|
||||||
@@ -91,7 +127,11 @@ install_python() {
|
|||||||
print_success "Python3 is already installed: $(python3 --version)"
|
print_success "Python3 is already installed: $(python3 --version)"
|
||||||
else
|
else
|
||||||
print_status "Installing Python..."
|
print_status "Installing Python..."
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
brew install python
|
brew install python
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
sudo apt install -y python3 python3-pip python3-venv
|
||||||
|
fi
|
||||||
print_success "Python installed successfully: $(python3 --version)"
|
print_success "Python installed successfully: $(python3 --version)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -100,7 +140,28 @@ install_python() {
|
|||||||
print_success "pip3 is available: $(pip3 --version)"
|
print_success "pip3 is available: $(pip3 --version)"
|
||||||
else
|
else
|
||||||
print_warning "pip3 not found, installing..."
|
print_warning "pip3 not found, installing..."
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
python3 -m ensurepip --upgrade
|
python3 -m ensurepip --upgrade
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
sudo apt install -y python3-pip
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to install build essentials (mainly for Raspberry Pi)
|
||||||
|
install_build_tools() {
|
||||||
|
if [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
print_status "Installing build essentials..."
|
||||||
|
sudo apt install -y build-essential curl wget
|
||||||
|
print_success "Build tools installed"
|
||||||
|
elif [[ "$OS" == "macos" ]]; then
|
||||||
|
# Xcode command line tools are usually installed with Homebrew
|
||||||
|
if ! command_exists gcc; then
|
||||||
|
print_status "Installing Xcode command line tools..."
|
||||||
|
xcode-select --install
|
||||||
|
else
|
||||||
|
print_success "Build tools are available"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +190,7 @@ install_synchan() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if yarn is available
|
# Check if yarn is available, install if not
|
||||||
if ! command_exists yarn; then
|
if ! command_exists yarn; then
|
||||||
print_status "Yarn not found, installing yarn..."
|
print_status "Yarn not found, installing yarn..."
|
||||||
if command_exists npm; then
|
if command_exists npm; then
|
||||||
@@ -194,8 +255,18 @@ install_actionwire() {
|
|||||||
# Check if poetry is available
|
# Check if poetry is available
|
||||||
if ! command_exists poetry; then
|
if ! command_exists poetry; then
|
||||||
print_status "Poetry not found, installing poetry..."
|
print_status "Poetry not found, installing poetry..."
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
brew install poetry
|
brew install poetry
|
||||||
print_status "Poetry installed"
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
# Install poetry via pip
|
||||||
|
python3 -m pip install --user poetry
|
||||||
|
# Add poetry to PATH if not already there
|
||||||
|
if ! command_exists poetry; then
|
||||||
|
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
print_success "Poetry installed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clone the repository
|
# Clone the repository
|
||||||
@@ -244,6 +315,7 @@ install_actionwire() {
|
|||||||
install_additional_tools() {
|
install_additional_tools() {
|
||||||
print_status "Installing additional useful development tools..."
|
print_status "Installing additional useful development tools..."
|
||||||
|
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
# Install common tools
|
# Install common tools
|
||||||
brew install curl wget jq tree
|
brew install curl wget jq tree
|
||||||
|
|
||||||
@@ -252,6 +324,24 @@ install_additional_tools() {
|
|||||||
brew install --cask iterm2
|
brew install --cask iterm2
|
||||||
|
|
||||||
print_success "Additional tools installed"
|
print_success "Additional tools installed"
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
# Install common tools
|
||||||
|
sudo apt install -y curl wget jq tree vim nano htop
|
||||||
|
|
||||||
|
# Install VS Code for ARM if available
|
||||||
|
if [[ $(uname -m) == "aarch64" ]]; then
|
||||||
|
print_status "Installing VS Code for ARM64..."
|
||||||
|
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
|
||||||
|
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
|
||||||
|
sudo sh -c 'echo "deb [arch=arm64,armhf,amd64 signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
|
||||||
|
sudo apt update
|
||||||
|
sudo apt install -y code
|
||||||
|
else
|
||||||
|
print_warning "VS Code may not be available for this ARM architecture"
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_success "Additional tools installed"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to verify installations
|
# Function to verify installations
|
||||||
@@ -283,11 +373,13 @@ verify_installations() {
|
|||||||
print_error "✗ Python3 installation failed"
|
print_error "✗ Python3 installation failed"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
if command_exists brew; then
|
if command_exists brew; then
|
||||||
print_success "✓ Homebrew: $(brew --version | head -n1)"
|
print_success "✓ Homebrew: $(brew --version | head -n1)"
|
||||||
else
|
else
|
||||||
print_error "✗ Homebrew installation failed"
|
print_error "✗ Homebrew installation failed"
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Check synchan installation
|
# Check synchan installation
|
||||||
if [ -d "$HOME/synchan" ]; then
|
if [ -d "$HOME/synchan" ]; then
|
||||||
@@ -306,15 +398,21 @@ verify_installations() {
|
|||||||
|
|
||||||
# Main execution
|
# Main execution
|
||||||
main() {
|
main() {
|
||||||
print_status "Starting Mac development environment setup..."
|
print_status "Starting cross-platform development environment setup..."
|
||||||
print_status "This script will install: Git, Node.js, Python, Homebrew, and optionally synchan and actionwire"
|
print_status "This script will install: Git, Node.js, Python, and optionally synchan and actionwire"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Check if running on macOS
|
# Detect operating system
|
||||||
check_macos
|
detect_os
|
||||||
|
|
||||||
# Install Homebrew first (required for other packages)
|
# Update package manager
|
||||||
install_homebrew
|
update_packages
|
||||||
|
|
||||||
|
# Install package manager if needed (Homebrew for Mac)
|
||||||
|
install_package_manager
|
||||||
|
|
||||||
|
# Install build tools
|
||||||
|
install_build_tools
|
||||||
|
|
||||||
# Install core development tools
|
# Install core development tools
|
||||||
install_git
|
install_git
|
||||||
@@ -339,7 +437,7 @@ main() {
|
|||||||
|
|
||||||
# Ask if user wants additional tools
|
# Ask if user wants additional tools
|
||||||
echo ""
|
echo ""
|
||||||
read -p "Do you want to install additional development tools (VS Code, iTerm2, etc.)? [y/N]: " -n 1 -r
|
read -p "Do you want to install additional development tools? [y/N]: " -n 1 -r
|
||||||
echo ""
|
echo ""
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
install_additional_tools
|
install_additional_tools
|
||||||
@@ -349,8 +447,14 @@ main() {
|
|||||||
verify_installations
|
verify_installations
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
print_success "Setup complete! Your Mac development environment is ready."
|
print_success "Setup complete! Your development environment is ready."
|
||||||
|
|
||||||
|
if [[ "$OS" == "macos" ]]; then
|
||||||
print_status "You may need to restart your terminal or run 'source ~/.zprofile' to use the new tools."
|
print_status "You may need to restart your terminal or run 'source ~/.zprofile' to use the new tools."
|
||||||
|
elif [[ "$OS" == "raspi" ]] || [[ "$OS" == "linux" ]]; then
|
||||||
|
print_status "You may need to restart your terminal or run 'source ~/.bashrc' to use the new tools."
|
||||||
|
print_status "If poetry was installed, you may need to restart your terminal for PATH changes to take effect."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run main function
|
# Run main function
|
||||||
|
|||||||
Reference in New Issue
Block a user