Mercurial > sat_docs
annotate docker/libervia_cont.sh @ 88:f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 19 Feb 2016 13:35:25 +0100 |
parents | 53a579906c32 |
children | 09099ce530da |
rev | line source |
---|---|
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
1 #!/bin/sh |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
2 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
3 # Libervia container manager |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
4 # Copyright (C) 2014-2016 Jérôme Poisson (goffi@goffi.org) |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
5 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
6 # This program is free software: you can redistribute it and/or modify |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
7 # it under the terms of the GNU Affero General Public License as published by |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
8 # the Free Software Foundation, either version 3 of the License, or |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
9 # (at your option) any later version. |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
10 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
11 # This program is distributed in the hope that it will be useful, |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
14 # GNU Affero General Public License for more details. |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
15 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
16 # You should have received a copy of the GNU Affero General Public License |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
18 |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
19 VERSION="0.3.0" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
20 ACCOUNT="salutatoi" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
21 |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
22 # environment variables that can be used for configuration: |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
23 # SAT_CONT_TLS_DIR for TLS certificates directory |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
24 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
25 CONTAINERS="prosody sat_pubsub salut sat libervia" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
26 |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
27 DK_DETACH="-d" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
28 DK_TERM="-ti" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
29 |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
30 VOLUME_NAME="data" |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
31 VOLUME_CONT="$ACCOUNT/$VOLUME_NAME" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 VOLUME_ALIAS="sat_data" |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
33 DK_VOLUME="--volumes-from $VOLUME_ALIAS" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 PUBLIC=0 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 PROSODY_PORTS="5222 5269" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 PORT_5222_NAME="XMPP client to server" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 PORT_5269_NAME="XMPP server to server" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 SAT_PORTS="10143 10125 28915" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 PORT_10143_NAME="IMAP server" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 PORT_10125_NAME="SMTP server" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 PORT_28915_NAME="XMPP file transfer" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 LIBERVIA_PORTS="8080 8443" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 PORT_8080_NAME="HTTP" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 PORT_8443_NAME="HTTPS" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 NO_PORT="No public port" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
49 DOCKER_EXE="docker" |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
50 |
87
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
51 USAGE="Usage: $0 [start|stop|restart|update|backup|restore|ports|config] [ARGS...]" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 HELP_SITE="http://wiki.goffi.org/wiki/Docker/en" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 HELP_MUC="sat@chat.jabberfr.org" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
56 CONT_CERT_DIR="/usr/share/sat/certificates" |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
57 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
58 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 get_dyn_var() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
60 # get dynamicly variable based on given name |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 name=$1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 var_type=$2 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 name_upp=$(echo "$name" | tr '[:lower:]' '[:upper:]') |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 case $var_type in |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 ports) eval echo $(echo "\$${name_upp}_PORTS");; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 port_name) eval echo $(echo "\$PORT_${name_upp}_NAME");; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 esac |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 } |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 list_ports() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
72 # list used ports in currently running containers |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
73 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 for cont in $CONTAINERS; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
75 # we get variable name with uppercase container name |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
76 # some magic to get the ports |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
77 ports=$(get_dyn_var $cont ports) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
78 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 [ -n "$ports" ] && printf "== $cont ==\n\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 for port in $ports; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 # some magic to get port human readable name |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 port_name=$(get_dyn_var $port port_name) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 real_port=$(docker port $cont $port 2>&1) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 if [ $? -ne 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 real_port=$NO_PORT |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 # we now show the ports with nice alignment |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 desc="port $port ($port_name):" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 nb_tabs=$((5-${#desc}/8)) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 printf "$desc" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 for i in $(seq $nb_tabs); do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 printf "\t" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
96 printf "$real_port\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
97 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 [ -n "$ports" ] && printf '\n' |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
99 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 } |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 public_ports_arg() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
103 # create Docker arg to have public ports corresponding to container ports |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 if [ $PUBLIC -ne 1 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 return |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 cont=$1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 ports=$(get_dyn_var $cont ports) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 ARG="" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 for port in $ports; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 ARG="$ARG -p $port:$port" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 echo $ARG |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
115 } |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
117 download_missing() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
118 # download images wich are not present locally |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
119 for cont in $CONTAINERS $VOLUME_NAME; do |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
120 image="$ACCOUNT/$cont" |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
121 docker inspect $image:latest > /dev/null 2>&1 |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
122 if [ $? -ne 0 ]; then |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
123 printf "$image is not present locally, downloading it\n" |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
124 docker pull $image:latest |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
125 if [ $? -eq 0 ]; then |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
126 printf "\nDownload of latest $image finished\n\n" |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
127 else |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
128 printf "\nError while downloading $image, please check your connection and logs\n" |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
129 return 1 |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
130 fi |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
131 fi |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
132 done |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
133 } |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
134 |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
135 check_docker() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
136 which $DOCKER_EXE > /dev/null 2>&1 |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
137 if [ $? -ne 0 ]; then |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
138 printf "Docker is not installed or not accessible, please install it.\nYou can check $HELP_SITE for instructions\n" |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
139 return 1 |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
140 fi |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
141 } |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
142 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
143 parse_run_args() { |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
144 # manage arguments for run command |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
145 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 while [ $# -gt 0 ]; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 case "$1" in |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 -h|--help) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 cat << OPT_END |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 options available for the run command: |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 -h, --help display this help message |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 -p, --public publish using true ports |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 -d DOMAIN, --domain DOMAIN use DOMAIN as domain name |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 OPT_END |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 exit 0 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
159 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
160 -d|--domain) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 shift |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
162 if [ $# -eq 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 printf "no domain given, --domain must be followed by a domain\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
165 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 DOMAIN=$1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 shift |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
170 -p|--public) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
171 shift |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
172 PUBLIC=1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
175 *) printf "Invalid argument, please check \"$0 run --help\"\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
176 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
178 esac |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
179 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 } |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
182 check_docker || exit 1 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
184 if [ $# -ge 1 ];then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 case $1 in |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
186 start) CMD=START;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 stop) CMD=STOP;; |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
188 restart) CMD=RESTART;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
189 update) CMD=UPDATE;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 backup) CMD=BACKUP;; |
87
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
191 restore) CMD=RESTORE;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
192 ports) CMD=PORTS;; |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
193 config) CMD=CONFIG;; |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
194 -v|--version) printf "$VERSION\n"; exit 0;; |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
195 -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;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 *) echo $USAGE |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 esac |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 shift |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 else |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
201 CMD=START |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
202 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
203 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
204 case $CMD in |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
205 START) |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
206 parse_run_args "$@" |
24
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
207 download_missing || exit 1 |
f0a59c8f3490
docker: added docker presence check + if image are not present locally on run, download them without catching the output (so we can se the progress)
Goffi <goffi@goffi.org>
parents:
23
diff
changeset
|
208 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
209 printf "Running data container... " |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
210 docker_id=$(docker run -d -ti --name $VOLUME_ALIAS $VOLUME_CONT 2>&1) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
211 if [ $? -eq 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
212 printf "OK ($docker_id)\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
213 else |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
214 echo $docker_id | grep Conflict > /dev/null 2>&1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
215 if [ $? -eq 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
216 printf "A data container already exists ($VOLUME_ALIAS), use \"docker ps -a\" to see it\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
217 else |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
218 printf "Error, please check data volume\nerror message: $docker_id\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
219 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
220 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
221 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
222 printf "\nRunning Libervia\n\n" |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
223 # we first check if we need to mount TLS directory |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
224 if [ -n "$SAT_CONT_TLS_DIR" ]; then |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
225 printf "$SAT_CONT_TLS_DIR will be used for TLS certificate\n" |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
226 DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR" |
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
227 fi |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 for CONT in $CONTAINERS; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 case $CONT in |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
230 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
231 if [ -n "$DOMAIN" ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
232 OPTS="-e DOMAIN=$DOMAIN $OPTS" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
233 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
234 ;; |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
235 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
236 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
237 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";; |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
238 libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat $DK_TLS -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 *) printf "Unkown container $CONT\n"; exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 esac |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 printf "Launching $CONT... " |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
242 docker_id=$(docker run $OPTS $ACCOUNT/$CONT 2>&1) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
243 if [ $? -eq 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
244 printf "OK ($docker_id)\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 else |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 printf "Error, please check container or ask help on XMPP MUC sat@chat.jabberfr.org\nerror message: $docker_id\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
247 printf "Abandon\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
248 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
249 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
250 done |
26
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
251 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' |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
252 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" |
a5e4c6c2a37d
docker: replaces tabs by spaces, download first app containers then data container + minor changes
Goffi <goffi@goffi.org>
parents:
25
diff
changeset
|
253 printf 'Below are the ports used to connect, you can go with your browser to Libervia HTTP port.\n\n' |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
254 list_ports |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
255 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
256 STOP) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
257 printf "stopping Libervia\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
258 REVERSED="" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
259 for CONT in $CONTAINERS; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
260 REVERSED="$CONT $REVERSED" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
261 done; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
262 for CONT in $REVERSED; do |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
263 printf "\nStopping container $CONT" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
264 docker stop $CONT > /dev/null 2>&1 || printf "... Error while stopping $CONT\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
265 printf "\rDeleting container $CONT" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
266 docker rm $CONT > /dev/null 2>&1 || printf "... Error while removing $CONT\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
267 done |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
268 printf "\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
269 ;; |
87
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
270 RESTART) |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
271 printf "restarting containers...\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
272 "$0" stop && "$0" start "$@" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
273 ;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
274 UPDATE) |
28
9ca1e7fe0f87
Docker: we update images, not containers
Goffi <goffi@goffi.org>
parents:
26
diff
changeset
|
275 printf "updating images...\n" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
276 errors=0 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
277 for CONT in $CONTAINERS data; do |
25
25b7452c2d5a
docker: "docker pull" result is not hidden anymore in libervia_cons.sh update, so download progress can be followed
Goffi <goffi@goffi.org>
parents:
24
diff
changeset
|
278 printf "\n*** updating $CONT ***\n" |
25b7452c2d5a
docker: "docker pull" result is not hidden anymore in libervia_cons.sh update, so download progress can be followed
Goffi <goffi@goffi.org>
parents:
24
diff
changeset
|
279 docker pull $ACCOUNT/$CONT:latest |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
280 if [ $? -ne 0 ]; then |
25
25b7452c2d5a
docker: "docker pull" result is not hidden anymore in libervia_cons.sh update, so download progress can be followed
Goffi <goffi@goffi.org>
parents:
24
diff
changeset
|
281 printf "\nError while updating $ACCOUNT/$CONT\n" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
282 errors=1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
283 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
284 done |
23
b10f01885949
docker: fixed libervia_cont update + added some newlines
Goffi <goffi@goffi.org>
parents:
22
diff
changeset
|
285 if [ $errors -eq 0 ]; then |
28
9ca1e7fe0f87
Docker: we update images, not containers
Goffi <goffi@goffi.org>
parents:
26
diff
changeset
|
286 printf "\n\nImages are up-to-date\n" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
287 else |
28
9ca1e7fe0f87
Docker: we update images, not containers
Goffi <goffi@goffi.org>
parents:
26
diff
changeset
|
288 printf "\n\nSome errors happened while updating images\n" |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
289 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
290 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
291 ;; |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
292 BACKUP) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
293 filename="sat_data_backup_$(date '+%Y-%m-%d_%H:%M:%S').tar.gz" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
294 printf "backing up data container to $filename\n\n" |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
295 docker run --rm $DK_VOLUME -v "$(pwd):/backup" debian:jessie tar zcvf "/backup/$filename" -C / -h volumes |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
296 if [ $? -eq 0 ]; then |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
297 printf "\nBackup finished\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
298 else |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
299 printf "\nBackup Error !\n" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
300 exit 1 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
301 fi |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
302 ;; |
87
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
303 RESTORE) |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
304 if [ $# -ne 1 ]; then |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
305 printf "syntaxe is $0 restore [backup_file.tar.gz]\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
306 exit 1 |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
307 fi |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
308 docker run --name $VOLUME_ALIAS $VOLUME_CONT > /dev/null 2>&1 |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
309 if [ $? -ne 0 ]; then |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
310 printf "Can't create $VOLUME_ALIAS container.\n\ |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
311 If you have an existing one, please remove it with \"docker rm $VOLUME_ALIAS\" (/!\\ it will remove *ALL* your data)\n\n\ |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
312 Hint: you can commit your container to avoid risk with \"docker commit $VOLUME_ALIAS your_committed_image_name\"\n\ |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
313 you can also rename your current data container with \"docker rename $VOLUME_ALIAS new_container_name\"\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
314 exit 1 |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
315 fi |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
316 |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
317 printf "restoring $1 to $VOLUME_ALIAS container\n\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
318 HOST_BACKUP_DIR="$(dirname "$1")" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
319 if [ $HOST_BACKUP_DIR = "." ]; then |
88
f7d275afc4f2
docker (libervia_cont): TLS dir (directory with certificate) can now be specified with env variable "SAT_CONT_TLS_DIR"
Goffi <goffi@goffi.org>
parents:
87
diff
changeset
|
320 # workaround for a Docker bug (container crash if "." is used) |
87
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
321 HOST_BACKUP_DIR=$(pwd) |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
322 fi |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
323 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" debian:jessie tar zxvf "/backup/$1" -C / -h volumes |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
324 if [ $? -eq 0 ]; then |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
325 printf "\nRestore finished\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
326 else |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
327 printf "\nRestore Error !\n" |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
328 exit 1 |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
329 fi |
53a579906c32
docker(libervia_cont): added a "restore" command
Goffi <goffi@goffi.org>
parents:
86
diff
changeset
|
330 ;; |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
331 PORTS) |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
332 list_ports |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
333 ;; |
86
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
334 CONFIG) |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
335 case $# in |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
336 0) CONF="libervia";; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
337 1) CONF="$1";; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
338 *) CONF="";; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
339 esac |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
340 case $CONF in |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
341 libervia) |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
342 CONT_CONF_FILE="/home/sat/.config/sat/sat.conf" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
343 ;; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
344 prosody) |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
345 CONT_CONF_FILE="/etc/prosody/prosody_sat_cfg/prosody.cfg.lua" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
346 ;; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
347 *) printf "\nPlease enter type of configuration to edit (libervia, prosody)\n" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
348 exit 1 |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
349 ;; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
350 esac |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
351 |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
352 HOST_CONF_FILE=$(basename $CONT_CONF_FILE) |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
353 |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
354 printf "\ngetting configuration for $CONF\n" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
355 # we copy config file to a temporary dit |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
356 # then edit with $EDITOR and put it back |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
357 |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
358 TMP_DIR=$(mktemp -d 2>/dev/null) |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
359 if [ $? -ne 0 ]; then |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
360 TMP_DIR="$DEFAULT_TMP_DIR" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
361 mkdir -p "$TMP_DIR" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
362 fi |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
363 |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
364 docker cp "$VOLUME_ALIAS:$CONT_CONF_FILE" "$TMP_DIR/$HOST_CONF_FILE" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
365 "$EDITOR" "$TMP_DIR/$HOST_CONF_FILE" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
366 if [ $? -eq 0 -a -s "$TMP_DIR/$HOST_CONF_FILE" ]; then |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
367 printf "updating configuration\n" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
368 docker cp "$TMP_DIR/$HOST_CONF_FILE" "$VOLUME_ALIAS:$CONT_CONF_FILE" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
369 fi |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
370 rm -rf "$TMP_DIR" |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
371 ;; |
f5067e3112ba
docker (libervia_cont): new commands:
Goffi <goffi@goffi.org>
parents:
28
diff
changeset
|
372 |
21
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
373 *) printf "Error: unknown command !" |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
374 exit 2 |
0e78c8a4626e
Added Dockerfiles to create Docker images for easy installation + scripts to manages them. see README for details.
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
375 esac |