jualhosting commited on
Commit
9b5dfdf
·
verified ·
1 Parent(s): 43b324c

Upload 4 files

Browse files
Files changed (2) hide show
  1. Dockerfile +5 -2
  2. entrypoint.sh +16 -6
Dockerfile CHANGED
@@ -12,8 +12,11 @@ RUN apt-get update && apt-get install -y \
12
  inotify-tools \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Install File Browser using the official script
16
- RUN curl -fsSL https://raw.githubusercontent.com/filebrowser/filebrowser/master/get.sh | bash
 
 
 
17
 
18
  # Create a non-root user matching Hugging Face Space UID (1000)
19
  RUN useradd -m -u 1000 user && \
 
12
  inotify-tools \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Install File Browser by downloading the binary directly from GitHub releases
16
+ RUN curl -fsSL https://github.com/filebrowser/filebrowser/releases/download/v2.32.0/linux-amd64-filebrowser.tar.gz -o filebrowser.tar.gz && \
17
+ tar -xzf filebrowser.tar.gz && \
18
+ mv filebrowser /usr/bin/ && \
19
+ rm filebrowser.tar.gz LICENSE README.md
20
 
21
  # Create a non-root user matching Hugging Face Space UID (1000)
22
  RUN useradd -m -u 1000 user && \
entrypoint.sh CHANGED
@@ -17,22 +17,34 @@ fi
17
  echo "$RCLONE_CONFIG_DATA" > "$CONFIG_PATH"
18
  chmod 600 "$CONFIG_PATH"
19
 
20
- # Extract the remote name from rclone.conf dynamically (the first section name)
21
- REMOTE_NAME=$(grep -oE '^\[[^\]]+\]' "$CONFIG_PATH" | head -n 1 | tr -d '[]')
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
  if [ -z "$REMOTE_NAME" ]; then
24
  echo "Failed to parse remote name from rclone config. Using fallback 'gdrive'."
25
  REMOTE_NAME="gdrive"
26
  fi
27
 
28
- echo "Detected remote name: $REMOTE_NAME"
29
 
30
  # Ensure SQLite database file exists so inotifywait can monitor it
31
  touch "$DB_PATH"
32
 
33
  # 1. Download database from Google Drive if it exists
34
  echo "Checking for persistent database on Google Drive..."
35
- rclone copy "$REMOTE_NAME:.filebrowser.db" "/tmp/" --config "$CONFIG_PATH" || true
36
 
37
  # 2. Download files from Google Drive to local /data directory
38
  echo "Syncing files from Google Drive..."
@@ -65,6 +77,4 @@ rclone sync "$REMOTE_NAME:" "$DATA_DIR" --config "$CONFIG_PATH" || true
65
 
66
  # 4. Start File Browser
67
  echo "Starting File Browser on port 7860..."
68
- # File Browser will run in the foreground. Default credentials are admin / admin.
69
- # Make sure to change your password after logging in.
70
  filebrowser --port 7860 --address 0.0.0.0 --database "$DB_PATH" --root "$DATA_DIR"
 
17
  echo "$RCLONE_CONFIG_DATA" > "$CONFIG_PATH"
18
  chmod 600 "$CONFIG_PATH"
19
 
20
+ # Extract the remote name dynamically using Python (robust against newlines and spaces)
21
+ REMOTE_NAME=$(python3 -c "
22
+ import configparser
23
+ config = configparser.ConfigParser()
24
+ try:
25
+ config.read('$CONFIG_PATH')
26
+ sections = config.sections()
27
+ if sections:
28
+ print(sections[0].strip())
29
+ else:
30
+ print('')
31
+ except Exception:
32
+ print('')
33
+ ")
34
 
35
  if [ -z "$REMOTE_NAME" ]; then
36
  echo "Failed to parse remote name from rclone config. Using fallback 'gdrive'."
37
  REMOTE_NAME="gdrive"
38
  fi
39
 
40
+ echo "Detected remote name: '$REMOTE_NAME'"
41
 
42
  # Ensure SQLite database file exists so inotifywait can monitor it
43
  touch "$DB_PATH"
44
 
45
  # 1. Download database from Google Drive if it exists
46
  echo "Checking for persistent database on Google Drive..."
47
+ rclone copyto "$REMOTE_NAME:.filebrowser.db" "$DB_PATH" --config "$CONFIG_PATH" || true
48
 
49
  # 2. Download files from Google Drive to local /data directory
50
  echo "Syncing files from Google Drive..."
 
77
 
78
  # 4. Start File Browser
79
  echo "Starting File Browser on port 7860..."
 
 
80
  filebrowser --port 7860 --address 0.0.0.0 --database "$DB_PATH" --root "$DATA_DIR"