#!/bin/bash source ~/.bashrc # Git Server Setup Script (Gitea) # Run this on the Git Server VM after OS installation set -e # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' log_info() { echo -e "${GREEN}[INFO]${NC} $1" } log_warn() { echo -e "${YELLOW}[WARN]${NC} $1" } log_error() { echo -e "${RED}[ERROR]${NC} $1" } log_step() { echo -e "${BLUE}[STEP]${NC} $1" } # Check if running as root if [ "$EUID" -ne 0 ]; then log_error "Please run as root (use sudo)" exit 1 fi GITEA_VERSION="${GITEA_VERSION:-1.21.0}" GITEA_USER="${GITEA_USER:-git}" GITEA_HOME="${GITEA_HOME:-/var/lib/gitea}" GITEA_DOMAIN="${GITEA_DOMAIN:-192.168.1.121}" GITEA_PORT="${GITEA_PORT:-3000}" log_step "Step 1: Installing dependencies..." apt-get update apt-get install -y git sqlite3 log_step "Step 2: Creating Gitea user..." useradd -r -s /bin/bash -m -d "$GITEA_HOME" "$GITEA_USER" || log_warn "User $GITEA_USER may already exist" log_step "Step 3: Downloading and installing Gitea..." mkdir -p "$GITEA_HOME" cd "$GITEA_HOME" wget -O gitea "https://dl.gitea.io/gitea/${GITEA_VERSION}/gitea-${GITEA_VERSION}-linux-amd64" chmod +x gitea chown -R "$GITEA_USER:$GITEA_USER" "$GITEA_HOME" log_step "Step 4: Creating systemd service..." cat > /etc/systemd/system/gitea.service < "$GITEA_HOME/custom/conf/app.ini" <