Files
eboek.info-scraper/install_and_run.sh
Louis Mylle ea4cab15c3 feat: Add installation scripts for Windows and Unix-based systems
- Created `install_and_run.bat` for Windows installation and setup.
- Created `install_and_run.sh` for Unix-based systems installation and setup.
- Removed `main.py` as it is no longer needed.
- Updated `requirements.txt` to specify package versions and added PyQt5.
- Deleted `start.bat` as it is redundant.
- Added unit tests for core functionality and scraping modes.
- Implemented input validation utilities in `utils/validators.py`.
- Added support for dual scraping modes in the scraper.
2026-01-10 14:45:00 +01:00

158 lines
4.8 KiB
Bash
Executable File

#!/bin/bash
echo "==============================================="
echo " EBoek.info Scraper - Installation and Setup"
echo "==============================================="
echo
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Check operating system
OS="$(uname -s)"
case "${OS}" in
Linux*) MACHINE=Linux;;
Darwin*) MACHINE=Mac;;
*) MACHINE="UNKNOWN:${OS}"
esac
echo "Operating System: $MACHINE"
# Check if Python is installed
if command_exists python3; then
PYTHON_CMD="python3"
elif command_exists python; then
PYTHON_VERSION=$(python --version 2>&1 | grep -oP '\d+\.\d+')
if [[ ${PYTHON_VERSION%.*} -ge 3 ]]; then
PYTHON_CMD="python"
else
echo "ERROR: Python 3 is required. Found Python $PYTHON_VERSION"
PYTHON_CMD=""
fi
else
PYTHON_CMD=""
fi
if [ -z "$PYTHON_CMD" ]; then
echo "Python 3 is not installed."
echo
if [ "$MACHINE" = "Mac" ]; then
echo "To install Python on macOS:"
echo "1. Install Homebrew: /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
echo "2. Install Python: brew install python"
echo " OR download from: https://www.python.org/downloads/"
elif [ "$MACHINE" = "Linux" ]; then
echo "To install Python on Linux:"
echo "Ubuntu/Debian: sudo apt update && sudo apt install python3 python3-pip"
echo "CentOS/RHEL: sudo yum install python3 python3-pip"
echo "Fedora: sudo dnf install python3 python3-pip"
fi
echo
echo "After installing Python, run this script again."
exit 1
fi
echo "Python found: $($PYTHON_CMD --version)"
# Check if pip is available
if ! $PYTHON_CMD -m pip --version >/dev/null 2>&1; then
echo "pip is not available. Installing pip..."
if [ "$MACHINE" = "Mac" ]; then
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
$PYTHON_CMD get-pip.py
rm get-pip.py
elif [ "$MACHINE" = "Linux" ]; then
echo "Please install pip using your package manager:"
echo "Ubuntu/Debian: sudo apt install python3-pip"
echo "CentOS/RHEL: sudo yum install python3-pip"
exit 1
fi
fi
# Check if GUI is already set up
if [ -f "gui_main.py" ]; then
echo "GUI application already set up."
echo
else
echo
echo "Installing required packages..."
echo "==============================================="
# Upgrade pip first
$PYTHON_CMD -m pip install --upgrade pip
# Install requirements
if ! $PYTHON_CMD -m pip install -r requirements.txt; then
echo
echo "ERROR: Failed to install requirements."
echo "Please check your internet connection and try again."
echo "You may need to install additional system dependencies."
if [ "$MACHINE" = "Mac" ]; then
echo
echo "On macOS, you might need to install Xcode command line tools:"
echo "xcode-select --install"
elif [ "$MACHINE" = "Linux" ]; then
echo
echo "On Linux, you might need additional packages:"
echo "Ubuntu/Debian: sudo apt install python3-dev python3-tk"
echo "CentOS/RHEL: sudo yum install python3-devel tkinter"
fi
exit 1
fi
echo
echo "Requirements installed successfully!"
echo "Setting up GUI application..."
fi
# Check for Chrome browser
if [ "$MACHINE" = "Mac" ]; then
if [ ! -d "/Applications/Google Chrome.app" ]; then
echo
echo "WARNING: Google Chrome not found."
echo "Please install Chrome from: https://www.google.com/chrome/"
echo "The scraper requires Chrome to function."
fi
elif [ "$MACHINE" = "Linux" ]; then
if ! command_exists google-chrome && ! command_exists chromium-browser; then
echo
echo "WARNING: Chrome/Chromium not found."
echo "Please install Chrome or Chromium:"
echo "Ubuntu/Debian: sudo apt install chromium-browser"
echo "Or download Chrome from: https://www.google.com/chrome/"
fi
fi
echo
echo "==============================================="
echo "Installation complete!"
echo "==============================================="
# Run the GUI application
if [ -f "gui_main.py" ]; then
echo "Starting EBoek.info Scraper GUI..."
echo
if ! $PYTHON_CMD gui_main.py; then
echo
echo "GUI failed to start. You can still use the terminal version:"
echo "$PYTHON_CMD main.py"
echo
fi
else
echo "GUI version not found. Running terminal version..."
echo
if [ -f "main.py" ]; then
$PYTHON_CMD main.py
else
echo "Error: No scraper found. Please check installation."
exit 1
fi
fi
echo
echo "Application closed."
echo "Press Enter to exit..."
read