|
@@ -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}"
|