-
Notifications
You must be signed in to change notification settings - Fork 1
/
gapi.sh
executable file
·42 lines (38 loc) · 1.35 KB
/
gapi.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
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #"
GAPI_ID=$(docker ps -a | grep piraticz/gapi | awk '{print $1}')
function start_gapi {
echo "Running GAPI container ..."
GAPI_CMD="docker run -t -p 8008:8008 -v $DIR/app:/home/app --name gapi -d piraticz/gapi"
echo $GAPI_CMD
GAPI_ID=$($GAPI_CMD)
}
case "$1" in
start)
if [ -z "$GAPI_ID" ]; then
start_gapi;
else
docker start $GAPI_ID;
IP="$( docker inspect $(docker ps -a | grep "piraticz/gapi:latest" | awk '{ print $1 }') | grep IPAddress | sed -r "s/[\" a-zA-Z:,]//g" )"
echo "IP: $IP"
fi
;;
stop)
if [ -z "$GAPI_ID" ]; then echo "GAPI container no exists, run $0 start"; else docker stop $GAPI_ID; fi
;;
restart)
if [ -z "$GAPI_ID" ]; then echo "GAPI container no exists, run $0 start"; else docker restart $GAPI_ID; fi
;;
status)
if [ -z $GAPI_ID ] ; then
echo "GAPI not running..."
else
docker ps -a | grep 'CONTAINER\|piraticz/gapi'
IP="$( docker inspect $(docker ps -a | grep "piraticz/gapi:latest" | awk '{ print $1 }') | grep IPAddress | sed -r "s/[\" a-zA-Z:,]//g" )"
echo "IP: $IP"
fi
;;
*)
echo -e "\nUsage: $0 {start|stop|restart|status}\n"
;;
esac