-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_file_created.sh
53 lines (42 loc) · 1.27 KB
/
check_file_created.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
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
while true
do
dir=$(inotifywait -r -e create,modify /home/ubuntu)
echo "the dirname is"
echo $dir
folderName=${dir#"/home/ubuntu/ CREATE,ISDIR "}
echo "The folderName is"$folderName
type=${dir#"/home/ubuntu/ "}
type=${type%",ISDIR "}
echo "the type is "$type
done
if type=="CREATE"
then
sudo docker build -t $folderName --build-arg fileName=$folderName .
sudo docker tag $folderName ecmithun/$folderName
sudo docker login -u "ecmithun" -p "mithun@1234" docker.io
sudo docker push ecmithun/$folderName
elif type=="MODIFY"
then
sudo docker build -t $folderName:latest --build-arg fileName=$folderName .
sudo docker tag $folderName ecmithun/$folderName:latest
sudo docker login -u "ecmithun" -p "mithun@1234" docker.io
sudo docker push ecmithun/$folderName:latest
fi
FROM nginx
ARG fileName
RUN echo $fileName
ADD $fileName/ /usr/share/nginx/html
while true
do
dir=$(inotifywait -r -e create /home/ubuntu)
echo "the dirname is"
echo $dir
folderName=${dir#"/home/ubuntu/ CREATE,ISDIR "}
echo "the dirname is"$folderName
cp $folderName -r /tmp
sudo docker build -t $folderName --build-arg fileName=$folderName .
sudo docker tag $folderName ecmithun/automation:$folderName
sudo docker login -u "ecmithun" -p "mithun@1234" docker.io
sudo docker push ecmithun/automation:$folderName
done