mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 04:30:13 -08:00
Add Docker test scripts for setup validation
- Created run-docker-tests.sh to execute setup tests in isolated Docker containers (Ubuntu and Debian). - Implemented logging functionality to track test results and errors. - Added startup.sh to ensure proper permissions and run tests within Docker containers. - Developed test-setup.sh to validate bootstrap.sh and setup.sh scripts, including package availability checks. - Enhanced error handling and reporting for package installations and missing dependencies. - Included detailed logging for system information and test results.
This commit is contained in:
75
shell-setup/startup.sh
Executable file
75
shell-setup/startup.sh
Executable file
@@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Startup script for Docker containers to ensure permissions and run tests
|
||||
|
||||
# Define colors for output
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[0;33m'
|
||||
RED='\033[0;31m'
|
||||
BLUE='\033[0;34m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
echo -e "${BLUE}=== Container Startup Checks ===${NC}"
|
||||
|
||||
# Display system information
|
||||
echo -e "${BLUE}System information:${NC}"
|
||||
if [ -f /etc/os-release ]; then
|
||||
. /etc/os-release
|
||||
echo -e "- OS: ${GREEN}$PRETTY_NAME${NC}"
|
||||
else
|
||||
echo -e "- OS: ${YELLOW}Unknown${NC}"
|
||||
fi
|
||||
|
||||
# Ensure packages.list is available
|
||||
echo -e "${BLUE}Checking for packages.list:${NC}"
|
||||
if [ -f "$HOME/shell/setup/packages.list" ]; then
|
||||
echo -e "- packages.list: ${GREEN}Found${NC}"
|
||||
# Count packages in list (excluding comments and empty lines)
|
||||
pkg_count=$(grep -v '^//' "$HOME/shell/setup/packages.list" | grep -v -e '^$' | wc -l)
|
||||
echo -e "- Package count: ${GREEN}$pkg_count packages${NC}"
|
||||
else
|
||||
echo -e "- packages.list: ${RED}Not found${NC}"
|
||||
echo "Error: Could not find packages.list file. Tests will fail."
|
||||
fi
|
||||
|
||||
# Ensure logs directory has correct permissions
|
||||
echo -e "${BLUE}Setting up logs directory:${NC}"
|
||||
if [ -d "/logs" ]; then
|
||||
echo -e "- Logs directory: ${GREEN}Found${NC}"
|
||||
|
||||
# Check ownership and permissions
|
||||
logs_owner=$(stat -c '%U:%G' /logs)
|
||||
echo -e "- Current ownership: $logs_owner"
|
||||
|
||||
echo "- Setting permissions on /logs directory..."
|
||||
sudo chown -R $(whoami):$(whoami) /logs 2>/dev/null || echo -e "${YELLOW}Failed to set ownership${NC}"
|
||||
sudo chmod -R 777 /logs 2>/dev/null || echo -e "${YELLOW}Failed to set permissions${NC}"
|
||||
|
||||
# Verify permissions are correct
|
||||
if [ -w "/logs" ]; then
|
||||
echo -e "- Write permission: ${GREEN}OK${NC}"
|
||||
|
||||
# Create a test file to really verify we can write
|
||||
if touch "/logs/test_file" 2>/dev/null; then
|
||||
echo -e "- Test write: ${GREEN}Succeeded${NC}"
|
||||
rm -f "/logs/test_file"
|
||||
else
|
||||
echo -e "- Test write: ${RED}Failed${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "- Write permission: ${RED}Failed${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "- Logs directory: ${YELLOW}Not found${NC}"
|
||||
echo "- Creating /logs directory..."
|
||||
if sudo mkdir -p /logs && sudo chown -R $(whoami):$(whoami) /logs && sudo chmod -R 777 /logs; then
|
||||
echo -e "- Created logs directory with proper permissions: ${GREEN}Success${NC}"
|
||||
else
|
||||
echo -e "- Creating logs directory: ${RED}Failed${NC}"
|
||||
echo "Warning: Logs will be saved inside container only"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}=== Starting Test Script ===${NC}"
|
||||
# Run the test script
|
||||
./test-setup.sh
|
||||
Reference in New Issue
Block a user