comparison scripts/.functions.sh @ 266:b72855a930f1

simplify method of getting project name
author smith@nwoca.org
date Mon, 12 Nov 2018 21:12:31 +0000
parents c3587159637f
children d6d8468441b1
comparison
equal deleted inserted replaced
263:74ba1fec18f3 266:b72855a930f1
32 } 32 }
33 33
34 # finds docker container for specified compose service 34 # finds docker container for specified compose service
35 composeGetContainer() { 35 composeGetContainer() {
36 service=${1?"Must supply service from current project"} 36 service=${1?"Must supply service from current project"}
37
38 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ ) 37 container=$( docker-compose ps | cut -d " " -f 1 -s | grep _${service}_ )
39 echo $container 38 echo $container
40 } 39 }
41 40
42 executeSQL() { 41 executeSQL() {
45 44
46 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME" 45 echo "$2" | docker exec -i $container sh -c "gosu postgres psql \$DB_NAME"
47 } 46 }
48 47
49 composeGetProject() { 48 composeGetProject() {
50 service=${1?"Must supply service from current project"} 49 project=$( docker-compose ps | tail -n1 | cut -d "_" -f 1 -s )
51 container=$(composeGetContainer $service) 50 echo $project
52 echo $(docker inspect -f '{{index .Config.Labels "com.docker.compose.project" }}' $container)
53 } 51 }