Created
November 16, 2019 17:29
-
-
Save iomarmochtar/0c01f00c1fe0c02561fe414f47ce02b1 to your computer and use it in GitHub Desktop.
Simple script to start & stop pgadmin4 container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Author: Imam Omar Mochtar ([email protected]) | |
## Func: Simple script to start and stop pgadmin4 container | |
[email protected] | |
PASSWORD=kacangitem | |
PORT=8787 | |
IMAGE="dpage/pgadmin4" | |
CONTAINER="omr_pgadmin4" | |
isAlreadyExist(){ | |
docker ps -a | grep $CONTAINER > /dev/null | |
return $? | |
} | |
init(){ | |
docker run --name $CONTAINER \ | |
-p 127.0.0.1:$PORT:80 \ | |
-e "PGADMIN_DEFAULT_EMAIL=$USERNAME" \ | |
-e "PGADMIN_DEFAULT_PASSWORD=$PASSWORD" \ | |
-d $IMAGE | |
} | |
start(){ | |
if isAlreadyExist; then | |
docker start $CONTAINER | |
else | |
init | |
fi | |
} | |
stop(){ | |
docker stop $CONTAINER | |
} | |
status(){ | |
docker ps | grep $CONTAINER > /dev/null | |
if [ $? == 0 ]; then | |
echo "Running" | |
else | |
echo "Stopped" | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Uknown option $1" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment