-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·160 lines (137 loc) · 4.31 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·160 lines (137 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#!/bin/bash
# Streamlink Dashboard Environment Setup Script
# This script sets up the development environment for Linux/macOS
set -e
echo "🚀 Streamlink Dashboard Environment Setup"
echo "=========================================="
# Check if Python 3.10 is available
if ! command -v python3.10 &> /dev/null; then
echo "❌ Python 3.10 is required but not found."
echo "Please install Python 3.10 first:"
echo ""
echo "Ubuntu/Debian:"
echo " sudo apt update"
echo " sudo apt install software-properties-common"
echo " sudo add-apt-repository ppa:deadsnakes/ppa"
echo " sudo apt update"
echo " sudo apt install python3.10 python3.10-venv python3.10-dev"
echo ""
echo "macOS:"
echo " brew install python@3.10"
echo ""
exit 1
fi
echo "✅ Python 3.10 found: $(python3.10 --version)"
# Install system dependencies
echo "📦 Installing system dependencies..."
if command -v apt-get &> /dev/null; then
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y build-essential libsqlite3-dev sqlite3 ffmpeg curl python3-dev python3.10-dev
elif command -v brew &> /dev/null; then
# macOS
brew install sqlite ffmpeg
elif command -v yum &> /dev/null; then
# CentOS/RHEL
sudo yum install -y gcc sqlite-devel sqlite ffmpeg curl python3-devel
elif command -v dnf &> /dev/null; then
# Fedora
sudo dnf install -y gcc sqlite-devel sqlite ffmpeg curl python3-devel
else
echo "⚠️ Could not detect package manager. Please install manually:"
echo " - build-essential (gcc, make, etc.)"
echo " - libsqlite3-dev"
echo " - sqlite3"
echo " - ffmpeg"
echo " - python3-dev"
fi
# Check if SQLite3 module is available in Python
echo "🔍 Checking SQLite3 availability..."
if ! python3.10 -c "import sqlite3; print('SQLite3 available')" 2>/dev/null; then
echo "⚠️ SQLite3 module not available in Python 3.10"
echo "This might be due to pyenv installation without SQLite support."
echo ""
echo "Solutions:"
echo "1. Reinstall Python 3.10 with SQLite support:"
echo " CONFIGURE_OPTS='--enable-loadable-sqlite-extensions' pyenv install 3.10.18"
echo ""
echo "2. Or use system Python 3.10 instead of pyenv"
echo ""
echo "3. Or use Docker (recommended):"
echo " docker-compose up --build"
echo ""
read -p "Continue anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
else
echo "✅ SQLite3 module is available"
fi
# Check if we're in the right directory
if [ ! -f "docker-compose.yml" ] || [ ! -d "backend" ]; then
echo "❌ Please run this script from the project root directory"
exit 1
fi
# Create unified data directory structure
echo "📁 Creating app_data directory structure..."
mkdir -p app_data/recordings
mkdir -p app_data/database
mkdir -p app_data/logs
mkdir -p app_data/config
# Setup backend environment
echo "🐍 Setting up backend environment..."
cd backend
# Create virtual environment
if [ ! -d "venv" ]; then
echo "Creating Python virtual environment..."
python3.10 -m venv venv
fi
# Activate virtual environment
source venv/bin/activate
# Upgrade pip
echo "Upgrading pip..."
pip install --upgrade pip
# Install dependencies
echo "Installing Python dependencies..."
pip install -r requirements.txt
# Install streamlink
echo "Installing streamlink..."
pip install streamlink
# Make run script executable
chmod +x run.sh
# Create .env file if it doesn't exist
if [ ! -f ".env" ]; then
echo "📝 Creating .env file..."
cat > .env << 'EOF'
# Application settings
DEBUG=true
LOG_LEVEL=INFO
# Database settings
APP_DATA_DIR=/app_data
DATABASE_URL=sqlite+aiosqlite:///$$APP_DATA_DIR/database/streamlink_dashboard.db
# Streamlink settings
STREAMLINK_PATH=streamlink
DEFAULT_QUALITY=best
# Authentication
BASIC_AUTH_USERNAME=admin
BASIC_AUTH_PASSWORD=admin123
# Scheduler settings
SCHEDULER_TIMEZONE=UTC
AUTO_START_SCHEDULER=true
EOF
fi
cd ..
echo ""
echo "✅ Setup completed successfully!"
echo ""
echo ""
echo "1. start the development server:"
echo " cd backend && ./run.sh"
echo ""
echo "2. Access the application:"
echo " http://localhost:8000"
echo " API docs: http://localhost:8000/docs"
echo ""
echo "� If your encounter SQLite issues, use Docker instead!"
echo "📚 For more information, see docs/ENVIRONMENT_SETUP.md"