296 líneas
7.0 KiB
Bash
Archivo Ejecutable
296 líneas
7.0 KiB
Bash
Archivo Ejecutable
#!/bin/bash
|
|
# WoeUSB Docker Verification Script
|
|
# Tests if the Docker setup is working correctly
|
|
|
|
set -e
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
print_header() {
|
|
echo -e "${BLUE}==================================${NC}"
|
|
echo -e "${BLUE} WoeUSB Docker Verification${NC}"
|
|
echo -e "${BLUE}==================================${NC}"
|
|
echo ""
|
|
}
|
|
|
|
print_test() {
|
|
echo -e "${YELLOW}[TEST]${NC} $1"
|
|
}
|
|
|
|
print_pass() {
|
|
echo -e "${GREEN}[PASS]${NC} $1"
|
|
}
|
|
|
|
print_fail() {
|
|
echo -e "${RED}[FAIL]${NC} $1"
|
|
}
|
|
|
|
print_info() {
|
|
echo -e "${BLUE}[INFO]${NC} $1"
|
|
}
|
|
|
|
check_docker() {
|
|
print_test "Checking if Docker is installed..."
|
|
if command -v docker &> /dev/null; then
|
|
DOCKER_VERSION=$(docker --version)
|
|
print_pass "Docker found: $DOCKER_VERSION"
|
|
return 0
|
|
else
|
|
print_fail "Docker is not installed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_docker_compose() {
|
|
print_test "Checking if Docker Compose is installed..."
|
|
if docker compose version &> /dev/null; then
|
|
COMPOSE_VERSION=$(docker compose version)
|
|
print_pass "Docker Compose found: $COMPOSE_VERSION"
|
|
return 0
|
|
elif command -v docker-compose &> /dev/null; then
|
|
COMPOSE_VERSION=$(docker-compose --version)
|
|
print_pass "Docker Compose found: $COMPOSE_VERSION"
|
|
return 0
|
|
else
|
|
print_fail "Docker Compose is not installed"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_privileged() {
|
|
print_test "Checking if current user can run Docker..."
|
|
if docker ps &> /dev/null; then
|
|
print_pass "User can run Docker commands"
|
|
return 0
|
|
else
|
|
print_fail "User cannot run Docker (try: sudo usermod -aG docker $USER)"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_files() {
|
|
print_test "Checking if required files exist..."
|
|
local missing=0
|
|
|
|
if [ ! -f "Dockerfile" ]; then
|
|
print_fail "Dockerfile not found"
|
|
missing=1
|
|
fi
|
|
|
|
if [ ! -f "docker-compose.yml" ]; then
|
|
print_fail "docker-compose.yml not found"
|
|
missing=1
|
|
fi
|
|
|
|
if [ ! -d "WoeUSB" ]; then
|
|
print_fail "WoeUSB directory not found"
|
|
missing=1
|
|
fi
|
|
|
|
if [ ! -f "WoeUSB/sbin/woeusb" ]; then
|
|
print_fail "WoeUSB script not found"
|
|
missing=1
|
|
fi
|
|
|
|
if [ $missing -eq 0 ]; then
|
|
print_pass "All required files present"
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_directories() {
|
|
print_test "Checking if required directories exist..."
|
|
|
|
if [ ! -d "isos" ]; then
|
|
mkdir -p isos
|
|
print_info "Created isos/ directory"
|
|
fi
|
|
|
|
if [ ! -d "output" ]; then
|
|
mkdir -p output
|
|
print_info "Created output/ directory"
|
|
fi
|
|
|
|
print_pass "Directory structure OK"
|
|
return 0
|
|
}
|
|
|
|
check_image() {
|
|
print_test "Checking if Docker image exists..."
|
|
if docker image inspect woeusb:latest &> /dev/null; then
|
|
print_pass "Docker image 'woeusb:latest' found"
|
|
return 0
|
|
else
|
|
print_info "Docker image not built yet (run: docker-compose build)"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_loop_devices() {
|
|
print_test "Testing loop device creation in container..."
|
|
|
|
if ! docker image inspect woeusb:latest &> /dev/null; then
|
|
print_info "Skipping (image not built)"
|
|
return 1
|
|
fi
|
|
|
|
# Test if container can create loop devices
|
|
if docker run --rm --privileged woeusb:latest \
|
|
/bin/bash -c "ls -l /dev/loop* 2>/dev/null | wc -l" &> /dev/null; then
|
|
local loop_count=$(docker run --rm --privileged woeusb:latest \
|
|
/bin/bash -c "ls -l /dev/loop* 2>/dev/null | wc -l")
|
|
if [ "$loop_count" -gt 0 ]; then
|
|
print_pass "Loop devices created successfully ($loop_count devices)"
|
|
return 0
|
|
else
|
|
print_fail "No loop devices found in container"
|
|
return 1
|
|
fi
|
|
else
|
|
print_fail "Could not test loop devices"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_woeusb_command() {
|
|
print_test "Testing if woeusb command is accessible..."
|
|
|
|
if ! docker image inspect woeusb:latest &> /dev/null; then
|
|
print_info "Skipping (image not built)"
|
|
return 1
|
|
fi
|
|
|
|
if docker run --rm woeusb:latest \
|
|
/bin/bash -c "which woeusb" &> /dev/null; then
|
|
print_pass "woeusb command found in PATH"
|
|
return 0
|
|
else
|
|
print_fail "woeusb command not found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
test_sudo_access() {
|
|
print_test "Testing sudo access in container..."
|
|
|
|
if ! docker image inspect woeusb:latest &> /dev/null; then
|
|
print_info "Skipping (image not built)"
|
|
return 1
|
|
fi
|
|
|
|
if docker run --rm woeusb:latest \
|
|
/bin/bash -c "sudo echo 'test'" &> /dev/null; then
|
|
print_pass "sudo works in container"
|
|
return 0
|
|
else
|
|
print_fail "sudo does not work in container"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_usb_devices() {
|
|
print_test "Checking for USB devices on host..."
|
|
|
|
local usb_devices=$(lsblk -d -o NAME,TYPE | grep disk | grep -v "loop\|ram" | wc -l)
|
|
|
|
if [ "$usb_devices" -gt 0 ]; then
|
|
print_pass "Found $usb_devices block device(s)"
|
|
print_info "Available devices:"
|
|
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,VENDOR,MODEL | grep -E "disk|NAME" | grep -v "loop\|ram"
|
|
return 0
|
|
else
|
|
print_info "No external block devices found"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
check_iso_files() {
|
|
print_test "Checking for ISO files..."
|
|
|
|
if [ -n "$(ls -A isos/*.iso 2>/dev/null)" ]; then
|
|
local iso_count=$(ls -1 isos/*.iso 2>/dev/null | wc -l)
|
|
print_pass "Found $iso_count ISO file(s):"
|
|
ls -lh isos/*.iso
|
|
return 0
|
|
else
|
|
print_info "No ISO files found in isos/ directory"
|
|
print_info "Copy your Windows ISO with: cp /path/to/windows.iso isos/"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
print_summary() {
|
|
echo ""
|
|
echo -e "${BLUE}==================================${NC}"
|
|
echo -e "${BLUE} Summary${NC}"
|
|
echo -e "${BLUE}==================================${NC}"
|
|
echo ""
|
|
|
|
if [ $1 -eq 0 ]; then
|
|
echo -e "${GREEN}✓ All critical checks passed!${NC}"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Copy your Windows ISO to isos/ directory"
|
|
echo "2. Identify your USB device with: lsblk"
|
|
echo "3. Run: ./woeusb-docker.sh"
|
|
else
|
|
echo -e "${RED}✗ Some checks failed${NC}"
|
|
echo ""
|
|
echo "Please fix the issues above before proceeding."
|
|
fi
|
|
echo ""
|
|
}
|
|
|
|
# Main execution
|
|
main() {
|
|
print_header
|
|
|
|
local failed=0
|
|
|
|
check_docker || failed=1
|
|
echo ""
|
|
|
|
check_docker_compose || failed=1
|
|
echo ""
|
|
|
|
check_privileged || failed=1
|
|
echo ""
|
|
|
|
check_files || failed=1
|
|
echo ""
|
|
|
|
check_directories || failed=1
|
|
echo ""
|
|
|
|
check_image
|
|
echo ""
|
|
|
|
test_loop_devices
|
|
echo ""
|
|
|
|
test_woeusb_command
|
|
echo ""
|
|
|
|
test_sudo_access
|
|
echo ""
|
|
|
|
check_usb_devices
|
|
echo ""
|
|
|
|
check_iso_files
|
|
echo ""
|
|
|
|
print_summary $failed
|
|
|
|
exit $failed
|
|
}
|
|
|
|
main
|