Create docker-entrypoint.sh
Browse files- docker-entrypoint.sh +44 -0
docker-entrypoint.sh
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Docker entrypoint script for RAR extractor
|
| 4 |
+
|
| 5 |
+
# Check if required environment variables are set
|
| 6 |
+
if [ -z "$HF_TOKEN" ]; then
|
| 7 |
+
echo "β Error: HF_TOKEN environment variable is required"
|
| 8 |
+
exit 1
|
| 9 |
+
fi
|
| 10 |
+
|
| 11 |
+
if [ -z "$SOURCE_REPO" ]; then
|
| 12 |
+
echo "β Error: SOURCE_REPO environment variable is required"
|
| 13 |
+
exit 1
|
| 14 |
+
fi
|
| 15 |
+
|
| 16 |
+
# Create directories if they don't exist
|
| 17 |
+
mkdir -p "$DOWNLOAD_FOLDER" "$EXTRACT_FOLDER" "$STATE_FOLDER"
|
| 18 |
+
|
| 19 |
+
# Move state files to persistent state directory
|
| 20 |
+
if [ -f "/app/download_progress.json" ] && [ ! -f "$STATE_FOLDER/download_progress.json" ]; then
|
| 21 |
+
mv /app/download_progress.json "$STATE_FOLDER/"
|
| 22 |
+
fi
|
| 23 |
+
|
| 24 |
+
if [ -f "/app/process_progress.json" ] && [ ! -f "$STATE_FOLDER/process_progress.json" ]; then
|
| 25 |
+
mv /app/process_progress.json "$STATE_FOLDER/"
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
if [ -f "/app/failed_files.log" ] && [ ! -f "$STATE_FOLDER/failed_files.log" ]; then
|
| 29 |
+
mv /app/failed_files.log "$STATE_FOLDER/"
|
| 30 |
+
fi
|
| 31 |
+
|
| 32 |
+
# Create symlinks for state files
|
| 33 |
+
ln -sf "$STATE_FOLDER/download_progress.json" /app/download_progress.json
|
| 34 |
+
ln -sf "$STATE_FOLDER/process_progress.json" /app/process_progress.json
|
| 35 |
+
ln -sf "$STATE_FOLDER/failed_files.log" /app/failed_files.log
|
| 36 |
+
|
| 37 |
+
echo "π³ Docker container starting..."
|
| 38 |
+
echo "π Source Repo: $SOURCE_REPO"
|
| 39 |
+
echo "π Extract Folder: $EXTRACT_FOLDER"
|
| 40 |
+
echo "πΎ State Folder: $STATE_FOLDER"
|
| 41 |
+
echo "π HF Token: ${HF_TOKEN:0:10}..."
|
| 42 |
+
|
| 43 |
+
# Execute the command
|
| 44 |
+
exec "$@"
|