comparison docker/libervia_cont.sh @ 26:a5e4c6c2a37d

docker: replaces tabs by spaces, download first app containers then data container + minor changes
author Goffi <goffi@goffi.org>
date Mon, 20 Oct 2014 16:50:12 +0200
parents 25b7452c2d5a
children 9ca1e7fe0f87
comparison
equal deleted inserted replaced
25:25b7452c2d5a 26:a5e4c6c2a37d
49 49
50 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en" 50 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en"
51 HELP_MUC="sat@chat.jabberfr.org" 51 HELP_MUC="sat@chat.jabberfr.org"
52 52
53 get_dyn_var() { 53 get_dyn_var() {
54 # get dynamicly variable based on given name 54 # get dynamicly variable based on given name
55 55
56 name=$1 56 name=$1
57 var_type=$2 57 var_type=$2
58 name_upp=$(echo "$name" | tr '[:lower:]' '[:upper:]') 58 name_upp=$(echo "$name" | tr '[:lower:]' '[:upper:]')
59 case $var_type in 59 case $var_type in
61 port_name) eval echo $(echo "\$PORT_${name_upp}_NAME");; 61 port_name) eval echo $(echo "\$PORT_${name_upp}_NAME");;
62 esac 62 esac
63 } 63 }
64 64
65 list_ports() { 65 list_ports() {
66 # list used ports in currently running containers 66 # list used ports in currently running containers
67 67
68 for cont in $CONTAINERS; do 68 for cont in $CONTAINERS; do
69 # we get variable name with uppercase container name 69 # we get variable name with uppercase container name
70 # some magic to get the ports 70 # some magic to get the ports
71 ports=$(get_dyn_var $cont ports) 71 ports=$(get_dyn_var $cont ports)
92 [ -n "$ports" ] && printf '\n' 92 [ -n "$ports" ] && printf '\n'
93 done 93 done
94 } 94 }
95 95
96 public_ports_arg() { 96 public_ports_arg() {
97 # create Docker arg to have public ports corresponding to container ports 97 # create Docker arg to have public ports corresponding to container ports
98 98
99 if [ $PUBLIC -ne 1 ]; then 99 if [ $PUBLIC -ne 1 ]; then
100 return 100 return
101 fi 101 fi
102 cont=$1 102 cont=$1
107 done 107 done
108 echo $ARG 108 echo $ARG
109 } 109 }
110 110
111 download_missing() { 111 download_missing() {
112 # download images wich are not present locally 112 # download images wich are not present locally
113 for cont in $VOLUME_NAME $CONTAINERS; do 113 for cont in $CONTAINERS $VOLUME_NAME; do
114 image="$ACCOUNT/$cont" 114 image="$ACCOUNT/$cont"
115 docker inspect $image:latest > /dev/null 2>&1 115 docker inspect $image:latest > /dev/null 2>&1
116 if [ $? -ne 0 ]; then 116 if [ $? -ne 0 ]; then
117 printf "$image is not present locally, downloading it\n" 117 printf "$image is not present locally, downloading it\n"
118 docker pull $image:latest 118 docker pull $image:latest
119 if [ $? -eq 0 ]; then 119 if [ $? -eq 0 ]; then
120 printf "\nDownload of latest $image finished\n\n" 120 printf "\nDownload of latest $image finished\n\n"
121 else 121 else
122 printf "\nError while downloading $image, please check your connection and logs\n" 122 printf "\nError while downloading $image, please check your connection and logs\n"
123 return 1 123 return 1
124 fi 124 fi
125 fi 125 fi
126 done 126 done
127 } 127 }
128 128
129 check_docker() { 129 check_docker() {
130 which $DOCKER_EXE > /dev/null 2>&1 130 which $DOCKER_EXE > /dev/null 2>&1
131 if [ $? -ne 0 ]; then 131 if [ $? -ne 0 ]; then
132 printf "Docker is not installed or not accessible, please install it.\nYou can check http://wiki.goffi.org/wiki/Docker/en for instructions\n" 132 printf "Docker is not installed or not accessible, please install it.\nYou can check http://wiki.goffi.org/wiki/Docker/en for instructions\n"
133 return 1 133 return 1
134 fi 134 fi
135 } 135 }
136 136
137 parse_run_args() { 137 parse_run_args() {
138 # manage arguments for run command 138 # manage arguments for run command
139 139
140 while [ $# -gt 0 ]; do 140 while [ $# -gt 0 ]; do
141 case "$1" in 141 case "$1" in
142 142
143 -h|--help) 143 -h|--help)
180 run) CMD=RUN;; 180 run) CMD=RUN;;
181 stop) CMD=STOP;; 181 stop) CMD=STOP;;
182 update) CMD=UPDATE;; 182 update) CMD=UPDATE;;
183 backup) CMD=BACKUP;; 183 backup) CMD=BACKUP;;
184 ports) CMD=PORTS;; 184 ports) CMD=PORTS;;
185 -v|--version) printf "$VERSION\n"; exit 0;; 185 -v|--version) printf "$VERSION\n"; exit 0;;
186 -h|--help) printf "$USAGE\n\nYou can check $HELP_SITE for instructions, or go to $HELP_MUC XMPP MUC room for help\n"; exit 0;; 186 -h|--help) printf "$USAGE\n\nYou can check $HELP_SITE for instructions, or go to $HELP_MUC XMPP MUC room for help\n"; exit 0;;
187 *) echo $USAGE 187 *) echo $USAGE
188 exit 1 188 exit 1
189 esac 189 esac
190 shift 190 shift
191 else 191 else
232 printf "Error, please check container or ask help on XMPP MUC sat@chat.jabberfr.org\nerror message: $docker_id\n" 232 printf "Error, please check container or ask help on XMPP MUC sat@chat.jabberfr.org\nerror message: $docker_id\n"
233 printf "Abandon\n" 233 printf "Abandon\n"
234 exit 1 234 exit 1
235 fi 235 fi
236 done 236 done
237 printf '\nLibervia is launched and should be reachable in a couple of seconds.\nYou can check logs with "docker logs libervia" (or any other container name)\n' 237 printf '\nLibervia is launched and should be reachable in a couple of seconds.\nYou can check logs with "docker logs libervia" (or any other container name).\n'
238 printf "An \"admin\" account has been created, you can check its password on $VOLUME_ALIAS container, in file /home/sat/ADMIN_PWD. Config can be tuned on this container\n" 238 printf "An \"admin\" account has been created, you can check its password on $VOLUME_ALIAS container, in file /home/sat/ADMIN_PWD. Config can be tuned on this container.\n"
239 printf 'Below are the ports used to connect, you can go with your browser to Libervia HTTP port\n\n' 239 printf 'Below are the ports used to connect, you can go with your browser to Libervia HTTP port.\n\n'
240 list_ports 240 list_ports
241 ;; 241 ;;
242 STOP) 242 STOP)
243 printf "stopping Libervia\n" 243 printf "stopping Libervia\n"
244 REVERSED="" 244 REVERSED=""