forked from brycekottke/cifs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount.sh
executable file
·36 lines (29 loc) · 985 Bytes
/
mount.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
30
31
32
33
34
35
36
#!/bin/bash
CONTAINER_NAME=cifs-docker
CIFS_PATH=//X.X.X.X/data
CIFS_USER=user
CIFS_PASS=pass
CIFS_MOUNT_DIR=/tmp/cifs
CIFS_SHARE_DIR=/tmp/win_share
docker run -d -v $CIFS_MOUNT_DIR:/tmp/coreos-tmp --name $CONTAINER_NAME brycekottke/$CONTAINER_NAME
ls -l $CIFS_SHARE_DIR
if [ $? -eq "0" ]; then
echo "$CIFS_SHARE_DIR already exist's"
else
echo "creating $CIFS_SHARE_DIR directory..."
mkdir -p $CIFS_SHARE_DIR
fi
echo "mounting cifs to $CIFS_PATH to $CIFS_SHARE_DIR"
sudo $CIFS_MOUNT_DIR/mount.cifs $CIFS_PATH $CIFS_SHARE_DIR -o username=$CIFS_USER,password=$CIFS_PASS
if [ $? -eq "0" ]; then
echo "SUCCESSFULLY MOUNTED $CIFS_PATH TO $CIFS_SHARE_DIR"
sleep 2
echo "Now Stopping $CONTAINER_NAME container, Please Wait..."
docker stop $CONTAINER_NAME
sleep 2
echo "Removing $CONTAINER_NAME container, no longer needed..."
docker rm $CONTAINER_NAME
sleep 2
else
echo "FAILED TO MOUNT $CIFS_PATH TO $CIFS_SHARE_DIR"
fi