98 lines
2.8 KiB
Bash
Executable File
98 lines
2.8 KiB
Bash
Executable File
#!/bin/bash
|
|
# Setup script for OBS R2 Uploader
|
|
# Installs dependencies and configures the environment
|
|
|
|
set -e # Exit on error
|
|
|
|
echo "=================================================="
|
|
echo "OBS R2 Uploader - Setup Script"
|
|
echo "=================================================="
|
|
echo ""
|
|
|
|
# Get the directory where this script is located
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
# Check Python version
|
|
echo "Checking Python version..."
|
|
if command -v python3 &> /dev/null; then
|
|
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
|
|
echo "✓ Python $PYTHON_VERSION found"
|
|
else
|
|
echo "✗ Python 3 is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check Node.js version
|
|
echo "Checking Node.js version..."
|
|
if command -v node &> /dev/null; then
|
|
NODE_VERSION=$(node --version)
|
|
echo "✓ Node.js $NODE_VERSION found"
|
|
else
|
|
echo "✗ Node.js is not installed"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if wrangler is installed
|
|
echo "Checking Wrangler CLI..."
|
|
if command -v wrangler &> /dev/null; then
|
|
WRANGLER_VERSION=$(wrangler --version)
|
|
echo "✓ Wrangler $WRANGLER_VERSION found"
|
|
else
|
|
echo "✗ Wrangler is not installed"
|
|
echo "Installing Wrangler globally..."
|
|
npm install -g wrangler
|
|
fi
|
|
|
|
# Install Python dependencies
|
|
echo ""
|
|
echo "Installing Python dependencies..."
|
|
|
|
# Check if virtual environment exists, create if not
|
|
if [ ! -d "venv" ]; then
|
|
echo "Creating virtual environment..."
|
|
python3 -m venv venv
|
|
fi
|
|
|
|
# Install dependencies in virtual environment
|
|
echo "Installing packages in virtual environment..."
|
|
venv/bin/pip install -r requirements.txt
|
|
|
|
echo "✓ Python dependencies installed in venv/"
|
|
echo " Activate with: source venv/bin/activate"
|
|
|
|
# Check if .env exists
|
|
echo ""
|
|
if [ -f .env ]; then
|
|
echo "✓ .env file already exists"
|
|
else
|
|
echo "Creating .env file from template..."
|
|
cp .env.example .env
|
|
echo "⚠ Please edit .env file and add your Cloudflare R2 credentials"
|
|
echo " You can get these from the Cloudflare dashboard after creating an R2 bucket"
|
|
fi
|
|
|
|
# Check if wrangler is authenticated
|
|
echo ""
|
|
echo "Checking Wrangler authentication..."
|
|
if wrangler whoami &> /dev/null; then
|
|
echo "✓ Wrangler is authenticated"
|
|
else
|
|
echo "⚠ Wrangler is not authenticated"
|
|
echo "Run 'wrangler login' to authenticate with Cloudflare"
|
|
fi
|
|
|
|
echo ""
|
|
echo "=================================================="
|
|
echo "Setup complete!"
|
|
echo "=================================================="
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Run 'wrangler login' to authenticate with Cloudflare (if not done)"
|
|
echo "2. Edit .env file with your R2 credentials"
|
|
echo "3. Run './scripts/deploy.sh' to create R2 bucket and deploy worker"
|
|
echo "4. Test upload with './scripts/upload.sh /path/to/video.mp4'"
|
|
echo ""
|