Fred808 commited on
Commit
fad12cc
Β·
verified Β·
1 Parent(s): 88a630d

Update docker-entrypoint.sh

Browse files
Files changed (1) hide show
  1. docker-entrypoint.sh +24 -30
docker-entrypoint.sh CHANGED
@@ -1,44 +1,38 @@
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 "$@"
 
1
  #!/bin/bash
2
 
3
+ # Docker entrypoint script for RAR extraction service
4
 
5
+ echo "🐳 Starting RAR extraction container..."
6
+ echo "πŸ“ Source Repo: ${SOURCE_REPO}"
7
+ echo "πŸ“‚ Extract Folder: ${EXTRACT_FOLDER}"
8
+ echo "πŸ’Ύ State Folder: ${STATE_FOLDER}"
9
+
10
+ # Check if HF_TOKEN is set
11
  if [ -z "$HF_TOKEN" ]; then
12
+ echo "⚠️ WARNING: HF_TOKEN environment variable is not set"
13
+ echo "πŸ’‘ You may need to set this for private repositories"
14
  fi
15
 
16
+ # Verify unrar is installed
17
+ if ! command -v unrar &> /dev/null; then
18
+ echo "❌ ERROR: unrar is not installed"
19
  exit 1
20
  fi
21
 
22
+ echo "βœ… unrar is available: $(unrar --version | head -1)"
 
 
 
 
 
 
23
 
24
+ # Check directory permissions
25
+ for dir in "$DOWNLOAD_FOLDER" "$EXTRACT_FOLDER" "$STATE_FOLDER"; do
26
+ if [ ! -w "$dir" ]; then
27
+ echo "⚠️ WARNING: Directory $dir is not writable"
28
+ fi
29
+ done
 
30
 
31
+ # Check disk space
32
+ available_space=$(df -h "$EXTRACT_FOLDER" | awk 'NR==2 {print $4}')
33
+ echo "πŸ’Ύ Available disk space: $available_space"
 
34
 
35
+ echo "πŸš€ Starting main application..."
 
 
 
 
36
 
37
+ # Execute the main command
38
  exec "$@"