-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetpath.sh
executable file
·40 lines (30 loc) · 949 Bytes
/
getpath.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
37
38
39
40
#!/bin/bash
# This script essentially asks for a directory path for the GET call to run with
# I am assuming the user already has docker downloaded and we do a quick cleanup after
echo "Hi there! Please provide a valid absolute directory path for me to use."
read pathName
if [[ ! -e $pathName ]]
then
echo "That path does not exist"
exit 1
fi
if [[ $pathName == "."* ]]
then
echo "Cannot accept any '.'s in input"
exit 1
fi
echo "To confirm, your path is $pathName"
# If dircontainer container exists, remove it.
existing_app_container=`docker ps -a | grep dircontainer | wc -l`
if [ $existing_app_container -gt "0" ]
then
docker rm -f dircontainer
fi
# If image for dircontainer exists, remove it.
existing_app_image=`docker images | grep dirimage | wc -l`
if [ $existing_app_image -gt "0" ]
then
docker rmi -f dirimage
fi
docker build -t dirimage .
docker run --name dircontainer -v $pathName:/mnt/mydata -p 80:80 dirimage