Browse Source

updated poweradmin run.sh

tags/v2.0.0
Robin Thoni 7 years ago
parent
commit
6795440df5
4 changed files with 51 additions and 24 deletions
  1. 8
    0
      poweradmin/Dockerfile
  2. 41
    0
      poweradmin/common.sh
  3. 1
    23
      poweradmin/run.sh
  4. 1
    1
      poweradmin/vars-files

+ 8
- 0
poweradmin/Dockerfile View File

3
 # FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
3
 # FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
4
 MAINTAINER Robin Thoni <robin@rthoni.com>
4
 MAINTAINER Robin Thoni <robin@rthoni.com>
5
 
5
 
6
+ARG CONFIG_DIR=/etc/default/config-files/
7
+
6
 RUN apt-get update && apt-get -y install\
8
 RUN apt-get update && apt-get -y install\
7
         apache2=2.4.*\
9
         apache2=2.4.*\
8
         libapache2-mod-php5\
10
         libapache2-mod-php5\
34
 
36
 
35
 COPY ./vars-files /etc/vars-files
37
 COPY ./vars-files /etc/vars-files
36
 
38
 
39
+COPY ./common.sh /common.sh
40
+
37
 COPY ./run.sh /run.sh
41
 COPY ./run.sh /run.sh
38
 
42
 
43
+RUN mkdir "${CONFIG_DIR}"
44
+
45
+COPY ./poweradmin-2.1.7/inc/config.inc.php "${CONFIG_DIR}"/config.inc.php
46
+
39
 EXPOSE 80
47
 EXPOSE 80
40
 
48
 
41
 CMD ["/run.sh"]
49
 CMD ["/run.sh"]

+ 41
- 0
poweradmin/common.sh View File

1
+export CONFIG_DIR="/etc/default/config-files/"
2
+
3
+resolv_host()
4
+{
5
+  hostname="${1}"
6
+  ip=$(getent hosts "${hostname}" | cut -d' ' -f1)
7
+  echo "${ip}"
8
+}
9
+
10
+replace_var()
11
+{
12
+  file="${1}"
13
+  var="${2}"
14
+  sed -e "s?${var}?${!var}?g" -i "${file}"
15
+}
16
+
17
+replace_vars()
18
+{
19
+  file="${1}"
20
+  for var in $(cat /etc/vars-vars)
21
+  do
22
+    replace_var "${file}" "${var}"
23
+  done
24
+}
25
+
26
+replace_files()
27
+{
28
+  cat /etc/vars-files | while read line
29
+  do
30
+    filesrc="${CONFIG_DIR}$(echo "${line}" | awk '{print $1}')"
31
+    filedst=$(echo "${line}" | awk '{print $2}')
32
+    if [ -f "${filesrc}" ]
33
+    then
34
+      echo "Expanding file ${filesrc} to ${filedst}"
35
+      cp "${filesrc}" "${filedst}"
36
+      replace_vars "${filedst}"
37
+    else
38
+      echo "File ${filesrc} does not exist. Skipping."
39
+    fi
40
+  done
41
+}

+ 1
- 23
poweradmin/run.sh View File

1
 #! /usr/bin/env bash
1
 #! /usr/bin/env bash
2
 
2
 
3
-replace_var()
4
-{
5
-  file="${1}"
6
-  var="${2}"
7
-  sed -e "s?${var}?${!var}?g" -i "${file}"
8
-}
9
-
10
-replace_vars()
11
-{
12
-  file="${1}"
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
25
-}
3
+. /common.sh
26
 
4
 
27
 replace_files
5
 replace_files
28
 
6
 

+ 1
- 1
poweradmin/vars-files View File

1
-/var/www/html/inc/config.inc.php
1
+config.inc.php /var/www/html/inc/config.inc.php

Loading…
Cancel
Save