Files
tools-installer/GITEA_INSTALLER_README.md

5.8 KiB

Gitea Server Installer

A comprehensive installer script for Gitea server that supports multiple Linux distributions and installation methods.

Features

  • Version Checking: Only downloads and installs if newer version is available
  • Multiple Installation Methods:
    • Package manager (apt, yum, dnf, zypper)
    • Binary download from GitHub releases
  • Cross-Platform Support: Debian, Ubuntu, RHEL, CentOS, Fedora, Arch, openSUSE
  • Architecture Support: x86_64 (amd64), ARM64, ARM
  • Automatic Updates: Fetches latest version from GitHub releases
  • Force Reinstall: Option to force reinstall even if up-to-date
  • Service Setup: Optional systemd service creation and configuration

Usage

Basic Usage

# Install latest version (only if newer than current)
./install-gitea-server.sh

# Install specific version
./install-gitea-server.sh -v v1.25.0

# Force reinstall even if up-to-date
./install-gitea-server.sh --force

Installation Methods

# Force installation from package manager
./install-gitea-server.sh --package

# Force installation from binary
./install-gitea-server.sh --binary

# Install and set up as systemd service
./install-gitea-server.sh --service

Help

./install-gitea-server.sh --help

Installation Logic

Version Checking

  1. Check Current Version: Detects installed Gitea version
  2. Fetch Latest: Gets latest version from GitHub API
  3. Compare Versions: Only proceeds if newer version available
  4. Force Override: --force flag bypasses version check

Installation Priority

  1. Package Manager (preferred):

    • Debian/Ubuntu: Uses official Gitea repository
    • RHEL/CentOS/Fedora: Uses official Gitea repository
    • Arch Linux: Available in AUR
    • openSUSE: Uses official Gitea repository
  2. Binary Download (fallback):

    • Downloads platform-specific binary from GitHub releases
    • Supports x86_64, ARM64, ARM architectures
    • Installs to /usr/local/bin/gitea

Service Setup

When --service is used:

  • Creates systemd service file
  • Sets up proper user/group permissions
  • Creates configuration directories
  • Generates basic configuration
  • Enables and starts the service

File Locations

Installation Directory

  • Binary: /usr/local/bin/gitea
  • Service: /etc/systemd/system/gitea.service
  • Configuration: /etc/gitea/app.ini
  • Data: /var/lib/gitea/data
  • Repositories: /var/lib/gitea/data/repositories
  • Logs: /var/lib/gitea/log
  • Attachments: /var/lib/gitea/data/attachments

Configuration

The installer creates a basic configuration with:

  • SQLite database (suitable for small installations)
  • Security settings with generated secret key
  • Local file storage
  • Console logging
  • Service user/group permissions

Version Comparison

The installer uses semantic version comparison:

  • Format: vX.Y.Z (e.g., v1.25.1)
  • Logic: Compares major, minor, patch versions
  • Build Info: Ignores build hashes/identifiers

Examples

Typical Workflow

# Check if update needed
./install-gitea-server.sh

# Output if up-to-date:
# [SUCCESS] You already have latest version (v1.25.1)
# [SUCCESS] No installation needed. Exiting.

# Output if update available:
# [INFO] Current version: v1.25.0
# [INFO] Latest version: v1.25.1
# [INFO] Newer version available: v1.25.1 > v1.25.0
# [SUCCESS] Installation completed successfully!

Service Setup

# Install and set up as service
./install-gitea-server.sh --service

# Output:
# [SUCCESS] Gitea service setup completed!
# Next steps:
# 1. Start service: sudo systemctl start gitea
# 2. Check status: sudo systemctl status gitea
# 3. View logs: sudo journalctl -u gitea -f
# 4. Configure at: /etc/gitea/app.ini

System Requirements

Required

  • curl or wget (for downloading)
  • sudo access (for system-wide installation)
  • Systemd (for service setup)

Optional

  • Package manager access (for package installations)
  • Internet connection (for downloading releases)

Security Features

  • Official Releases: Downloads from official GitHub releases
  • Package Verification: Uses GPG keys for package manager installations
  • Proper Permissions: Sets appropriate file ownership and permissions
  • Service Isolation: Runs as dedicated service user/group

Supported Distributions

Package Manager Support

  • Debian/Ubuntu: Official Gitea repository with GPG verification
  • RHEL/CentOS/Fedora: Official Gitea RPM repository
  • Arch Linux: Available in AUR (pacman)
  • openSUSE: Official Gitea repository

Binary Support

  • Linux x86_64: gitea-1.25.1-linux-amd64
  • Linux ARM64: gitea-1.25.1-linux-arm64
  • Linux ARM: gitea-1.25.1-linux-arm-5

Troubleshooting

Version Detection Issues

# Check current version manually
gitea --version

# Force reinstall if version detection fails
./install-gitea-server.sh --force

Permission Issues

# Ensure proper permissions
sudo chown root:root /usr/local/bin/gitea
sudo chmod 755 /usr/local/bin/gitea

Service Issues

# Check service status
sudo systemctl status gitea

# View service logs
sudo journalctl -u gitea -f

# Restart service
sudo systemctl restart gitea

Production Considerations

For production use, consider:

  • Using PostgreSQL/MySQL instead of SQLite
  • Configuring reverse proxy (nginx/apache)
  • Setting up SSL certificates
  • Adjusting firewall settings
  • Regular backups
  • Monitoring and log rotation

Contributing

To add support for new distributions or architectures:

  1. Update detect_os() function for new package managers
  2. Add architecture detection in get_arch() function
  3. Update installation methods in install_from_*() functions
  4. Test with target distribution
  5. Update documentation

License

This installer script follows the same license as Gitea (MIT).