Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 35 additions & 4 deletions registry/coder/modules/filebrowser/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,44 @@ echo "DB_PATH: ${DB_PATH}"

export FB_DATABASE="${DB_PATH}"

# Check if filebrowser db exists
if PID="$(pgrep -x filebrowser)"; then
echo "File Browser is already running (PID: $${PID})"

# Show which database the running process is using.
RUNNING_DB="$(tr '\0' '\n' < /proc/$${PID}/environ | grep '^FB_DATABASE=' | cut -d= -f2- || true)"

echo "Running database: $${RUNNING_DB}"

if [[ "$${RUNNING_DB}" == "${DB_PATH}" ]]; then
echo "Existing File Browser already uses ${DB_PATH}."
echo "Skipping configuration and startup."

exit 0
fi

echo "A File Browser process is already running but is using another database."
echo "Continuing..."
fi

if [[ ! -f "${DB_PATH}" ]]; then
filebrowser config init 2>&1 | tee -a ${LOG_PATH}
filebrowser users add admin "coderPASSWORD" --perm.admin=true --viewMode=mosaic 2>&1 | tee -a ${LOG_PATH}
echo "Initializing File Browser database..."

filebrowser config init 2>&1 | tee -a "${LOG_PATH}"

filebrowser users add \
admin \
"coderPASSWORD" \
--perm.admin=true \
--viewMode=mosaic \
2>&1 | tee -a "${LOG_PATH}"
fi

filebrowser config set --baseURL=${SERVER_BASE_PATH} --port=${PORT} --auth.method=noauth --root=$ROOT_DIR 2>&1 | tee -a ${LOG_PATH}
filebrowser config set \
--baseURL="${SERVER_BASE_PATH}" \
--port="${PORT}" \
--auth.method=noauth \
--root="$${ROOT_DIR}" \
2>&1 | tee -a "${LOG_PATH}"

printf "👷 Starting filebrowser in background... \n\n"

Expand Down