-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_harbor_https.sh
More file actions
executable file
·133 lines (108 loc) · 3.6 KB
/
start_harbor_https.sh
File metadata and controls
executable file
·133 lines (108 loc) · 3.6 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
#!/bin/bash
# Harbor WebRTC Streaming Server - HTTPS Startup Script
# This script starts the server with HTTPS support for production use
set -e # Exit on any error
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Configuration
ENV_NAME="harbor"
DEFAULT_HOST="0.0.0.0"
DEFAULT_PORT="8443"
DEFAULT_WIDTH="160"
DEFAULT_HEIGHT="120"
DEFAULT_FPS="30"
CERT_FILE="cert.pem"
KEY_FILE="key.pem"
# Parse command line arguments
HOST=${1:-$DEFAULT_HOST}
PORT=${2:-$DEFAULT_PORT}
WIDTH=${3:-$DEFAULT_WIDTH}
HEIGHT=${4:-$DEFAULT_HEIGHT}
FPS=${5:-$DEFAULT_FPS}
echo "🔒 Starting Harbor WebRTC Streaming Server (HTTPS)"
echo "=================================================="
# Check if conda is available
if ! command -v conda &> /dev/null; then
print_error "Conda is not installed. Please run setup_environment.sh first."
exit 1
fi
# Check if environment exists
if ! conda info --envs | grep -q "^${ENV_NAME} "; then
print_error "Environment '${ENV_NAME}' does not exist."
print_status "Please run: ./setup_environment.sh"
exit 1
fi
# Check for SSL certificates
if [[ ! -f "$CERT_FILE" ]] || [[ ! -f "$KEY_FILE" ]]; then
print_warning "SSL certificates not found. Generating self-signed certificates..."
if ! command -v openssl &> /dev/null; then
print_error "OpenSSL is required to generate certificates."
print_status "Install OpenSSL or provide your own cert.pem and key.pem files."
exit 1
fi
print_status "Generating self-signed certificate (for testing only)..."
openssl req -x509 -newkey rsa:4096 -keyout "$KEY_FILE" -out "$CERT_FILE" -days 365 -nodes \
-subj "/C=US/ST=State/L=City/O=Harbor/OU=Testing/CN=localhost"
print_success "Self-signed certificates generated:"
print_warning "⚠️ These are for TESTING ONLY. Use proper certificates in production!"
fi
print_status "Using certificates:"
echo " Certificate: $CERT_FILE"
echo " Private Key: $KEY_FILE"
print_status "Activating conda environment: ${ENV_NAME}"
# Source conda and activate environment
eval "$(conda shell.bash hook)"
conda activate ${ENV_NAME}
# Verify environment is active
if [[ "$CONDA_DEFAULT_ENV" != "$ENV_NAME" ]]; then
print_error "Failed to activate environment: ${ENV_NAME}"
exit 1
fi
print_success "Environment activated: ${CONDA_DEFAULT_ENV}"
# Display configuration
print_status "HTTPS Server Configuration:"
echo " Host: ${HOST}"
echo " Port: ${PORT}"
echo " Video: ${WIDTH}x${HEIGHT} @ ${FPS} fps"
echo " SSL Certificate: ${CERT_FILE}"
echo " SSL Private Key: ${KEY_FILE}"
echo
# Check if port is available
if command -v lsof &> /dev/null; then
if lsof -i:${PORT} &> /dev/null; then
print_warning "Port ${PORT} appears to be in use."
print_status "Continuing anyway (may fail if port is blocked)..."
fi
fi
# Start the server
print_status "Starting Harbor HTTPS server..."
print_success "Server will be available at: https://localhost:${PORT}"
print_warning "⚠️ You may need to accept the self-signed certificate in your browser"
print_status "Press Ctrl+C to stop the server"
echo
# Run the application with HTTPS
python app.py \
--host "${HOST}" \
--port "${PORT}" \
--width "${WIDTH}" \
--height "${HEIGHT}" \
--fps "${FPS}" \
--cert "${CERT_FILE}" \
--key "${KEY_FILE}"