diff --git a/webdav-rclone-sidecar/README.md b/webdav-rclone-sidecar/README.md index 58f8207..9953ec6 100644 --- a/webdav-rclone-sidecar/README.md +++ b/webdav-rclone-sidecar/README.md @@ -13,16 +13,20 @@ Using environment: * WEBDAV\_VENDOR: WebDAV vendor (default: *other*) * MOUNT\_OPTS: space separated additional arguments for *rclone mount* command * MOUNT\_PATH: mount path (default: */mnt*) +* MOUNT\_WAIT: wait time for mountpoint in /proc/mounts (default: *20*) +* MOUNT\_WAIT\_POINT: mountpoint regular expression to wait for (default: (empty)) * VFS\_CACHE\_MODE: value for rclone VFS cache mode (off, minimal, writes, full) (default: *full*) Examples: - docker run --privileged -it --rm --name oidcmount -v /tmp/webdav:/mnt:shared + docker run --privileged -it --rm --name oidcmount -v /tmp/webdav:/mnt:shared \ -e WEBDAV_URL="$WEBDAV_URL" \ -e WEBDAV_TOKEN="$(oidc-token my-issuer)" \ webdav-rclone-sidecar" & echo "$(oidc-token my-issuer)" >/tmp/token - docker run --privileged -it --rm --name oidcmount -v /tmp/webdav:/mnt:shared -v /tmp/token:/tmp/token + docker run --privileged -it --rm --name oidcmount -v /tmp/webdav:/mnt:shared -v /tmp/token:/tmp/token \ + -e MOUNT_PATH="/mnt/subpath" \ + -e MOUNT_WAIT_POINT="webdav-fs: /mnt fuse.rclone " \ -e WEBDAV_URL="$WEBDAV_URL" \ webdav-rclone-sidecar bearer_token_command="cat /tmp/token" & diff --git a/webdav-rclone-sidecar/mount.sh b/webdav-rclone-sidecar/mount.sh index b9d0532..7a7bcd2 100755 --- a/webdav-rclone-sidecar/mount.sh +++ b/webdav-rclone-sidecar/mount.sh @@ -5,10 +5,21 @@ MOUNT_OPTS=${MOUNT_OPTS:-} # where to mount MOUNT_PATH=${MOUNT_PATH:-/mnt/} +MOUNT_WAIT=${MOUNT_WAIT:-20} JOVYAN_UID=${JOVYAN_UID:-1000} JOVYAN_GRP=${JOVYAN_GRP:-100} VFS_CACHE_MODE=${VFS_CACHE_MODE:-full} +if [ -n "$MOUNT_WAIT_POINT" ]; then + i=0 + echo "Checking $MOUNT_WAIT_POINT ($MOUNT_PATH)..." + while ! grep "^$MOUNT_WAIT_POINT" /proc/mounts && test $i -lt $((2 * MOUNT_WAIT)); do + echo "Waiting for $MOUNT_WAIT_POINT..." + sleep 0.5 + i=$((i + 1)) + done +fi + if [ ! -d "$MOUNT_PATH" ]; then mkdir -p "$MOUNT_PATH" chown "$JOVYAN_UID:$JOVYAN_GRP" "$MOUNT_PATH"