Created
February 6, 2019 08:34
-
-
Save matteopic/c0ff19be890bbf26c7157e8aa1a0f2c4 to your computer and use it in GitHub Desktop.
pgadmin container
This file contains 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 | |
imageName=dpage/pgadmin4 | |
containerName=pgadmin4 | |
function start(){ | |
count=$(docker ps --all --filter "name=${containerName}" | tail -n+2 | wc -l) | |
if [ "$count" -eq "1" ]; | |
then | |
echo "Resuming ${containerName}" | |
docker start $containerName | |
else | |
echo "Starting ${containerName}" | |
docker run --name="$containerName" \ | |
-d \ | |
-p 80:80 \ | |
-e "[email protected]" \ | |
-e "PGADMIN_DEFAULT_PASSWORD=mypassword" \ | |
-v "/home/matteopic/pgadmin/servers.json:/pgadmin4/servers.json" \ | |
$imageName | |
fi | |
} | |
function shell(){ | |
docker exec -it "$containerName" /bin/sh | |
} | |
function stop(){ | |
docker stop "$containerName" | |
if [ "$1" == "--clean" ]; | |
then | |
echo "Removing $containerName" | |
docker rm $containerName | |
fi | |
} | |
function rebuild(){ | |
# echo not supported | |
# mkdir -p tenants/$tenant | |
# scp -r 192.168.231.55:/opt/smart-platform/smart-www/assets/smart-assets/$tenant/* tenants/$tenant | |
docker rm $containerName | |
docker rmi $imageName | |
# docker build --tag="$imageName" --build-arg TENANT=$tenant . | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
shift | |
stop $@ | |
;; | |
restart) | |
stop | |
start | |
;; | |
shell) | |
shell | |
;; | |
rebuild) | |
rebuild | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|restart|shell|rebuild}" | |
exit 1 | |
;; | |
esac | |
This file contains 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
{ | |
"Servers": { | |
"1": { | |
"Name": "192.168.X.X", | |
"Group": "Servers", | |
"Host": "192.168.X.X", | |
"Port": 5432, | |
"MaintenanceDB": "postgres", | |
"Username": "postgres", | |
"SSLMode": "prefer", | |
"SSLCert": "<STORAGE_DIR>/.postgresql/postgresql.crt", | |
"SSLKey": "<STORAGE_DIR>/.postgresql/postgresql.key", | |
"SSLCompression": 0, | |
"Timeout": 0, | |
"UseSSHTunnel": 0, | |
"TunnelPort": "22", | |
"TunnelAuthentication": 0 | |
}, | |
"2": { | |
"Name": "192.168.Y.Y", | |
"Group": "Servers", | |
"Host": "192.168.Y.Y", | |
"Port": 5432, | |
"MaintenanceDB": "postgres", | |
"Username": "postgres", | |
"SSLMode": "prefer", | |
"SSLCert": "<STORAGE_DIR>/.postgresql/postgresql.crt", | |
"SSLKey": "<STORAGE_DIR>/.postgresql/postgresql.key", | |
"SSLCompression": 0, | |
"Timeout": 0, | |
"UseSSHTunnel": 0, | |
"TunnelPort": "22", | |
"TunnelAuthentication": 0 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment