Skip to content

Commit

Permalink
Wait for the other mounts, if needed - for remote parent directory
Browse files Browse the repository at this point in the history
  • Loading branch information
valtri committed Jul 11, 2024
1 parent b94a3ef commit 3b20948
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions webdav-rclone-sidecar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 regex 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" &
11 changes: 11 additions & 0 deletions webdav-rclone-sidecar/mount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 3b20948

Please sign in to comment.