90 lines
No EOL
3 KiB
Bash
90 lines
No EOL
3 KiB
Bash
#!/bin/bash
|
|
|
|
# apt-layer Testing Environment Startup Script
|
|
# Connects to existing apt-cache server
|
|
|
|
set -e
|
|
|
|
# Colors for output
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${BLUE}==========================================${NC}"
|
|
echo -e "${BLUE}apt-layer C Implementation - Testing Setup${NC}"
|
|
echo -e "${BLUE}==========================================${NC}"
|
|
echo
|
|
|
|
# Get the directory where this script is located
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
DOCKER_DIR="$PROJECT_DIR/docker"
|
|
|
|
echo -e "${GREEN}✓ Project directory: $PROJECT_DIR${NC}"
|
|
echo -e "${GREEN}✓ Docker directory: $DOCKER_DIR${NC}"
|
|
echo
|
|
|
|
# Check if we're connected to the existing apt-cache server
|
|
echo -e "${BLUE}Checking apt-cache server connection...${NC}"
|
|
if curl -s http://localhost:3142/acng-report.html > /dev/null; then
|
|
echo -e "${GREEN}✓ apt-cache server is running on localhost:3142${NC}"
|
|
else
|
|
echo -e "${YELLOW}⚠ apt-cache server not found on localhost:3142${NC}"
|
|
echo -e "${YELLOW} Make sure your particleos-builder apt-cacher-ng is running${NC}"
|
|
echo -e "${YELLOW} You can start it with: docker start apt-cacher-ng${NC}"
|
|
read -p -e "${BLUE}Continue anyway? (y/N): ${NC}" -n 1 -r
|
|
echo
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Change to docker directory
|
|
cd "$DOCKER_DIR"
|
|
echo -e "${GREEN}✓ Changed to docker directory${NC}"
|
|
echo
|
|
|
|
# Build and start the container
|
|
echo -e "${BLUE}Building and starting apt-layer test container...${NC}"
|
|
docker-compose up --build -d
|
|
|
|
# Wait for container to be ready
|
|
echo -e "${YELLOW}Waiting for container to be ready...${NC}"
|
|
sleep 5
|
|
|
|
# Show container status
|
|
echo -e "${BLUE}Container status:${NC}"
|
|
docker-compose ps
|
|
echo
|
|
|
|
# Attach to the container
|
|
echo -e "${BLUE}Attaching to container (use Ctrl+P, Ctrl+Q to detach)...${NC}"
|
|
docker-compose exec apt-layer-test /bin/bash
|
|
|
|
echo -e "${GREEN}Container stopped. To restart: cd $DOCKER_DIR && docker-compose up -d${NC}"
|
|
|
|
# Show available commands
|
|
echo -e "${BLUE}Available Commands:${NC}"
|
|
echo -e "${YELLOW}Attach to container:${NC} docker-compose exec apt-layer-test /bin/bash"
|
|
echo -e "${YELLOW}View logs:${NC} docker-compose logs -f apt-layer-test"
|
|
echo -e "${YELLOW}Stop container:${NC} docker-compose down"
|
|
echo -e "${YELLOW}Restart container:${NC} docker-compose up -d"
|
|
echo
|
|
|
|
# Ask if user wants to attach to container
|
|
echo -e "${BLUE}Would you like to attach to the container now? (y/n)${NC}"
|
|
read -r response
|
|
|
|
if [[ "$response" =~ ^[Yy]$ ]]; then
|
|
echo -e "${GREEN}Attaching to container...${NC}"
|
|
echo -e "${YELLOW}Inside the container, you can:${NC}"
|
|
echo " - Run tests: ./testing/test-apt-layer.sh"
|
|
echo " - Test commands: ./bin/apt-layer --help"
|
|
echo " - Build: make clean && make"
|
|
echo " - Exit: exit"
|
|
echo
|
|
docker-compose exec apt-layer-test /bin/bash
|
|
else
|
|
echo -e "${GREEN}Container is ready! Use 'docker-compose exec apt-layer-test /bin/bash' to attach.${NC}"
|
|
fi |