- Create `scripts/setup-swap.sh` to dynamically detect and allocate a 4GB swap file to prevent OOM errors on low-RAM servers. - Integrate the swap check gracefully into the `run.sh` orchestrator flow. - Update `README.md` to document new sudo/disk space prerequisites and the updated deployment steps.
83 lines
3.3 KiB
Bash
83 lines
3.3 KiB
Bash
#!/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"
|
|
|
|
echo -e "${GREEN}[OK] Critical variables are valid.${NC}\n"
|
|
|
|
if [ -f "./scripts/setup-swap.sh" ]; then
|
|
bash ./scripts/setup-swap.sh
|
|
else
|
|
echo -e "${YELLOW}[WARNING] ./scripts/setup-swap.sh not found. Skipping swap check.${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
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
|