annotate docker_legacy/libervia_cont.sh @ 164:29873a41aae1

docker: new docker files are now in sat main repos, this one is legacy
author Goffi <goffi@goffi.org>
date Fri, 01 Jan 2021 18:33:52 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/bin/sh
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
2
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia container manager
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2014-2016 Jérôme Poisson (goffi@goffi.org)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
5
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
10
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
15
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
18
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
19 VERSION="0.3.0"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
20 APP_NAME="Libervia"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
21 ACCOUNT="salutatoi"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
22
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
23 # environment variables that can be used for configuration:
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
24 # SAT_CONT_TLS_DIR for TLS certificates directory
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
25 # SAT_CONT_DOMAIN for the host name
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
26 # SAT_CONT_BACKUP_DIR is the directory where tar.gz backup will be written
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
27 # SAT_CONT_DK_EXTRA is used for extra options (used with all containers but sat_data)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
28 # SAT_CONT_PORT_<port> is used to specify port when -p is used, <port> must be an exposed port
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
29
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
30 CONTAINERS="prosody sat_pubsub salut sat libervia"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
31 TEST_CONT="libervia" # container used to test status
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
32 MAINT_CONT="debian:jessie" # container used for maintenance
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
33
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
34 DK_DETACH="-d"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
35 DK_TERM="-ti"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
36
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
37 VOLUME_NAME="data"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
38 VOLUME_CONT="$ACCOUNT/$VOLUME_NAME"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
39 VOLUME_ALIAS="sat_data"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
40 DK_VOLUME="--volumes-from $VOLUME_ALIAS"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
41
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
42 PUBLIC=0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
43
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
44 PROSODY_PORTS="5222 5269 5280 5281"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
45 PORT_5222_NAME="XMPP client to server"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
46 PORT_5269_NAME="XMPP server to server"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
47 PORT_5280_NAME="HTTP Upload"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
48 PORT_5281_NAME="HTTP Upload (HTTPS)"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
49 SAT_PORTS="10143 10125"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
50 PORT_10143_NAME="IMAP server"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
51 PORT_10125_NAME="SMTP server"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
52 LIBERVIA_PORTS="8080 8443"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
53 PORT_8080_NAME="HTTP"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
54 PORT_8443_NAME="HTTPS"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
55 NO_PORT="No public port"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
56
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
57 DOCKER_EXE="docker"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
58
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
59 USAGE="Usage: $0 [start|stop|restart|status|update|backup|restore|ports|config|stats] [ARGS...]"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
60
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
61 HELP_SITE="https://wiki.goffi.org/wiki/Docker/en"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
62 HELP_MUC="sat@chat.jabberfr.org"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
63
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
64 CONT_CERT_DIR="/usr/share/sat/certificates"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
65 DEFAULT_TMP_DIR="/tmp/tmp_sat_docker"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
66
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
67 eprintf()
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
68 {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
69 >&2 printf "$@"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
70 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
71
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
72 get_dyn_var() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
73 # get dynamicly variable based on given name
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
74
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
75 name=$1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
76 var_type=$2
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
77 name_upp=$(echo "$name" | tr '[:lower:]' '[:upper:]')
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
78 case $var_type in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
79 ports) eval echo "\$${name_upp}_PORTS";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
80 port_name) eval echo "\$PORT_${name_upp}_NAME";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
81 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
82 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
83
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
84 list_ports() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
85 # list used ports in currently running containers
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
86
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
87 for cont in $CONTAINERS; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
88 # we get variable name with uppercase container name
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
89 # some magic to get the ports
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
90 ports=$(get_dyn_var $cont ports)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
91
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
92 [ -n "$ports" ] && printf "== $cont ==\n\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
93
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
94 for port in $ports; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
95 # some magic to get port human readable name
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
96 port_name=$(get_dyn_var $port port_name)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
97 real_port=$(docker port $cont $port 2>&1)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
98 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
99 real_port=$NO_PORT
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
100 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
101
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
102 # we now show the ports with nice alignment
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
103 desc="port $port ($port_name):"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
104 nb_tabs=$((5-${#desc}/8))
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
105 printf "$desc"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
106 for i in $(seq $nb_tabs); do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
107 printf "\t"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
108 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
109 printf "$real_port\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
110 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
111 [ -n "$ports" ] && printf '\n'
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
112 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
113 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
114
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
115 public_ports_arg() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
116 # create Docker arg to have public ports corresponding to container ports
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
117
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
118 if [ $PUBLIC -ne 1 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
119 return
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
120 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
121 cont=$1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
122 ports=$(get_dyn_var $cont ports)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
123 ARG=""
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
124 for port in $ports; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
125 host_port=$(eval echo "\$SAT_CONT_PORT_${port}")
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
126 if [ -z "$host_port" ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
127 host_port=$port
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
128 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
129 if [ "$host_port" != 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
130 ARG="$ARG -p $host_port:$port"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
131 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
132 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
133 echo $ARG
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
134 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
135
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
136 download_missing() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
137 # download images wich are not present locally
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
138 for cont in $CONTAINERS $VOLUME_NAME; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
139 image="$ACCOUNT/$cont"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
140 docker inspect $image:latest > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
141 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
142 printf "$image is not present locally, downloading it\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
143 docker pull $image:latest
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
144 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
145 printf "\nDownload of latest $image finished\n\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
146 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
147 eprintf "\nError while downloading $image, please check your connection and logs\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
148 return 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
149 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
150 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
151 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
152 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
153
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
154 check_docker() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
155 which $DOCKER_EXE > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
156 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
157 printf "Docker is not installed or not accessible, please install it.\nYou can check $HELP_SITE for instructions\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
158 return 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
159 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
160 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
161
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
162 check_docker_version() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
163 # check if current docker version is greater than or equal to the requested one
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
164 wanted_major=$1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
165 wanted_minor=$2
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
166 wanted_rev=$3
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
167 raw=$(docker --version | grep -o '\([0-9]\+\)\.[0-9]\+\.[0-9]\+')
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
168 docker_major=$(echo "$raw" | cut -d . -f 1)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
169 docker_minor=$(echo "$raw" | cut -d . -f 2)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
170 docker_rev=$(echo "$raw" | cut -d . -f 3)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
171 for name in major minor rev; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
172 docker_val=$(eval echo \$docker_$name)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
173 wanted_val=$(eval echo \$wanted_$name)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
174 if [ $docker_val -gt $wanted_val ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
175 return 0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
176 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
177 if [ $docker_val -lt $wanted_val ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
178 return 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
179 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
180 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
181
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
182 # wanted version and docker version are the same
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
183 return 0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
184 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
185
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
186 parse_run_args() {
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
187 # manage arguments for run command
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
188
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
189 while [ $# -gt 0 ]; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
190 case "$1" in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
191
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
192 -h|--help)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
193 cat << OPT_END
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
194 options available for the run command:
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
195
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
196 -h, --help display this help message
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
197 -p, --public publish using true ports
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
198 -d DOMAIN, --domain DOMAIN use DOMAIN as domain name
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
199 OPT_END
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
200 exit 0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
201 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
202
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
203 -d|--domain)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
204 shift
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
205 if [ $# -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
206 printf "no domain given, --domain must be followed by a domain\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
207 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
208 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
209 SAT_CONT_DOMAIN="$1"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
210 shift
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
211 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
212
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
213 -p|--public)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
214 shift
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
215 PUBLIC=1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
216 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
217
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
218 *) printf "Invalid argument, please check \"$0 run --help\"\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
219 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
220 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
221 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
222 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
223 }
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
224
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
225 check_docker || exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
226
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
227 if [ $# -ge 1 ];then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
228 case $1 in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
229 start) CMD=START;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
230 stop) CMD=STOP;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
231 restart) CMD=RESTART;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
232 status) CMD=STATUS;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
233 update) CMD=UPDATE;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
234 backup) CMD=BACKUP;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
235 restore) CMD=RESTORE;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
236 ports) CMD=PORTS;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
237 config) CMD=CONFIG;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
238 stats) CMD=STATS;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
239 -v|--version) printf "$VERSION\n"; exit 0;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
240 -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;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
241 *) echo $USAGE
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
242 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
243 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
244 shift
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
245 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
246 CMD=START
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
247 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
248
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
249 case $CMD in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
250 START)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
251 parse_run_args "$@"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
252 download_missing || exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
253
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
254 printf "Running data container... "
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
255 # we use -d even if data container doesn't stay in background to get id of the container
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
256 docker_id=$(docker run -d --name $VOLUME_ALIAS $VOLUME_CONT 2>&1)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
257 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
258 printf "OK ($docker_id)\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
259 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
260 echo $docker_id | grep Conflict > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
261 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
262 printf "A data container already exists ($VOLUME_ALIAS), use \"docker ps -a\" to see it\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
263 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
264 eprintf "Error, please check data volume\nerror message: $docker_id\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
265 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
266 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
267 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
268 printf "\nRunning Libervia\n\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
269 # we first check if we need to mount TLS directory
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
270 if [ -n "$SAT_CONT_TLS_DIR" ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
271 printf "$SAT_CONT_TLS_DIR will be used for TLS certificate\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
272 DK_TLS="--volume=$SAT_CONT_TLS_DIR:$CONT_CERT_DIR"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
273 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
274 for CONT in $CONTAINERS; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
275 case $CONT in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
276 prosody) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME $DK_TLS $(public_ports_arg $CONT) --name prosody"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
277 if [ -n "$SAT_CONT_DOMAIN" ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
278 OPTS="-e DOMAIN=$SAT_CONT_DOMAIN $OPTS"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
279 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
280 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
281 sat_pubsub) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name sat_pubsub --link=prosody:prosody";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
282 salut) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --name salut --link=prosody:prosody";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
283 sat) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME -P $(public_ports_arg $CONT) --name sat --link=prosody:prosody";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
284 libervia) OPTS="$DK_DETACH $DK_TERM $DK_VOLUME --volumes-from sat $DK_TLS -P $(public_ports_arg $CONT) --name libervia --link=sat:sat";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
285 *) eprintf "Unkown container $CONT\n"; exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
286 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
287 printf "Launching $CONT... "
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
288 docker_id=$(docker run $OPTS $SAT_CONT_DK_EXTRA $ACCOUNT/$CONT 2>&1)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
289 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
290 printf "OK ($docker_id)\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
291 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
292 eprintf "Error, please check container or ask help on XMPP MUC sat@chat.jabberfr.org\nerror message: $docker_id\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
293 eprintf "Abandon\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
294 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
295 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
296 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
297 printf '\nLibervia is launched and should be reachable in a couple of seconds.\nYou can check logs with "docker logs -f libervia" (or any other container name).\n'
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
298 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"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
299 printf 'Below are the ports used to connect, you can go with your browser to Libervia HTTP(S) port.\n\n'
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
300 list_ports
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
301 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
302 STOP)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
303 printf "stopping Libervia\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
304 REVERSED=""
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
305 for CONT in $CONTAINERS; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
306 REVERSED="$CONT $REVERSED"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
307 done;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
308 for CONT in $REVERSED; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
309 printf "\nStopping container $CONT"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
310 docker stop $CONT > /dev/null 2>&1 || eprintf "... Error while stopping $CONT\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
311 printf "\rDeleting container $CONT"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
312 docker rm -v $CONT > /dev/null 2>&1 || eprintf "... Error while removing $CONT\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
313 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
314 printf "\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
315 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
316 RESTART)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
317 printf "restarting containers...\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
318 "$0" stop && "$0" start "$@"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
319 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
320 STATUS)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
321 docker inspect $TEST_CONT > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
322 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
323 printf "$APP_NAME is running"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
324 # we test the presence of "starting on xxxx" (where xxxx is one of the exposed ports)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
325 # this is not really reliable as ports can be changed in configuration
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
326 # but in most case it should work OK
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
327 PORTS_REGEX=$(get_dyn_var $TEST_CONT ports | sed 's/ /\\|/')
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
328 docker logs $TEST_CONT | grep "starting on \($PORTS_REGEX\)" > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
329 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
330 printf " but no server is started\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
331 exit 2
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
332 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
333 printf "\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
334 exit 0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
335 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
336 printf "$APP_NAME is not running\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
337 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
338 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
339 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
340 UPDATE)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
341 printf "updating images...\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
342 errors=0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
343 for CONT in $CONTAINERS data; do
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
344 printf "\n*** updating $CONT ***\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
345 docker pull $ACCOUNT/$CONT:latest
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
346 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
347 eprintf "\nError while updating $ACCOUNT/$CONT\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
348 errors=1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
349 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
350 done
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
351 if [ $errors -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
352 printf "\n\nImages are up-to-date\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
353 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
354 eprintf "\n\nSome errors happened while updating images\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
355 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
356 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
357 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
358 BACKUP)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
359 case $# in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
360 0) SAT_CONT_BACKUP_DIR="$(pwd)";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
361 1) SAT_CONT_BACKUP_DIR="$1";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
362 *) printf "syntaxe is $0 backup [backup_dir_absolute_path]\n[backup_dir_absolute_path] default to current working dir\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
363 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
364 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
365 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
366 SAT_CONT_BACKUP_DIR=$(echo $SAT_CONT_BACKUP_DIR | sed 's%^\/*\|\/*$%\/%g') # we want to be sure that path starts and finishes with "/"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
367 filename="sat_data_backup_$(date '+%Y-%m-%d_%H:%M:%S').tar.gz"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
368 printf "backing up data container to ${SAT_CONT_BACKUP_DIR}${filename}\n\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
369 docker run --rm $DK_VOLUME -v "$SAT_CONT_BACKUP_DIR:/backup" $MAINT_CONT tar zcvf "/backup/$filename" -C / -h volumes
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
370 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
371 printf "\nBackup finished and available at ${SAT_CONT_BACKUP_DIR}${filename}\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
372 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
373 eprintf "\nBackup Error !\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
374 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
375 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
376 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
377 RESTORE)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
378 if [ $# -ne 1 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
379 printf "syntaxe is $0 restore <backup_file.tar.gz>\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
380 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
381 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
382 docker run --name $VOLUME_ALIAS $VOLUME_CONT > /dev/null 2>&1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
383 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
384 eprintf "Can't create $VOLUME_ALIAS container.\n\
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
385 If you have an existing one, please remove it with \"docker rm -v $VOLUME_ALIAS\" (/!\\ it will remove *ALL* your data)\n\n\
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
386 Hint: you can also rename your current data container with \"docker rename $VOLUME_ALIAS new_container_name\"\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
387 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
388 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
389
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
390 printf "restoring $1 to $VOLUME_ALIAS container\n\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
391 HOST_BACKUP_DIR=$(dirname "$1")
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
392 HOST_BACKUP_NAME=$(basename "$1")
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
393 if [ $HOST_BACKUP_DIR = "." ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
394 # workaround for a Docker bug (container crash if "." is used)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
395 HOST_BACKUP_DIR=$(pwd)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
396 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
397 docker run --rm $DK_VOLUME -v "$HOST_BACKUP_DIR:/backup" $MAINT_CONT tar zxvf "/backup/$HOST_BACKUP_NAME" -C / -h volumes
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
398 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
399 printf "\nRestore finished\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
400 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
401 eprintf "\nRestore Error !\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
402 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
403 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
404 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
405 PORTS)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
406 list_ports
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
407 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
408 CONFIG)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
409 case $# in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
410 0) CONF="libervia";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
411 1) CONF="$1";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
412 *) CONF="";;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
413 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
414 case $CONF in
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
415 libervia)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
416 CONT_CONF_FILE="/home/sat/.config/sat/sat.conf"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
417 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
418 prosody)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
419 CONT_CONF_FILE="/etc/prosody/prosody_sat_cfg/prosody.cfg.lua"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
420 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
421 *) printf "\nPlease enter type of configuration to edit (libervia, prosody)\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
422 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
423 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
424 esac
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
425
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
426 HOST_CONF_FILE=$(basename $CONT_CONF_FILE)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
427
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
428 printf "\ngetting configuration for $CONF\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
429 # we copy config file to a temporary dit
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
430 # then edit with $EDITOR and put it back
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
431
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
432 TMP_DIR=$(mktemp -d 2>/dev/null)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
433 if [ $? -ne 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
434 TMP_DIR="$DEFAULT_TMP_DIR"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
435 mkdir -p "$TMP_DIR"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
436 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
437
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
438 docker cp "$VOLUME_ALIAS:$CONT_CONF_FILE" "$TMP_DIR/"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
439 "$EDITOR" "$TMP_DIR/$HOST_CONF_FILE"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
440 if [ $? -eq 0 -a -s "$TMP_DIR/$HOST_CONF_FILE" ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
441 printf "updating configuration\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
442 check_docker_version 1 8 0
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
443 if [ $? -eq 0 ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
444 docker cp "$TMP_DIR/$HOST_CONF_FILE" "$VOLUME_ALIAS:$CONT_CONF_FILE"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
445 else
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
446 eprintf "Old Docker version detected, using workaround, please update!\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
447 docker run --rm $DK_VOLUME -v "$TMP_DIR:/tmp_config" $MAINT_CONT /bin/cp -f "/tmp_config/$HOST_CONF_FILE" "$CONT_CONF_FILE"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
448 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
449 # "docker cp" copy file on container as root, if an option is available later to change this behaviour,
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
450 # the following operation could be removed
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
451 printf "ownership fix..."
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
452 docker run --rm $DK_VOLUME $MAINT_CONT /bin/chown 1000:1000 "$CONT_CONF_FILE"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
453 printf "done\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
454 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
455 rm -rf "$TMP_DIR"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
456 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
457 STATS)
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
458 if [ -n "$1" -a "$1" != "--no-stream" ]; then
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
459 printf "usage: $0 stats [--no-stream]\n"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
460 exit 1
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
461 fi
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
462 docker stats $1 $CONTAINERS
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
463 ;;
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
464 *) eprintf "Error: unknown command !"
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
465 exit 2
29873a41aae1 docker: new docker files are now in sat main repos, this one is legacy
Goffi <goffi@goffi.org>
parents:
diff changeset
466 esac