initial commit

This commit is contained in:
2026-03-16 02:43:58 +08:00
commit 515d11e663
8 changed files with 502 additions and 0 deletions

73
run.sh Normal file
View File

@@ -0,0 +1,73 @@
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
echo -e "${CYAN}==========================================${NC}"
echo -e "${CYAN} GitLab Deployment Bootstrapper ${NC}"
echo -e "${CYAN}==========================================${NC}\n"
if [ ! -f ".env" ]; then
echo -e "${YELLOW}[WARNING] No .env file found.${NC}"
echo -e "Creating one from .env.sample..."
cp .env.sample .env
echo -e "\n${RED}[ACTION REQUIRED] A new .env file has been created.${NC}"
echo -e "${RED}Please open the .env file, fill in your specific settings (especially GITLAB_EXTERNAL_URL), and run this script again.${NC}"
exit 1
fi
echo -e "${GREEN}[OK] .env file found. Validating configuration...${NC}"
EXTERNAL_URL=$(grep '^GITLAB_EXTERNAL_URL=' .env | cut -d '=' -f2-)
ROOT_PASSWORD=$(grep '^GITLAB_ROOT_PASSWORD=' .env | cut -d '=' -f2-)
if [[ -z "$EXTERNAL_URL" || "$EXTERNAL_URL" == *"<"* || "$EXTERNAL_URL" == *"example.com"* ]]; then
echo -e "\n${RED}[ERROR] GITLAB_EXTERNAL_URL is invalid or still using the default placeholder!${NC}"
echo -e "${YELLOW}Current value: $EXTERNAL_URL${NC}"
echo -e "${YELLOW}Please edit your .env file and set it to a valid URL (e.g., http://192.168.1.50 or https://gitlab.yourdomain.com).${NC}"
exit 1
fi
if [[ ! "$EXTERNAL_URL" =~ ^https?:// ]]; then
echo -e "\n${RED}[ERROR] GITLAB_EXTERNAL_URL must start with exactly 'http://' or 'https://'.${NC}"
exit 1
fi
if [ ${#ROOT_PASSWORD} -lt 8 ]; then
echo -e "\n${RED}[ERROR] GITLAB_ROOT_PASSWORD must be at least 8 characters long!${NC}"
echo -e "${YELLOW}GitLab enforces a strict 8-character minimum for all passwords.${NC}"
exit 1
fi
echo -e "${GREEN}[OK] Critical variables are valid.${NC}\n"
read -p "Do you want to run the auto-tune script to optimize GitLab for this server's RAM/CPU? (y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
if [ -f "./scripts/auto-tune.sh" ]; then
bash ./scripts/auto-tune.sh
else
echo -e "${YELLOW}[WARNING] ./scripts/auto-tune.sh not found. Skipping tuning.${NC}"
fi
fi
echo -e "\n${CYAN}Starting GitLab via Docker Compose...${NC}"
docker compose up -d
if [ $? -eq 0 ]; then
echo -e "\n${GREEN}==========================================${NC}"
echo -e "${GREEN} SUCCESS! GitLab is now booting up. ${NC}"
echo -e "${GREEN}==========================================${NC}"
echo -e "\n${YELLOW}================= READ THIS =================${NC}"
echo -e "1. GitLab Omnibus is huge. It takes roughly $3$ to $5$ minutes to fully start."
echo -e "2. If you visit $EXTERNAL_URL right now, you might see a '502 Bad Gateway' error. This is normal. Just wait."
echo -e "3. Once you can log in to the web interface, you can register your runner by executing:"
echo -e " ${CYAN}bash ./scripts/setup-runner.sh${NC}"
echo -e "${YELLOW}=============================================${NC}\n"
else
echo -e "\n${RED}[ERROR] Docker Compose failed to start the containers.${NC}"
exit 1
fi