Skip to content

Commit 8b184eb

Browse files
fix(filebrowser): configure before running (#400)
Fixes #399 Instead of trying to cram the config into one command we check if the db exists, if not initialize it then configure the various values before starting the app. --------- Co-authored-by: M Atif Ali <[email protected]>
1 parent 3caf1b2 commit 8b184eb

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

filebrowser/run.sh

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
BOLD='\033[0;1m'
3+
BOLD='\033[[0;1m'
44

55
printf "$${BOLD}Installing filebrowser \n\n"
66

@@ -11,20 +11,27 @@ fi
1111

1212
printf "🥳 Installation complete! \n\n"
1313

14-
printf "👷 Starting filebrowser in background... \n\n"
14+
printf "🛠️ Configuring filebrowser \n\n"
1515

1616
ROOT_DIR=${FOLDER}
1717
ROOT_DIR=$${ROOT_DIR/\~/$HOME}
1818

19-
DB_FLAG=""
20-
if [ "${DB_PATH}" != "filebrowser.db" ]; then
21-
DB_FLAG=" -d ${DB_PATH}"
19+
echo "DB_PATH: ${DB_PATH}"
20+
21+
export FB_DATABASE="${DB_PATH}"
22+
23+
# Check if filebrowser db exists
24+
if [[ ! -f "${DB_PATH}" ]]; then
25+
filebrowser config init 2>&1 | tee -a ${LOG_PATH}
26+
filebrowser users add admin "" --perm.admin=true --viewMode=mosaic 2>&1 | tee -a ${LOG_PATH}
2227
fi
2328

24-
printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
29+
filebrowser config set --baseurl=${SERVER_BASE_PATH} --port=${PORT} --auth.method=noauth --root=$ROOT_DIR 2>&1 | tee -a ${LOG_PATH}
2530

26-
printf "Running 'filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} --baseurl ${SERVER_BASE_PATH}' \n\n"
31+
printf "👷 Starting filebrowser in background... \n\n"
32+
33+
printf "📂 Serving $${ROOT_DIR} at http://localhost:${PORT} \n\n"
2734

28-
filebrowser --noauth --root $ROOT_DIR --port ${PORT}$${DB_FLAG} --baseurl ${SERVER_BASE_PATH} > ${LOG_PATH} 2>&1 &
35+
filebrowser >> ${LOG_PATH} 2>&1 &
2936

3037
printf "📝 Logs at ${LOG_PATH} \n\n"

0 commit comments

Comments
 (0)