Procházet zdrojové kódy

refractor variable replacement

tags/v1.0.0^0
Robin Thoni před 8 roky
rodič
revize
e6552f6bee
5 změnil soubory, kde provedl 58 přidání a 21 odebrání
  1. 8
    4
      roundcube/Dockerfile
  2. 22
    17
      roundcube/run.sh
  3. 3
    0
      roundcube/vars-files
  4. 18
    0
      roundcube/vars-vars
  5. 7
    0
      update_vars.sh

+ 8
- 4
roundcube/Dockerfile Zobrazit soubor

@@ -31,12 +31,16 @@ RUN rm -rf /var/log/* &&\
31 31
 
32 32
 COPY ./apache2.conf /etc/apache2/apache2.conf
33 33
 
34
-COPY ./run.sh /run.sh
35
-
36
-EXPOSE 80
37
-
38 34
 COPY ./roundcubemail-1.2.2/ /var/www/html/
39 35
 
40 36
 RUN ln -s /dev/stderr /var/www/html/logs/errors
41 37
 
38
+COPY ./vars-vars /etc/vars-vars
39
+
40
+COPY ./vars-files /etc/vars-files
41
+
42
+COPY ./run.sh /run.sh
43
+
44
+EXPOSE 80
45
+
42 46
 CMD ["/run.sh"]

+ 22
- 17
roundcube/run.sh Zobrazit soubor

@@ -1,25 +1,30 @@
1
-#!/bin/bash
1
+#! /usr/bin/env bash
2
+
3
+replace_var()
4
+{
5
+  file="${1}"
6
+  var="${2}"
7
+  sed -e "s?${var}?${!var}?g" -i "${file}"
8
+}
9
+
2 10
 replace_vars()
3 11
 {
4 12
   file="${1}"
5
-  sed -e "s/POSTGRES_HOST/${POSTGRES_HOST}/" -i "${file}"
6
-  sed -e "s/POSTGRES_USER/${POSTGRES_USER}/" -i "${file}"
7
-  sed -e "s/POSTGRES_PASSWORD/${POSTGRES_PASSWORD}/" -i "${file}"
8
-  sed -e "s/POSTGRES_DB/${POSTGRES_DB}/" -i "${file}"
9
-  sed -e "s/MAIL_USER_DB_HOST/${MAIL_USER_DB_HOST}/" -i "${file}"
10
-  sed -e "s/MAIL_USER_DB_USER/${MAIL_USER_DB_USER}/" -i "${file}"
11
-  sed -e "s/MAIL_USER_DB_PASSWORD/${MAIL_USER_DB_PASSWORD}/" -i "${file}"
12
-  sed -e "s/MAIL_USER_DB_DB/${MAIL_USER_DB_DB}/" -i "${file}"
13
-  sed -e "s/MAIL_USER_DB_PORT/${MAIL_USER_DB_PORT}/" -i "${file}"
14
-  sed -e "s!IMAP_HOST!${IMAP_HOST}!" -i "${file}"
15
-  sed -e "s!SMTP_HOST!${SMTP_HOST}!" -i "${file}"
16
-  sed -e "s/SIEVE_HOST/${SIEVE_HOST}/" -i "${file}"
17
-  sed -e "s/DES_KEY/${DES_KEY}/" -i "${file}"
13
+  for var in $(cat /etc/vars-vars)
14
+  do
15
+    replace_var "${file}" "${var}"
16
+  done
17
+}
18
+
19
+replace_files()
20
+{
21
+  for file in $(cat /etc/vars-files)
22
+  do
23
+    replace_vars "${file}"
24
+  done
18 25
 }
19 26
 
20
-replace_vars /var/www/html/config/config.inc.php
21
-replace_vars /var/www/html/plugins/password/config.inc.php
22
-replace_vars /var/www/html/plugins/vacation_sieve/config.inc.php
27
+replace_files
23 28
 
24 29
 rm -f /run/apache2/apache2.pid
25 30
 exec /usr/sbin/apache2ctl -D FOREGROUND

+ 3
- 0
roundcube/vars-files Zobrazit soubor

@@ -0,0 +1,3 @@
1
+/var/www/html/config/config.inc.php
2
+/var/www/html/plugins/password/config.inc.php
3
+/var/www/html/plugins/vacation_sieve/config.inc.php

+ 18
- 0
roundcube/vars-vars Zobrazit soubor

@@ -0,0 +1,18 @@
1
+POSTGRES_HOST
2
+POSTGRES_USER
3
+POSTGRES_PASSWORD
4
+POSTGRES_DB
5
+
6
+IMAP_HOST
7
+
8
+SMTP_HOST
9
+
10
+SIEVE_HOST
11
+
12
+MAIL_USER_DB_HOST
13
+MAIL_USER_DB_USER
14
+MAIL_USER_DB_PASSWORD
15
+MAIL_USER_DB_DB
16
+MAIL_USER_DB_PORT
17
+
18
+DES_KEY

+ 7
- 0
update_vars.sh Zobrazit soubor

@@ -0,0 +1,7 @@
1
+#! /usr/bin/env sh
2
+
3
+vars=$(cat env | cut -d= -f1)
4
+for docker in roundcube
5
+do
6
+  echo "${vars}" > "./${docker}/vars-vars"
7
+done

Načítá se…
Zrušit
Uložit