Robin Thoni před 9 roky
revize
cf8c2995cc
4 změnil soubory, kde provedl 66 přidání a 0 odebrání
  1. 4
    0
      install.sh
  2. 40
    0
      sitegen.sh
  3. 19
    0
      sitegen/def
  4. 3
    0
      sitegen/def.conf

+ 4
- 0
install.sh Zobrazit soubor

@@ -0,0 +1,4 @@
1
+#! /usr/bin/env sh
2
+
3
+cp -r sitegen /etc
4
+cp sitegen.sh /usr/local/bin

+ 40
- 0
sitegen.sh Zobrazit soubor

@@ -0,0 +1,40 @@
1
+#! /usr/bin/env sh
2
+
3
+dir="/etc/apache2/sites-available/"
4
+
5
+if [ $# -eq 0 ] || [ $# -gt 2 ]
6
+then
7
+  echo "Usage:" $(basename $0) "hostname [config=def]" >&2
8
+  exit 1
9
+fi
10
+
11
+host="$1"
12
+if [ $# -eq 2 ]
13
+then
14
+  conf="$2"
15
+else
16
+  conf="def"
17
+fi
18
+
19
+def="/etc/sitegen/${conf}"
20
+def_conf="/etc/sitegen/${conf}.conf"
21
+
22
+adef="${dir}/${host}"
23
+adef_conf="${dir}/${host}.conf"
24
+
25
+if [ ! -f "${def}" ] || [ ! -f "${def_conf}" ]
26
+then
27
+  echo "Configuration file ${def} and/or ${def_conf} error: No such file" >&2
28
+  exit 2
29
+fi
30
+
31
+if [ -f "${adef}" ] || [ -f "${adef_conf}" ]
32
+then
33
+  echo "Host already exists: ${adef} and/or ${adef_conf}" >&2
34
+  exit 3
35
+fi
36
+
37
+sed="s/%%HOST%%/${host}/g"
38
+sed "${sed}" "${def}" > "${adef}"
39
+sed "${sed}" "${def_conf}" > "${adef_conf}"
40
+mkdir -p "/var/${host}"

+ 19
- 0
sitegen/def Zobrazit soubor

@@ -0,0 +1,19 @@
1
+<IfModule mod_ssl.c>
2
+    <VirtualHost *:80>
3
+        ServerName %%HOST%%
4
+        Redirect permanent / https://%%HOST%%/
5
+    </VirtualHost>
6
+    <VirtualHost *:443>
7
+        Include sites-available/%%HOST%%.conf
8
+
9
+        SSLEngine on
10
+        SSLCertificateFile /etc/ssl/private/%%HOST%%.crt
11
+        SSLCertificateKeyFile /etc/ssl/private/%%HOST%%.key
12
+        SSLCertificateChainFile /etc/ssl/certs/sub.class1.server.ca.pem
13
+    </VirtualHost>
14
+</IfModule>
15
+<IfModule !mod_ssl.c>
16
+    <VirtualHost *:80>
17
+        Include sites-available/%%HOST%%.conf
18
+    </VirtualHost>
19
+</IfModule>

+ 3
- 0
sitegen/def.conf Zobrazit soubor

@@ -0,0 +1,3 @@
1
+ServerName %%HOST%%
2
+DocumentRoot /var/%%HOST%%
3
+ServerAlias %%HOST%%

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