Last change
on this file since 782 was
765,
checked in by presbrey, 16 years ago
|
packaged cronload,vhostadd,vhostedit
|
-
Property svn:executable set to
*
|
File size:
985 bytes
|
Line | |
---|
1 | #!/bin/bash |
---|
2 | set -e |
---|
3 | |
---|
4 | printf "Host name: " >&2 |
---|
5 | if [ "$1" ]; then |
---|
6 | host="$1"; shift |
---|
7 | echo "$host" |
---|
8 | else |
---|
9 | read host |
---|
10 | fi |
---|
11 | |
---|
12 | if ! grep -Fq "." <<< "$host"; then host=$host.mit.edu; fi |
---|
13 | |
---|
14 | printf "User: " >&2 |
---|
15 | if [ "$1" ]; then |
---|
16 | user="$1"; shift |
---|
17 | echo "$user" |
---|
18 | else |
---|
19 | read user |
---|
20 | fi |
---|
21 | |
---|
22 | pw=$(getent passwd "$user") |
---|
23 | if [ $? -ne 0 ]; then |
---|
24 | echo "User not found." >&2 |
---|
25 | exit $? |
---|
26 | fi |
---|
27 | IFS=: read user x uid gid x home x <<< "$pw" |
---|
28 | |
---|
29 | printf "Docroot: $home/web_scripts" >&2 |
---|
30 | read subdir |
---|
31 | |
---|
32 | tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $? |
---|
33 | trap 'rm -f "$tmpfile"' EXIT |
---|
34 | |
---|
35 | cat <<EOF > "$tmpfile" |
---|
36 | dn: apacheServerName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu |
---|
37 | objectClass: apacheConfig |
---|
38 | objectClass: top |
---|
39 | apacheServerName: $host |
---|
40 | EOF |
---|
41 | |
---|
42 | if [ "${host%mit.edu}" != "$host" ]; then |
---|
43 | cat <<EOF >> "$tmpfile" |
---|
44 | apacheServerAlias: ${host%.mit.edu} |
---|
45 | EOF |
---|
46 | fi |
---|
47 | |
---|
48 | cat <<EOF >> "$tmpfile" |
---|
49 | apacheDocumentRoot: $home/web_scripts$subdir |
---|
50 | apacheSuexecUid: $uid |
---|
51 | apacheSuexecGid: $gid |
---|
52 | EOF |
---|
53 | |
---|
54 | exec ldapvi --add --in "$tmpfile" |
---|
Note: See
TracBrowser
for help on using the repository browser.