# 2: Installing Infinity Tools

This chapter covers the complete installation process for Infinity Tools on your Linux server. We'll cover SSH connection, downloading the installer, and running the installation with technical details relevant to system administrators.

## Prerequisites Recap

Ensure you have:

- ✅ Linux server with root/sudo access
- ✅ SSH client installed on your local machine
- ✅ Server IP address and credentials
- ✅ Internet connectivity on both local and server

## Obtaining the Infinity Tools Installer

You'll receive the Infinity Tools installer as a file (typically named `infinity-tools-installer.run`) through your preferred delivery method.

### File Transfer Methods

**Method 1: SCP (Secure Copy) - Recommended**

```
# From your local machine
scp infinity-tools-installer.run root@YOUR_SERVER_IP:/tmp/
```

**Method 2: SFTP (Secure File Transfer Protocol)**

```
# Connect via SFTP
sftp root@YOUR_SERVER_IP

# Upload file
put infinity-tools-installer.run /tmp/

# Exit SFTP
quit
```

### Verify File Integrity

```
# Check file size
ls -lh infinity-tools-installer.run

# Verify file type
file infinity-tools-installer.run

# Check for corruption (if checksum available)
# sha256sum infinity-tools-installer.run
# Compare with provided checksum

# Verify file permissions
ls -la infinity-tools-installer.run
```

## Installation Process

### Pre-Installation Setup

Make the installer executable and verify permissions:

```
chmod +x infinity-tools-installer.run
ls -la infinity-tools-installer.run
```

### Run Installation

Execute the installer with root privileges:

```
sudo ./infinity-tools-installer.run
```

### Installation Process Details

The installer performs the following operations:

1. **Archive Extraction:**
    - Uses makeself to extract to temporary directory
    - Creates `/tmp/selfgz[random]/InfinityTools/`
    - Contains all scripts, configurations, and dependencies
2. **File Installation:**
    - Copies files to `/opt/InfinityTools/`
    - Sets executable permissions on all `*.sh` files
    - Preserves directory structure and file ownership
3. **Dependency Installation:**
    - Installs GUM (interactive menu tool) if not present
    - Detects package manager (apt, dnf, pacman, apk)
    - Adds repository and installs via appropriate package manager
4. **System Integration:**
    - Creates symbolic link: `/usr/local/bin/infinity-tools`
    - Creates desktop entry (if GUI environment detected)
    - Sets up proper file permissions and ownership

### Installation Output

Expected installation output:

```
╔════════════════════════════════════════════════════════════════════════════════╗
║                                                                                ║
║                    ♾️  Infinity Tools - Linux Server Suite                     ║
║                                                                                ║
╚════════════════════════════════════════════════════════════════════════════════╝

📦 Installing Infinity Tools...
   Source: /tmp/selfgz12345/InfinityTools
   Target: /opt/InfinityTools

📋 Copying files...
🔧 Setting permissions...
📦 Checking dependencies...
   Installing 'gum' (interactive menu tool)...
🔗 Creating command shortcut...
🖥️  Creating desktop shortcut...

╔════════════════════════════════════════════════════════════════════════════════╗
║                     ✅ INSTALLATION SUCCESSFUL!                                ║
╚════════════════════════════════════════════════════════════════════════════════╝
```

## First Run

### Launch Infinity Tools

```
sudo bash infinity-tools
```

### Initial System Check

On first run, Infinity Tools will:

- Load all helper modules from `StartHelper/`
- Check system readiness and dependencies
- Initialize the interactive menu system
- Display service status and health information

### Menu Navigation

The main menu provides access to:

- **📱 APPS - SOFTWARE:** Application installation scripts
- **🔐 SECURITY &amp; NETWORKING:** Security hardening and network tools
- **🏗️ INFRASTRUCTURE &amp; CORE SYSTEMS:** Docker, Portainer, system tools
- **💾 BACKUP MANAGEMENT:** Borgmatic, Rclone, backup configuration
- **📊 STATUS &amp; HEALTH:** System monitoring and health checks

## Installation Architecture

### Directory Structure

