Procházet zdrojové kódy

update

tags/v2.0.0
Robin Thoni před 9 roky
rodič
revize
3ed89b9b9d

+ 51
- 14
sitegen.sh Zobrazit soubor

@@ -1,13 +1,44 @@
1 1
 #! /usr/bin/env sh
2 2
 
3
-dir="/etc/apache2/sites-available/"
3
+apache_dir=/etc/apache2/sites-available/
4
+conf_dir=/etc/sitegen/
5
+site_dir=/var/
4 6
 
5
-if [ $# -eq 0 ] || [ $# -gt 2 ]
7
+conf_file=/etc/sitegen/sitegen.conf
8
+conf_file_local=~/.sitegen.conf
9
+
10
+loadConf()
11
+{
12
+  if [ -e "$1" ]
13
+  then
14
+    echo "Found a config file: $1"
15
+    . "$1"
16
+  fi
17
+}
18
+
19
+makeDir()
20
+{
21
+  mkdir -p "$1"
22
+  if [ $? -ne 0 ]
23
+  then
24
+    exit 4
25
+  fi
26
+}
27
+
28
+getPath()
29
+{
30
+  readlink -m "$1"
31
+}
32
+
33
+if [ $# -eq 0 ] || [ $# -gt 2 ] || [ "$1" = "--help" ]
6 34
 then
7 35
   echo "Usage:" $(basename $0) "hostname [config=default]" >&2
8 36
   exit 1
9 37
 fi
10 38
 
39
+loadConf "${conf_file}"
40
+loadConf "${conf_file_local}"
41
+
11 42
 host="$1"
12 43
 if [ $# -eq 2 ]
13 44
 then
@@ -16,25 +47,31 @@ else
16 47
   conf="default"
17 48
 fi
18 49
 
19
-def="/etc/sitegen/${conf}"
20
-def_conf="/etc/sitegen/${conf}.conf"
50
+conf_conf=$(getPath "${conf_dir}/${conf}.conf")
51
+conf_include=$(getPath "${conf_dir}/${conf}.include")
52
+
53
+site_conf=$(getPath "${apache_dir}/${host}.conf")
54
+site_include=$(getPath "${apache_dir}/${host}.include")
21 55
 
22
-adef="${dir}/${host}"
23
-adef_conf="${dir}/${host}.conf"
56
+root_dir=$(getPath "${site_dir}/${host}")
24 57
 
25
-if [ ! -f "${def}" ] || [ ! -f "${def_conf}" ]
58
+sed_host="s:%%HOST%%:${host}:g"
59
+sed_root="s:%%ROOT%%:${root_dir}:g"
60
+
61
+if [ ! -f "${conf_conf}" ] || [ ! -f "${conf_include}" ]
26 62
 then
27
-  echo "Configuration file ${def} and/or ${def_conf} error: No such file" >&2
63
+  echo "Configuration file ${conf_conf} and/or ${conf_include} error: No such file" >&2
28 64
   exit 2
29 65
 fi
30 66
 
31
-if [ -f "${adef}" ] || [ -f "${adef_conf}" ]
67
+if [ -f "${site_conf}" ] || [ -f "${site_include}" ]
32 68
 then
33
-  echo "Host already exists: ${adef} and/or ${adef_conf}" >&2
69
+  echo "Host already exists: ${site_conf} and/or ${site_include}" >&2
34 70
   exit 3
35 71
 fi
36 72
 
37
-sed="s/%%HOST%%/${host}/g"
38
-sed "${sed}" "${def}" > "${adef}"
39
-sed "${sed}" "${def_conf}" > "${adef_conf}"
40
-mkdir -p "/var/${host}"
73
+makeDir "${root_dir}"
74
+makeDir "${apache_dir}"
75
+
76
+sed -e "${sed_host}" -e "${sed_root}" "${conf_conf}" > "${site_conf}"
77
+sed -e "${sed_host}" -e "${sed_root}" "${conf_include}" > "${site_include}"

+ 0
- 3
sitegen/default.conf Zobrazit soubor

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

+ 1
- 0
sitegen/default.conf Zobrazit soubor

@@ -0,0 +1 @@
1
+https.conf

+ 1
- 0
sitegen/default.include Zobrazit soubor

@@ -0,0 +1 @@
1
+https.include

+ 0
- 3
sitegen/http Zobrazit soubor

@@ -1,3 +0,0 @@
1
-<VirtualHost *:80>
2
-    Include sites-available/%%HOST%%.conf
3
-</VirtualHost>

+ 3
- 3
sitegen/http.conf Zobrazit soubor

@@ -1,3 +1,3 @@
1
-ServerName %%HOST%%
2
-DocumentRoot /var/%%HOST%%
3
-ServerAlias %%HOST%%
1
+<VirtualHost *:80>
2
+    Include sites-available/%%HOST%%.include
3
+</VirtualHost>

+ 1
- 0
sitegen/http.include Zobrazit soubor

@@ -0,0 +1 @@
1
+https.include

sitegen/default → sitegen/https.conf Zobrazit soubor

@@ -4,7 +4,7 @@
4 4
         Redirect permanent / https://%%HOST%%/
5 5
     </VirtualHost>
6 6
     <VirtualHost *:443>
7
-        Include sites-available/%%HOST%%.conf
7
+        Include sites-available/%%HOST%%.include
8 8
 
9 9
         SSLEngine on
10 10
         SSLCertificateFile /etc/ssl/private/%%HOST%%.crt
@@ -14,6 +14,6 @@
14 14
 </IfModule>
15 15
 <IfModule !mod_ssl.c>
16 16
     <VirtualHost *:80>
17
-        Include sites-available/%%HOST%%.conf
17
+        Include sites-available/%%HOST%%.include
18 18
     </VirtualHost>
19 19
 </IfModule>

+ 3
- 0
sitegen/https.include Zobrazit soubor

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

+ 1
- 0
sitegen/laravel.http.conf Zobrazit soubor

@@ -0,0 +1 @@
1
+http.conf

+ 7
- 0
sitegen/laravel.http.include Zobrazit soubor

@@ -0,0 +1,7 @@
1
+ServerName %%HOST%%
2
+DocumentRoot %%ROOT%%/public
3
+ServerAlias %%HOST%%
4
+<Directory %%ROOT%%/public>
5
+  Options Indexes FollowSymLinks MultiViews
6
+  AllowOverride All
7
+</Directory>

+ 1
- 0
sitegen/laravel.https.conf Zobrazit soubor

@@ -0,0 +1 @@
1
+https.conf

+ 1
- 0
sitegen/laravel.https.include Zobrazit soubor

@@ -0,0 +1 @@
1
+laravel.http.include

+ 0
- 19
sitegen/reverse Zobrazit soubor

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

+ 1
- 0
sitegen/reverse.http.conf Zobrazit soubor

@@ -0,0 +1 @@
1
+http.conf

+ 6
- 0
sitegen/reverse.http.include Zobrazit soubor

@@ -0,0 +1,6 @@
1
+ServerName %%HOST%%
2
+ServerAlias %%HOST%%
3
+ProxyPreserveHost On
4
+ProxyRequests off
5
+ProxyPass / http://%%HOST%%/
6
+ProxyPassReverse / http://%%HOST%%/

+ 1
- 0
sitegen/reverse.https.conf Zobrazit soubor

@@ -0,0 +1 @@
1
+https.conf

sitegen/reverse.conf → sitegen/reverse.https.include Zobrazit soubor


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