Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
119
scripts/infrastructure/setup-git-server.sh
Executable file
119
scripts/infrastructure/setup-git-server.sh
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/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 <<EOF
|
||||
[Unit]
|
||||
Description=Gitea (Git with a cup of tea)
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=$GITEA_USER
|
||||
Group=$GITEA_USER
|
||||
WorkingDirectory=$GITEA_HOME
|
||||
ExecStart=$GITEA_HOME/gitea web --config $GITEA_HOME/custom/conf/app.ini
|
||||
Restart=always
|
||||
RestartSec=5s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
log_step "Step 5: Creating initial configuration..."
|
||||
mkdir -p "$GITEA_HOME/custom/conf"
|
||||
cat > "$GITEA_HOME/custom/conf/app.ini" <<EOF
|
||||
[server]
|
||||
DOMAIN = $GITEA_DOMAIN
|
||||
HTTP_PORT = $GITEA_PORT
|
||||
ROOT_URL = http://$GITEA_DOMAIN:$GITEA_PORT/
|
||||
DISABLE_SSH = false
|
||||
SSH_PORT = 22
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = $GITEA_HOME/data/gitea.db
|
||||
|
||||
[repository]
|
||||
ROOT = $GITEA_HOME/gitea-repositories
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = Info
|
||||
EOF
|
||||
|
||||
chown -R "$GITEA_USER:$GITEA_USER" "$GITEA_HOME"
|
||||
|
||||
log_step "Step 6: Enabling and starting Gitea..."
|
||||
systemctl daemon-reload
|
||||
systemctl enable gitea
|
||||
systemctl start gitea
|
||||
sleep 3
|
||||
systemctl status gitea --no-pager
|
||||
|
||||
log_info "========================================="
|
||||
log_info "Gitea Installation Complete!"
|
||||
log_info "========================================="
|
||||
echo ""
|
||||
log_info "Access Gitea at: http://$GITEA_DOMAIN:$GITEA_PORT"
|
||||
log_info "Initial setup will be required on first access"
|
||||
echo ""
|
||||
log_info "Next steps:"
|
||||
echo " 1. Complete initial Gitea setup via web UI"
|
||||
echo " 2. Create GitOps repository"
|
||||
echo " 3. Configure SSH keys for Git access"
|
||||
echo " 4. Set up Flux GitOps (if using)"
|
||||
|
||||
Reference in New Issue
Block a user