```
/opt/InfinityTools/
├── start-tools.sh              # Main launcher script
├── install.sh                  # Installation script
├── Solutions/                  # Application installers
│   ├── setup-traefik.sh
│   ├── setup-wordpress.sh
│   └── ...
├── Infrastructure/             # Core system tools
│   ├── install-docker.sh
│   ├── increase-security.sh
│   └── ...
├── StartHelper/                # Helper modules
│   ├── menu-builder.sh
│   ├── service-metadata.sh
│   └── ...
├── Uninstallations/            # Removal scripts
├── Fallback/                   # Recovery tools
└── Repair/                     # Maintenance utilities
```

### Data Directory

Application data is stored in:

```
/opt/speedbits/
├── _configuration/             # Global configuration
├── traefik/                    # Traefik data
├── wordpress/                  # WordPress instances
├── vaultwarden/                # Vaultwarden data
└── ...
```

## Configuration Management

### Global Configuration

Infinity Tools uses a centralized configuration system:

```
# Main configuration file
/opt/speedbits/_configuration/config

# Port configuration
Infrastructure/ports-config.yml

# Service metadata
StartHelper/service-metadata.sh
```

### Environment Variables

Key environment variables for customization:

```
# Debug mode
export INFINITY_DEBUG=true

# Custom installation path (not recommended)
export INFINITY_INSTALL_DIR=/custom/path

# Disable tracking
export INFINITY_NO_TRACKING=true
```

## Security Considerations

### File Permissions

```
# Check script permissions
find /opt/InfinityTools -name "*.sh" -ls

# Verify ownership
ls -la /opt/InfinityTools/

# Check for world-writable files
find /opt/InfinityTools -perm -002 -type f
```

### Network Security

Infinity Tools implements:

- Network isolation between services
- SSL/TLS termination at Traefik
- Firewall configuration via UFW
- SSH hardening options

## Troubleshooting

### Common Issues

**Installation fails with permission errors:**

```
# Ensure running as root
sudo whoami

# Check file permissions
ls -la infinity-tools-installer.run

# Verify disk space
df -h /opt
```

**GUM installation fails:**

```
# Manual GUM installation
curl -sL https://github.com/charmbracelet/gum/releases/download/v0.13.0/gum_0.13.0_Linux_x86_64.tar.gz | tar -xz
sudo mv gum /usr/local/bin/
```

**Command not found after installation:**

```
# Check symbolic link
ls -la /usr/local/bin/infinity-tools

# Recreate if missing
sudo ln -sf /opt/InfinityTools/start-tools.sh /usr/local/bin/infinity-tools

# Update PATH if necessary
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
```

### Log Analysis

```
# Check installation logs
journalctl -u infinity-tools 2>/dev/null || echo "No systemd service"

# Check Docker logs
docker logs infinity-tools 2>/dev/null || echo "No Docker container"

# Check system logs
tail -f /var/log/syslog | grep -i infinity
```

## Uninstallation

### Complete Removal

```
# Remove Infinity Tools
sudo rm -rf /opt/InfinityTools/

# Remove symbolic link
sudo rm -f /usr/local/bin/infinity-tools

# Remove desktop entry
sudo rm -f /usr/share/applications/infinity-tools.desktop

# Remove data (WARNING: This deletes all application data)
sudo rm -rf /opt/speedbits/
```

### Selective Cleanup

To remove only Infinity Tools while preserving data:

```
# Remove only the application
sudo rm -rf /opt/InfinityTools/

# Keep data directory
# /opt/speedbits/ remains intact
```

## Next Steps

After successful installation:

1. **Install Docker:** Navigate to Infrastructure → Install Docker
2. **Configure Traefik:** Set up reverse proxy and SSL
3. **Deploy Applications:** Install your required services
4. **Configure Backups:** Set up Borgmatic for data protection
5. **Security Hardening:** Apply security configurations

## Quick Reference

```
# Start Infinity Tools
sudo infinity-tools

# Manual execution
cd /opt/InfinityTools && sudo bash start-tools.sh

# Check status
sudo infinity-tools --status 2>/dev/null || echo "Status check not available"

# View logs
sudo journalctl -f -u infinity-tools 2>/dev/null || echo "No systemd service"

# Update (if available)
cd /opt/InfinityTools && git pull 2>/dev/null || echo "Not a git repository"
```

---

**Installation Complete:** Infinity Tools is now installed and ready for configuration. Proceed to the next chapter to begin deploying your infrastructure stack.

*Next: Infrastructure Setup and Application Deployment (Chapter 3)*