forked from iRobie/moby-cifs-mount
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
29 lines (24 loc) · 827 Bytes
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#! /bin/sh
# get the shell envs
set -e
# check the the required vars are set
if [ -z "$SERVER" ]; then
echo "SERVER var not set"
exit 1
fi
if [ -z "$MOUNT" ]; then
echo "MOUNT var not set"
exit 1
fi
# use nsenter to enter the docker host so we can mount cifs share host and all containers will have access to the mounted folder
# install required packages and mount the NFS share using env vars $SERVER and $MOUNT
# create the $MOUNT dir if it doesn't exist
# and finally run inotifywait which will output all file folder and file operations so we have some basic logging
nsenter -t 1 -m -u -i -n sh -c " \
apk update && \
apk add inotify-tools && \
mkdir -p $MOUNT && \
(umount $MOUNT || /bin/true) && \
mount -t cifs $SERVER $MOUNT -o $OPTIONS && \
inotifywait -m $MOUNT \
"