Skip to content

Commit c0915ac

Browse files
committed
Fix corrupted shell scripts for Docker deployment
- Fixed shebang lines (removed backslash escapes) - Fixed negation operators (! instead of \!) - Removed corrupted EOF markers at end of files - Fixed ARM64 architecture support in install-ffmpeg.sh - Ensured all scripts have proper executable permissions These scripts are critical for Docker container initialization and deployment verification.
1 parent 571d688 commit c0915ac

File tree

6 files changed

+141
-224
lines changed

6 files changed

+141
-224
lines changed

docker/install-ffmpeg.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#\!/bin/bash
1+
#!/bin/bash
22
# Install latest FFmpeg from BtbN/FFmpeg-Builds (static builds)
33
# This ensures we get the latest FFmpeg with all codecs enabled
44

@@ -10,26 +10,24 @@ echo "Installing FFmpeg..."
1010
ARCH=$(uname -m)
1111
case $ARCH in
1212
x86_64)
13-
FFMPEG_ARCH="amd64"
13+
FFMPEG_ARCH="linux64"
14+
DOWNLOAD_URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz"
1415
;;
1516
aarch64|arm64)
16-
FFMPEG_ARCH="arm64"
17+
FFMPEG_ARCH="linuxarm64"
18+
DOWNLOAD_URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linuxarm64-gpl.tar.xz"
1719
;;
1820
*)
1921
echo "Unsupported architecture: $ARCH"
2022
exit 1
2123
;;
2224
esac
2325

24-
# FFmpeg version and download URL
25-
FFMPEG_VERSION="6.1"
26-
DOWNLOAD_URL="https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-linux64-gpl.tar.xz"
27-
2826
# Create temporary directory
2927
TEMP_DIR=$(mktemp -d)
3028
cd "$TEMP_DIR"
3129

32-
echo "Downloading FFmpeg for $ARCH..."
30+
echo "Downloading FFmpeg for $ARCH from $DOWNLOAD_URL..."
3331
curl -L -o ffmpeg.tar.xz "$DOWNLOAD_URL"
3432

3533
echo "Extracting FFmpeg..."
@@ -49,5 +47,4 @@ ffprobe -version
4947
cd /
5048
rm -rf "$TEMP_DIR"
5149

52-
echo "FFmpeg installation completed successfully\!"
53-
EOF < /dev/null
50+
echo "FFmpeg installation completed successfully!"

scripts/backup-postgres.sh

100644100755
File mode changed.

scripts/disaster-recovery.sh

100644100755
File mode changed.

scripts/docker-entrypoint.sh

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#\!/bin/bash
1+
#!/bin/bash
22
# Docker entrypoint script for FFmpeg API
33
# Handles initialization and service startup
44

@@ -10,28 +10,28 @@ wait_for_service() {
1010
local port=$2
1111
local service=$3
1212
local timeout=${4:-60}
13-
13+
1414
echo "Waiting for $service at $host:$port..."
1515
for i in $(seq 1 $timeout); do
1616
if nc -z "$host" "$port" 2>/dev/null; then
17-
echo "$service is ready\!"
17+
echo "$service is ready!"
1818
return 0
1919
fi
2020
echo "Waiting for $service... ($i/$timeout)"
2121
sleep 1
2222
done
23-
23+
2424
echo "ERROR: $service at $host:$port not available after $timeout seconds"
2525
return 1
2626
}
2727

