-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
Β·221 lines (188 loc) Β· 6.26 KB
/
install.sh
File metadata and controls
executable file
Β·221 lines (188 loc) Β· 6.26 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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
# ShortsCreator One-Click Installer for Digital Ocean
# Usage: curl -fsSL https://raw.githubusercontent.com/jdportugal/VideoEditorAPI/main/install.sh | bash
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Helper functions
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"
}
# Check if running as root
if [[ $EUID -ne 0 ]]; then
print_error "This script must be run as root (use sudo)"
exit 1
fi
# Get system information
ARCH=$(uname -m)
OS=$(lsb_release -si 2>/dev/null || echo "Unknown")
VERSION=$(lsb_release -sr 2>/dev/null || echo "Unknown")
print_status "System detected: $OS $VERSION ($ARCH)"
# Check minimum requirements
TOTAL_MEM=$(free -g | awk '/^Mem:/{print $2}')
if [ "$TOTAL_MEM" -lt 3 ]; then
print_warning "System has only ${TOTAL_MEM}GB RAM. Minimum 4GB recommended."
read -p "Continue anyway? (y/N): " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
echo
echo "π¬ ShortsCreator - One-Click Installer"
echo "====================================="
echo "This will install:"
echo " β’ Docker & Docker Compose"
echo " β’ ShortsCreator API server"
echo " β’ Automatic startup service"
echo " β’ Firewall configuration"
echo
read -p "Continue with installation? (Y/n): " -n 1 -r
echo
if [[ $REPLY =~ ^[Nn]$ ]]; then
exit 0
fi
# Update system
print_status "Updating system packages..."
apt-get update -y > /dev/null 2>&1
# Install required packages
print_status "Installing required packages..."
apt-get install -y curl wget git ufw > /dev/null 2>&1
# Install Docker
if ! command -v docker &> /dev/null; then
print_status "Installing Docker..."
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh > /dev/null 2>&1
rm get-docker.sh
systemctl enable docker > /dev/null 2>&1
systemctl start docker > /dev/null 2>&1
print_success "Docker installed successfully"
else
print_success "Docker already installed"
fi
# Install Docker Compose
if ! command -v docker-compose &> /dev/null; then
print_status "Installing Docker Compose..."
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
print_success "Docker Compose installed successfully"
else
print_success "Docker Compose already installed"
fi
# Set up application directory
APP_DIR="/opt/shortscreator"
print_status "Setting up application directory: $APP_DIR"
rm -rf $APP_DIR
mkdir -p $APP_DIR
cd $APP_DIR
# Clone repository
print_status "Downloading ShortsCreator application..."
# Replace this URL with your actual GitHub repository
REPO_URL="https://github.com/jdportugal/VideoEditorAPI.git"
git clone $REPO_URL . > /dev/null 2>&1
# Create environment file
print_status "Setting up configuration..."
if [ ! -f .env ]; then
cp .env.example .env
fi
# Create required directories
mkdir -p temp uploads jobs static logs
chmod 755 temp uploads jobs static logs
# Pull and build Docker images
print_status "Building Docker images (this may take a few minutes)..."
docker-compose pull > /dev/null 2>&1 || true
docker-compose build > /dev/null 2>&1
# Create systemd service
print_status "Setting up auto-start service..."
cat > /etc/systemd/system/shortscreator.service << EOF
[Unit]
Description=ShortsCreator Video Processing API
Requires=docker.service
After=docker.service network.target
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=$APP_DIR
ExecStart=/usr/local/bin/docker-compose up -d
ExecStop=/usr/local/bin/docker-compose down
ExecReload=/usr/local/bin/docker-compose restart
TimeoutStartSec=120
TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable shortscreator.service > /dev/null 2>&1
# Configure firewall
print_status "Configuring firewall..."
ufw --force enable > /dev/null 2>&1
ufw allow ssh > /dev/null 2>&1
ufw allow 5000/tcp > /dev/null 2>&1
# Start the application
print_status "Starting ShortsCreator API..."
systemctl start shortscreator.service
# Wait for service to be ready
print_status "Waiting for service to start..."
sleep 30
# Check if service is running
if systemctl is-active --quiet shortscreator.service; then
print_success "Service started successfully"
else
print_error "Service failed to start"
echo "Check logs with: journalctl -u shortscreator.service"
exit 1
fi
# Get server IP
SERVER_IP=$(curl -s http://checkip.amazonaws.com 2>/dev/null || curl -s http://ipinfo.io/ip 2>/dev/null || echo "YOUR_SERVER_IP")
# Test health endpoint
print_status "Testing API health..."
sleep 10
if curl -f -s "http://localhost:8080/health" > /dev/null; then
print_success "API is responding correctly"
else
print_warning "API health check failed - service may still be starting"
fi
echo
print_success "π ShortsCreator installed successfully!"
echo
echo "π Installation Summary:"
echo "======================="
echo "π API URL: http://$SERVER_IP:8080"
echo "π Health Check: http://$SERVER_IP:8080/health"
echo "π App Directory: $APP_DIR"
echo
echo "π οΈ Management Commands:"
echo " Status: systemctl status shortscreator"
echo " Stop: systemctl stop shortscreator"
echo " Start: systemctl start shortscreator"
echo " Restart: systemctl restart shortscreator"
echo " Logs: docker-compose logs -f"
echo
echo "π API Endpoints:"
echo " POST /add-subtitles - Add subtitles with karaoke effect"
echo " POST /split-video - Split video by time range"
echo " POST /join-videos - Join multiple videos"
echo " POST /add-music - Add background music"
echo " GET /job-status/<id> - Check processing status"
echo " GET /download/<id> - Download processed video"
echo
echo "π§ Example Usage:"
echo "curl -X POST http://$SERVER_IP:8080/add-subtitles \\"
echo " -H 'Content-Type: application/json' \\"
echo " -d '{\"url\": \"https://example.com/video.mp4\"}'"
echo
echo "π¬ Happy video processing!"