Browse Source

first working version

tags/v1.0.0
Robin Thoni 6 years ago
parent
commit
2303b3da46

+ 3
- 1
.gitignore View File

@@ -1,2 +1,4 @@
1
-/data
1
+/data/isc-dhcp
2
+initrd.img
3
+vmlinuz
2 4
 *.swp

+ 39
- 0
apache/Dockerfile View File

@@ -0,0 +1,39 @@
1
+FROM debian:jessie
2
+
3
+# FROM https://github.com/ZHAJOR/Docker-Apache-2.4-Php-5.6-for-Laravel
4
+MAINTAINER Robin Thoni <robin@rthoni.com>
5
+
6
+RUN apt-get update && apt-get -y install\
7
+        apache2=2.4.*\
8
+        libapache2-mod-php5\
9
+        php5\
10
+        php5-mcrypt\
11
+        php5-pgsql\
12
+        php5-mysql\
13
+        php5-gd\
14
+        php5-curl\
15
+        php5-imap &&\
16
+        apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
17
+
18
+RUN /usr/sbin/a2enmod rewrite &&\
19
+    rm -rf /var/www/html &&\
20
+    mkdir -p /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html &&\
21
+    chown -R www-data:www-data /var/lock/apache2 /var/run/apache2 /var/log/apache2 /var/www/html
22
+
23
+RUN rm -rf /var/log/* &&\
24
+    mkdir -p /var/log/apache2 &&\
25
+    ln -s /dev/stderr /var/log/apache2/error.log &&\
26
+    ln -s /dev/stdout /var/log/apache2/access.log &&\
27
+    ln -s /dev/stdout /var/log/apache2/other_vhosts_access.log
28
+
29
+COPY apache2.conf /etc/apache2/apache2.conf
30
+
31
+COPY ./vars-vars /etc/vars-vars
32
+
33
+COPY ./vars-files /etc/vars-files
34
+
35
+COPY ./run.sh /run.sh
36
+
37
+EXPOSE 80
38
+
39
+CMD ["/run.sh"]

+ 59
- 0
apache/apache2.conf View File

@@ -0,0 +1,59 @@
1
+# see http://sources.debian.net/src/apache2/2.4.10-1/debian/config-dir/apache2.conf
2
+
3
+Mutex file:/var/lock/apache2 default
4
+PidFile /var/run/apache2/apache2.pid
5
+Timeout 300
6
+KeepAlive On
7
+MaxKeepAliveRequests 100
8
+KeepAliveTimeout 5
9
+User www-data
10
+Group www-data
11
+HostnameLookups Off
12
+ErrorLog /var/log/apache2/error.log
13
+LogLevel warn
14
+
15
+IncludeOptional mods-enabled/*.load
16
+IncludeOptional mods-enabled/*.conf
17
+
18
+# ports.conf
19
+Listen 80
20
+<IfModule ssl_module>
21
+    Listen 443
22
+</IfModule>
23
+<IfModule mod_gnutls.c>
24
+    Listen 443
25
+</IfModule>
26
+
27
+DocumentRoot "/var/www/"
28
+
29
+<Directory />
30
+    Options FollowSymLinks
31
+    AllowOverride None
32
+    Require all denied
33
+</Directory>
34
+
35
+<Directory /var/www/>
36
+    Options FollowSymLinks
37
+    AllowOverride All
38
+    Require all granted
39
+</Directory>
40
+
41
+
42
+
43
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
44
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
45
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
46
+LogFormat "%{Referer}i -> %U" referer
47
+LogFormat "%{User-agent}i" agent
48
+
49
+CustomLog /var/log/apache2/access.log combined
50
+
51
+<FilesMatch \.php$>
52
+    SetHandler application/x-httpd-php
53
+</FilesMatch>
54
+
55
+# Multiple DirectoryIndex directives within the same context will add
56
+# to the list of resources to look for rather than replace
57
+# https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
58
+DirectoryIndex disabled
59
+DirectoryIndex index.php index.html

+ 41
- 0
apache/common.sh View File

@@ -0,0 +1,41 @@
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
+}

+ 8
- 0
apache/run.sh View File

@@ -0,0 +1,8 @@
1
+#! /usr/bin/env bash
2
+
3
+. /common.sh
4
+
5
+replace_files
6
+
7
+rm -f /run/apache2/apache2.pid
8
+exec /usr/sbin/apache2ctl -D FOREGROUND

+ 0
- 0
apache/vars-files View File


+ 2
- 0
apache/vars-vars View File

@@ -0,0 +1,2 @@
1
+DNS_HOST_ROUTER
2
+IP_HOST8ROUTER

+ 1
- 0
data/apache/files/.htaccess View File

@@ -0,0 +1 @@
1
+AddType application/x-httpd-php .ipxe

+ 79
- 0
data/apache/files/boot.ipxe View File

@@ -0,0 +1,79 @@
1
+<?php
2
+
3
+$common = ':shell
4
+shell
5
+
6
+:reboot
7
+reboot
8
+
9
+:boot-install
10
+set unix install/${install}
11
+set options vga=788 -- quiet
12
+goto boot-unix
13
+
14
+:boot-live
15
+set unix live/${live}
16
+set options vga=normal ramdisk_size=14332 root=/dev/nfs nfsroot=10.15.44.1:/pxeroot/${live} rw --
17
+goto boot-unix
18
+
19
+:boot-unix
20
+initrd unix/${unix}/initrd.img
21
+boot unix/${unix}/vmlinuz ${options}
22
+
23
+
24
+:boot-iso
25
+initrd iso/${iso}
26
+chain /memdisk iso raw
27
+boot
28
+
29
+:boot-winpe
30
+kernel winpe/${winpe}/wimboot
31
+initrd winpe/${winpe}/bcd                 BCD
32
+initrd winpe/${winpe}/boot.sdi            boot.sdi
33
+initrd winpe/${winpe}/boot.wim            boot.wim
34
+boot';
35
+
36
+echo "#!ipxe\n";
37
+echo "console --picture misc/splash.png\n";
38
+echo "menu gigi PXE\n\n";
39
+
40
+
41
+$types = [['live', 'unix/live', 'Live'],
42
+  ['iso', 'iso', 'ISO'],
43
+  ['install', 'unix/install', 'Installers'],
44
+  ['winpe', 'winpe', 'Windows PE']];
45
+
46
+$labels = "";
47
+
48
+foreach ($types as $type)
49
+{
50
+  echo "\nitem --gap -- " . $type[2] . "\n";
51
+  if (is_dir($type[1])) {
52
+    $items = scandir($type[1]);
53
+    if (is_null($items))
54
+      continue;
55
+    foreach ($items as $item)
56
+    {
57
+      if ($item[0] == '.')
58
+        continue;
59
+      $name = ucwords($item);
60
+      $label = $item . '-' . $type[0];
61
+      echo "item $label" . " $name\n";
62
+      $labels .= "\n\n:" . $label . "\n";
63
+      $labels .= 'set ' . $type[0] . ' ' . $item . "\n";
64
+      $labels .= 'goto boot-' . $type[0] . "\n\n";
65
+    }
66
+  }
67
+}
68
+
69
+echo "item --gap -- Misc
70
+item shell Shell
71
+item reboot Reboot\n";
72
+echo 'choose choice && goto ${choice}' . "\n";
73
+
74
+echo $labels;
75
+
76
+echo $common;
77
+
78
+?>
79
+

+ 0
- 0
data/apache/files/iso/.gitkeep View File


BIN
data/apache/files/memdisk View File


BIN
data/apache/files/misc/splash.png View File


+ 0
- 0
data/apache/files/unix/install/.gitkeep View File


+ 0
- 0
data/apache/files/unix/live/.gitkeep View File


+ 0
- 0
data/apache/files/winpe/.gitkeep View File


BIN
data/tftpd/tftp/ipxe-rthoni.kpxe View File


+ 7
- 0
docker-compose.override.yml View File

@@ -0,0 +1,7 @@
1
+version: '2'
2
+
3
+services:
4
+    apache:
5
+        ports:
6
+            - "10.15.100.1:80:80"
7
+

+ 10
- 24
docker-compose.yml View File

@@ -7,12 +7,6 @@ services:
7 7
         volumes:
8 8
             - ./data/isc-dhcp:/data
9 9
         network_mode: host
10
-#        networks:
11
-#            dhcp.internal.docker:
12
-#                aliases:
13
-#                    - isc-dhcp.dhcp.internal.docker
14
-#        ports:
15
-#            - "0.0.0.0:67:67/udp"
16 10
         env_file:
17 11
             - env
18 12
 
@@ -21,25 +15,17 @@ services:
21 15
         container_name: dhcp-tftpd
22 16
         volumes:
23 17
             - ./data/tftpd/tftp:/srv/tftp/
24
-        networks:
25
-            dhcp.internal.docker:
26
-                aliases:
27
-                    - tftpd.dhcp.internal.docker
28
-        ports:
29
-            - "0.0.0.0:69:69/udp"
18
+        network_mode: host
30 19
         env_file:
31 20
             - env
32 21
 
33
-#    dhcp-recursor:
34
-#        build: ./dhcp-recursor
35
-#        container_name: dhcp-dhcp-recursor
36
-#        networks:
37
-#            dhcp.internal.docker:
38
-#                aliases:
39
-#                    - dhcp-recursor.dhcp.internal.docker
40
-#        env_file:
41
-#            - env
42
-
22
+    apache:
23
+        build: ./apache
24
+        container_name: dhcp-apache
25
+        volumes:
26
+            - ./data/apache/files:/var/www
27
+        ports:
28
+            - "127.0.0.1:34030:80"
29
+        env_file:
30
+            - env
43 31
 
44
-networks:
45
-    dhcp.internal.docker:

+ 4
- 4
isc-dhcp/dhcpd.conf View File

@@ -17,22 +17,22 @@ subnet 10.15.100.0 netmask 255.255.255.0 {
17 17
   range 10.15.100.50 10.15.100.250;
18 18
   option subnet-mask 255.255.255.0;
19 19
   option broadcast-address 10.15.100.255;
20
-  option routers 10.15.100.2;
20
+  option routers 10.15.100.1;
21 21
 
22
-  option domain-name "site.rthoni.com rthoni.com";
22
+  option domain-name "site.rthoni.com";
23 23
   option domain-name-servers 10.15.100.1;
24 24
 
25 25
   #option classless-routes 24, 10,15,42, 10.15.12,2;
26 26
   #option classless-routes-win 24, 10,15,42, 10.15.12,2;
27 27
 
28
-  next-server 10.15.100.2;
28
+  next-server 10.15.100.1;
29 29
   if exists user-class and ( option user-class = "iPXE-rthoni" ) {
30 30
     filename "http://netboot/boot.ipxe";
31 31
   }
32 32
   else {
33 33
     filename "ipxe-rthoni.kpxe";
34 34
   }
35
-  option root-path "10.15.100.1:/pxeroot/ubuntu";
35
+#  option root-path "10.15.100.1:/pxeroot/ubuntu";
36 36
 
37 37
 }
38 38
 

+ 1
- 1
tftpd/xinetd.tftp.conf View File

@@ -5,5 +5,5 @@ service tftp
5 5
     wait                = yes
6 6
     user                = root
7 7
     server              = /usr/sbin/in.tftpd
8
-    server_args = /srv/tftp/
8
+    server_args = -s /srv/tftp/
9 9
   }

+ 1
- 1
update_vars.sh View File

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

Loading…
Cancel
Save