2828
# Function to run database migrations
2929
run_migrations() {
3030
echo "Running database migrations..."
31-
31+
3232
# Wait for PostgreSQL
3333
wait_for_service postgres 5432 "PostgreSQL" 120
34-
34+
3535
# Run Alembic migrations
3636
if [ -f "alembic.ini" ]; then
3737
echo "Running Alembic migrations..."
@@ -45,54 +45,54 @@ run_migrations() {
4545
# Function to initialize storage
4646
init_storage() {
4747
echo "Initializing storage directories..."
48-
48+
4949
# Create storage directories
5050
mkdir -p /storage/input /storage/output /storage/temp
5151
mkdir -p /app/logs /app/temp
52-
52+
5353
# Set permissions
5454
chmod 755 /storage/input /storage/output /storage/temp
5555
chmod 755 /app/logs /app/temp
56-
56+
5757
echo "Storage directories initialized."
5858
}
5959

6060
# Function to validate environment
6161
validate_environment() {
6262
echo "Validating environment..."
63-
63+
6464
# Check required environment variables
6565
if [ -z "$DATABASE_URL" ]; then
6666
echo "ERROR: DATABASE_URL environment variable is required"
6767
exit 1
6868
fi
69-
69+
7070
if [ -z "$REDIS_URL" ]; then
7171
echo "ERROR: REDIS_URL environment variable is required"
7272
exit 1
7373
fi
74-
74+
7575
# Check FFmpeg installation
76-
if \! command -v ffmpeg &> /dev/null; then
76+
if ! command -v ffmpeg &> /dev/null; then
7777
echo "ERROR: FFmpeg is not installed"
7878
exit 1
7979
fi
80-
81-
if \! command -v ffprobe &> /dev/null; then
80+
81+
if ! command -v ffprobe &> /dev/null; then
8282
echo "ERROR: FFprobe is not installed"
8383
exit 1
8484
fi
85-
85+
8686
echo "Environment validation passed."
8787
}
8888

8989
# Function to setup monitoring
9090
setup_monitoring() {
9191
echo "Setting up monitoring..."
92-
92+
9393
# Create metrics directory
9494
mkdir -p /app/metrics
95-
95+
9696
# Setup log rotation if available
9797
if command -v logrotate &> /dev/null; then
9898
echo "Setting up log rotation..."
@@ -108,35 +108,35 @@ setup_monitoring() {
108108
}
109109
LOGROTATE_EOF
110110
fi
111-
111+
112112
echo "Monitoring setup completed."
113113
}
114114

115115
# Main execution
116116
main() {
117117
local service_type=${1:-api}
118-
118+
119119
echo "Starting FFmpeg API Docker Container..."
120120
echo "Service Type: $service_type"
121121
echo "Environment: ${ENVIRONMENT:-production}"
122-
122+
123123
# Initialize
124124
validate_environment
125125
init_storage
126126
setup_monitoring
127-
127+
128128
# Service-specific initialization
129129
case $service_type in
130130
"api")
131131
echo "Starting API service..."
132-
132+
133133
# Wait for dependencies
134134
wait_for_service postgres 5432 "PostgreSQL" 120
135135
wait_for_service redis 6379 "Redis" 60
136-
136+
137137
# Run migrations (API service is responsible for this)
138138
run_migrations
139-
139+
140140
# Start API server
141141
exec uvicorn api.main:app \
142142
--host 0.0.0.0 \
@@ -146,14 +146,14 @@ main() {
146146
--access-log \
147147
--log-level ${LOG_LEVEL:-info}
148148
;;
149-
149+
150150
"worker")
151151
echo "Starting worker service..."
152-
152+
153153
# Wait for dependencies
154154
wait_for_service postgres 5432 "PostgreSQL" 120
155155
wait_for_service redis 6379 "Redis" 60
156-
156+
157157
# Start Celery worker
158158
exec celery -A worker.main worker \
159159
--loglevel=${LOG_LEVEL:-info} \
@@ -162,20 +162,20 @@ main() {
162162
--max-tasks-per-child=${WORKER_MAX_TASKS_PER_CHILD:-100} \
163163
--time-limit=${WORKER_TASK_TIME_LIMIT:-21600}
164164
;;
165-
165+
166166
"migrate")
167167
echo "Running migration service..."
168168
run_migrations
169169
echo "Migration completed successfully."
170170
;;
171-
171+
172172
"setup")
173173
echo "Running setup tasks..."
174174
validate_environment
175175
init_storage
176176
echo "Setup completed successfully."
177177
;;
178-
178+
179179
*)
180180
echo "Unknown service type: $service_type"
181181
echo "Available service types: api, worker, migrate, setup"
@@ -187,13 +187,13 @@ main() {
187187
# Signal handlers for graceful shutdown
188188
shutdown() {
189189
echo "Received shutdown signal..."
190-
190+
191191
# Kill child processes
192-
if [ \! -z "$\!" ]; then
193-
kill -TERM "$\!" 2>/dev/null || true
194-
wait "$\!" 2>/dev/null || true
192+
if [ ! -z "$!" ]; then
193+
kill -TERM "$!" 2>/dev/null || true
194+
wait "$!" 2>/dev/null || true
195195
fi
196-
196+
197197
echo "Shutdown completed."
198198
exit 0
199199
}
@@ -203,4 +203,3 @@ trap shutdown SIGTERM SIGINT
203203

204204
# Run main function with all arguments
205205
main "$@"
206-
EOF < /dev/null

0 commit comments

Comments
 (0)