Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- Dockerfile +3 -0
- entrypoint.sh +21 -14
Dockerfile
CHANGED
|
@@ -10,6 +10,9 @@ RUN apt-get update && apt-get install -y \
|
|
| 10 |
python3 \
|
| 11 |
rclone \
|
| 12 |
inotify-tools \
|
|
|
|
|
|
|
|
|
|
| 13 |
&& rm -rf /var/lib/apt/lists/*
|
| 14 |
|
| 15 |
# Install File Browser by downloading the binary directly from GitHub releases
|
|
|
|
| 10 |
python3 \
|
| 11 |
rclone \
|
| 12 |
inotify-tools \
|
| 13 |
+
zip \
|
| 14 |
+
unzip \
|
| 15 |
+
wget \
|
| 16 |
&& rm -rf /var/lib/apt/lists/*
|
| 17 |
|
| 18 |
# Install File Browser by downloading the binary directly from GitHub releases
|
entrypoint.sh
CHANGED
|
@@ -62,25 +62,32 @@ touch "$DB_PATH"
|
|
| 62 |
echo "Checking for persistent database on Google Drive..."
|
| 63 |
rclone copyto "$REMOTE_PATH/.filebrowser.db" "$DB_PATH" --config "$CONFIG_PATH" --drive-skip-shortcuts --drive-acknowledge-abuse $SHARED_FLAG || true
|
| 64 |
|
| 65 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
if [ -n "$FILEBROWSER_PASSWORD" ]; then
|
| 67 |
echo "FILEBROWSER_PASSWORD secret is set. Configuring admin password..."
|
| 68 |
-
|
| 69 |
-
# Initialize config if export fails (e.g. database doesn't exist or is empty)
|
| 70 |
-
if ! filebrowser config export -d "$DB_PATH" >/dev/null 2>&1; then
|
| 71 |
-
echo "Initializing database..."
|
| 72 |
-
filebrowser config init -d "$DB_PATH"
|
| 73 |
-
filebrowser config set --root "$DATA_DIR" -d "$DB_PATH"
|
| 74 |
-
fi
|
| 75 |
-
|
| 76 |
-
# Set or update the admin user password
|
| 77 |
echo "Setting admin user password..."
|
| 78 |
-
if filebrowser users update admin --password "$FILEBROWSER_PASSWORD" -d "$DB_PATH" >/dev/null 2>&1; then
|
| 79 |
-
echo "Admin password updated successfully."
|
| 80 |
else
|
| 81 |
-
echo "Admin user not found. Creating admin user..."
|
| 82 |
-
filebrowser users add admin "$FILEBROWSER_PASSWORD" --perm.admin -d "$DB_PATH"
|
| 83 |
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
fi
|
| 85 |
|
| 86 |
# 2. Download files from Google Drive to local /data directory
|
|
|
|
| 62 |
echo "Checking for persistent database on Google Drive..."
|
| 63 |
rclone copyto "$REMOTE_PATH/.filebrowser.db" "$DB_PATH" --config "$CONFIG_PATH" --drive-skip-shortcuts --drive-acknowledge-abuse $SHARED_FLAG || true
|
| 64 |
|
| 65 |
+
# Initialize config if export fails (e.g. database doesn't exist or is empty)
|
| 66 |
+
if ! filebrowser config export -d "$DB_PATH" >/dev/null 2>&1; then
|
| 67 |
+
echo "Initializing database..."
|
| 68 |
+
filebrowser config init -d "$DB_PATH"
|
| 69 |
+
filebrowser config set --root "$DATA_DIR" -d "$DB_PATH"
|
| 70 |
+
fi
|
| 71 |
+
|
| 72 |
+
# Enable Command Runner (shell execution) globally
|
| 73 |
+
echo "Enabling Command Runner globally..."
|
| 74 |
+
filebrowser config set --disable-exec=false --commands "zip,unzip,wget,curl,ls" -d "$DB_PATH"
|
| 75 |
+
|
| 76 |
+
# Configure admin password and execution permissions via FILEBROWSER_PASSWORD secret if set
|
| 77 |
if [ -n "$FILEBROWSER_PASSWORD" ]; then
|
| 78 |
echo "FILEBROWSER_PASSWORD secret is set. Configuring admin password..."
|
| 79 |
+
# Set or update the admin user password and execution permissions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
echo "Setting admin user password..."
|
| 81 |
+
if filebrowser users update admin --password "$FILEBROWSER_PASSWORD" --commands "zip,unzip,wget,curl,ls" --perm.execute=true -d "$DB_PATH" >/dev/null 2>&1; then
|
| 82 |
+
echo "Admin password and permissions updated successfully."
|
| 83 |
else
|
| 84 |
+
echo "Admin user not found. Creating admin user with custom password..."
|
| 85 |
+
filebrowser users add admin "$FILEBROWSER_PASSWORD" --perm.admin --perm.execute=true --commands "zip,unzip,wget,curl,ls" -d "$DB_PATH"
|
| 86 |
fi
|
| 87 |
+
else
|
| 88 |
+
# Even if password secret is not set, ensure default admin has execute permissions
|
| 89 |
+
echo "Updating default admin user commands and permissions..."
|
| 90 |
+
filebrowser users update admin --commands "zip,unzip,wget,curl,ls" --perm.execute=true -d "$DB_PATH" || true
|
| 91 |
fi
|
| 92 |
|
| 93 |
# 2. Download files from Google Drive to local /data directory
|