Initial commit: Server configurations and license management
This commit is contained in:
97
scripts/init-cad-repo.ps1
Normal file
97
scripts/init-cad-repo.ps1
Normal file
@@ -0,0 +1,97 @@
|
||||
# ===========================================
|
||||
# Initialize CAD Repository Structure
|
||||
# Run this inside your cloned repository
|
||||
# ===========================================
|
||||
|
||||
param(
|
||||
[string]$RepoPath = "."
|
||||
)
|
||||
|
||||
Write-Host "=== Initializing CAD Repository Structure ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
Push-Location $RepoPath
|
||||
|
||||
# Create directory structure
|
||||
$directories = @(
|
||||
"NX/Projects/P04-StarSpec"
|
||||
"NX/Projects/Atomaste-Tools"
|
||||
"NX/Projects/Client-Projects"
|
||||
"NX/Templates/part-templates"
|
||||
"NX/Templates/simulation-templates"
|
||||
"NX/Libraries/materials"
|
||||
"NX/Libraries/fasteners"
|
||||
"SolidWorks/Projects"
|
||||
"SolidWorks/Templates"
|
||||
"Exports/STEP"
|
||||
"Exports/STL"
|
||||
"Exports/PDF"
|
||||
"Documentation/specs"
|
||||
"Documentation/reports"
|
||||
)
|
||||
|
||||
foreach ($dir in $directories) {
|
||||
if (!(Test-Path $dir)) {
|
||||
New-Item -ItemType Directory -Path $dir -Force | Out-Null
|
||||
# Create .gitkeep to track empty directories
|
||||
New-Item -ItemType File -Path "$dir/.gitkeep" -Force | Out-Null
|
||||
Write-Host "Created: $dir" -ForegroundColor Green
|
||||
} else {
|
||||
Write-Host "Exists: $dir" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
|
||||
# Create README.md
|
||||
$readmeContent = @"
|
||||
# CAD Projects Repository
|
||||
|
||||
Version-controlled CAD files using Git LFS on Gitea.
|
||||
|
||||
## Structure
|
||||
|
||||
- **NX/** - NX Siemens projects and files
|
||||
- **Projects/** - Active project folders
|
||||
- **Templates/** - Part and simulation templates
|
||||
- **Libraries/** - Reusable materials and components
|
||||
|
||||
- **SolidWorks/** - SolidWorks projects and files
|
||||
|
||||
- **Exports/** - Exchange format exports (STEP, STL, PDF)
|
||||
|
||||
- **Documentation/** - Specs and reports
|
||||
|
||||
## Quick Commands
|
||||
|
||||
``````bash
|
||||
# Lock a file before editing
|
||||
git lfs lock "NX/Projects/P04-StarSpec/main-assembly.prt"
|
||||
|
||||
# Check what's locked
|
||||
git lfs locks
|
||||
|
||||
# Unlock after committing
|
||||
git lfs unlock "NX/Projects/P04-StarSpec/main-assembly.prt"
|
||||
|
||||
# See LFS tracked files
|
||||
git lfs ls-files
|
||||
``````
|
||||
|
||||
## Server
|
||||
|
||||
- Gitea: http://git.dalidou.home
|
||||
- IP: 192.168.86.50:3000
|
||||
"@
|
||||
|
||||
$readmeContent | Out-File -FilePath "README.md" -Encoding utf8
|
||||
Write-Host "Created: README.md" -ForegroundColor Green
|
||||
|
||||
Pop-Location
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Repository structure initialized!" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
Write-Host "Next steps:" -ForegroundColor Yellow
|
||||
Write-Host " cd $RepoPath"
|
||||
Write-Host " git add ."
|
||||
Write-Host " git commit -m 'Initialize CAD repository structure'"
|
||||
Write-Host " git push"
|
||||
138
scripts/server-setup.sh
Normal file
138
scripts/server-setup.sh
Normal file
@@ -0,0 +1,138 @@
|
||||
#!/bin/bash
|
||||
# ===========================================
|
||||
# Gitea Git LFS Setup Script for dalidou
|
||||
# Server: 192.168.86.50
|
||||
# ===========================================
|
||||
|
||||
set -e
|
||||
|
||||
echo "=== Gitea Git LFS Setup for dalidou ==="
|
||||
echo ""
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 1: Find Gitea container and config
|
||||
# -----------------------------------------
|
||||
echo "[1/5] Finding Gitea container..."
|
||||
|
||||
GITEA_CONTAINER=$(docker ps --format '{{.Names}}' | grep -i gitea | head -1)
|
||||
|
||||
if [ -z "$GITEA_CONTAINER" ]; then
|
||||
echo "ERROR: Gitea container not found!"
|
||||
echo "Make sure Gitea is running: docker ps"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found container: $GITEA_CONTAINER"
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 2: Find app.ini location
|
||||
# -----------------------------------------
|
||||
echo ""
|
||||
echo "[2/5] Locating app.ini..."
|
||||
|
||||
# Try common locations
|
||||
APP_INI_PATHS=(
|
||||
"/data/gitea/conf/app.ini"
|
||||
"/etc/gitea/app.ini"
|
||||
"/app/gitea/conf/app.ini"
|
||||
)
|
||||
|
||||
APP_INI=""
|
||||
for path in "${APP_INI_PATHS[@]}"; do
|
||||
if docker exec "$GITEA_CONTAINER" test -f "$path" 2>/dev/null; then
|
||||
APP_INI="$path"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$APP_INI" ]; then
|
||||
echo "WARNING: Could not find app.ini automatically."
|
||||
echo "Searching inside container..."
|
||||
APP_INI=$(docker exec "$GITEA_CONTAINER" find / -name "app.ini" 2>/dev/null | head -1)
|
||||
fi
|
||||
|
||||
if [ -z "$APP_INI" ]; then
|
||||
echo "ERROR: app.ini not found!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found app.ini at: $APP_INI"
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 3: Backup current config
|
||||
# -----------------------------------------
|
||||
echo ""
|
||||
echo "[3/5] Backing up current configuration..."
|
||||
|
||||
BACKUP_NAME="app.ini.backup.$(date +%Y%m%d_%H%M%S)"
|
||||
docker exec "$GITEA_CONTAINER" cp "$APP_INI" "${APP_INI}.backup"
|
||||
echo "Backup created: ${APP_INI}.backup"
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 4: Check/Enable LFS settings
|
||||
# -----------------------------------------
|
||||
echo ""
|
||||
echo "[4/5] Checking LFS configuration..."
|
||||
|
||||
# Check if LFS is already configured
|
||||
if docker exec "$GITEA_CONTAINER" grep -q "LFS_START_SERVER" "$APP_INI"; then
|
||||
echo "LFS_START_SERVER already exists in config"
|
||||
docker exec "$GITEA_CONTAINER" grep "LFS_START_SERVER" "$APP_INI"
|
||||
else
|
||||
echo "LFS not configured. Adding LFS settings..."
|
||||
|
||||
# Create a temporary script to modify the config
|
||||
docker exec "$GITEA_CONTAINER" sh -c "
|
||||
# Add LFS_START_SERVER to [server] section if not present
|
||||
if grep -q '^\[server\]' '$APP_INI'; then
|
||||
sed -i '/^\[server\]/a LFS_START_SERVER = true' '$APP_INI'
|
||||
fi
|
||||
"
|
||||
echo "Added LFS_START_SERVER = true to [server] section"
|
||||
fi
|
||||
|
||||
# Check/add [lfs] section
|
||||
if docker exec "$GITEA_CONTAINER" grep -q "^\[lfs\]" "$APP_INI"; then
|
||||
echo "[lfs] section already exists"
|
||||
docker exec "$GITEA_CONTAINER" grep -A5 "^\[lfs\]" "$APP_INI"
|
||||
else
|
||||
echo "Adding [lfs] section..."
|
||||
docker exec "$GITEA_CONTAINER" sh -c "
|
||||
echo '' >> '$APP_INI'
|
||||
echo '[lfs]' >> '$APP_INI'
|
||||
echo 'PATH = /data/lfs' >> '$APP_INI'
|
||||
"
|
||||
echo "Added [lfs] section with PATH = /data/lfs"
|
||||
fi
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 5: Create LFS directory and set permissions
|
||||
# -----------------------------------------
|
||||
echo ""
|
||||
echo "[5/5] Setting up LFS directory..."
|
||||
|
||||
docker exec "$GITEA_CONTAINER" sh -c "
|
||||
mkdir -p /data/lfs
|
||||
chown -R git:git /data/lfs 2>/dev/null || chown -R 1000:1000 /data/lfs
|
||||
chmod 755 /data/lfs
|
||||
"
|
||||
echo "LFS directory created at /data/lfs"
|
||||
|
||||
# -----------------------------------------
|
||||
# Show final configuration
|
||||
# -----------------------------------------
|
||||
echo ""
|
||||
echo "=== Current LFS Configuration ==="
|
||||
docker exec "$GITEA_CONTAINER" grep -E "(LFS_START_SERVER|^\[lfs\]|^PATH)" "$APP_INI" || true
|
||||
|
||||
echo ""
|
||||
echo "=== Next Steps ==="
|
||||
echo "1. Restart Gitea to apply changes:"
|
||||
echo " docker restart $GITEA_CONTAINER"
|
||||
echo ""
|
||||
echo "2. Verify LFS is enabled:"
|
||||
echo " docker logs $GITEA_CONTAINER 2>&1 | grep -i lfs"
|
||||
echo ""
|
||||
echo "3. Test from Windows client (see windows-setup.ps1)"
|
||||
echo ""
|
||||
echo "Done!"
|
||||
102
scripts/windows-setup.ps1
Normal file
102
scripts/windows-setup.ps1
Normal file
@@ -0,0 +1,102 @@
|
||||
# ===========================================
|
||||
# Git LFS Setup for Windows (ThinkPad P16)
|
||||
# CAD Versioning with Gitea on dalidou
|
||||
# ===========================================
|
||||
|
||||
Write-Host "=== Git LFS Setup for CAD Versioning ===" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 1: Check Git installation
|
||||
# -----------------------------------------
|
||||
Write-Host "[1/5] Checking Git installation..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$gitVersion = git --version
|
||||
Write-Host "Git installed: $gitVersion" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "ERROR: Git is not installed!" -ForegroundColor Red
|
||||
Write-Host "Install Git from: https://git-scm.com/download/win"
|
||||
Write-Host "Or run: winget install Git.Git"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 2: Install Git LFS
|
||||
# -----------------------------------------
|
||||
Write-Host ""
|
||||
Write-Host "[2/5] Checking/Installing Git LFS..." -ForegroundColor Yellow
|
||||
|
||||
try {
|
||||
$lfsVersion = git lfs version
|
||||
Write-Host "Git LFS installed: $lfsVersion" -ForegroundColor Green
|
||||
} catch {
|
||||
Write-Host "Git LFS not found. Installing..." -ForegroundColor Yellow
|
||||
|
||||
# Try winget first
|
||||
$wingetInstalled = Get-Command winget -ErrorAction SilentlyContinue
|
||||
if ($wingetInstalled) {
|
||||
Write-Host "Installing via winget..."
|
||||
winget install GitHub.GitLFS --accept-package-agreements --accept-source-agreements
|
||||
} else {
|
||||
Write-Host "ERROR: Please install Git LFS manually from https://git-lfs.github.com/"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 3: Initialize Git LFS globally
|
||||
# -----------------------------------------
|
||||
Write-Host ""
|
||||
Write-Host "[3/5] Initializing Git LFS..." -ForegroundColor Yellow
|
||||
|
||||
git lfs install
|
||||
Write-Host "Git LFS initialized globally" -ForegroundColor Green
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 4: Configure Git for large files
|
||||
# -----------------------------------------
|
||||
Write-Host ""
|
||||
Write-Host "[4/5] Configuring Git for large file uploads..." -ForegroundColor Yellow
|
||||
|
||||
# Increase HTTP buffer for large CAD files
|
||||
git config --global http.postBuffer 524288000
|
||||
|
||||
# Configure credentials for Gitea
|
||||
git config --global credential.helper manager
|
||||
|
||||
Write-Host "HTTP buffer set to 500MB" -ForegroundColor Green
|
||||
Write-Host "Credential helper configured" -ForegroundColor Green
|
||||
|
||||
# -----------------------------------------
|
||||
# Step 5: Display connection info
|
||||
# -----------------------------------------
|
||||
Write-Host ""
|
||||
Write-Host "[5/5] Setup Complete!" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host "=== Gitea Server Info ===" -ForegroundColor Cyan
|
||||
Write-Host "URL: http://git.dalidou.home" -ForegroundColor White
|
||||
Write-Host "Alt URL: http://192.168.86.50:3000" -ForegroundColor White
|
||||
Write-Host "SSH: ssh://git@192.168.86.50:2222" -ForegroundColor White
|
||||
Write-Host ""
|
||||
Write-Host "=== Next Steps ===" -ForegroundColor Cyan
|
||||
Write-Host "1. Create a new repository in Gitea web UI"
|
||||
Write-Host "2. Clone it:"
|
||||
Write-Host " git clone http://git.dalidou.home/antoine/cad-projects.git"
|
||||
Write-Host ""
|
||||
Write-Host "3. Copy .gitattributes and .gitignore to the repo:"
|
||||
Write-Host " Copy-Item '.\.gitattributes' 'cad-projects\'"
|
||||
Write-Host " Copy-Item '.\.gitignore' 'cad-projects\'"
|
||||
Write-Host ""
|
||||
Write-Host "4. Commit and push:"
|
||||
Write-Host " cd cad-projects"
|
||||
Write-Host " git add .gitattributes .gitignore"
|
||||
Write-Host " git commit -m 'Add LFS tracking for CAD files'"
|
||||
Write-Host " git push"
|
||||
Write-Host ""
|
||||
Write-Host "=== Daily Workflow Commands ===" -ForegroundColor Cyan
|
||||
Write-Host "Lock file: git lfs lock 'path/to/file.prt'"
|
||||
Write-Host "View locks: git lfs locks"
|
||||
Write-Host "Unlock: git lfs unlock 'path/to/file.prt'"
|
||||
Write-Host "LFS status: git lfs status"
|
||||
Write-Host ""
|
||||
Reference in New Issue
Block a user