Last change
on this file since 1943 was
1901,
checked in by adehnert, 14 years ago
|
Merge locker-dev to trunk
|
-
Property svn:executable set to
*
|
File size:
1.6 KB
|
Rev | Line | |
---|
[1748] | 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 | while read attr value; do |
---|
| 23 | echo "$attr" "$value" |
---|
| 24 | case "$attr" in |
---|
| 25 | dn:) user_dn=$value;; |
---|
| 26 | uid:) user=$value;; |
---|
| 27 | uidNumber:) uid=$value;; |
---|
| 28 | gidNumber:) gid=$value;; |
---|
| 29 | homeDirectory:) home=$value;; |
---|
| 30 | esac |
---|
| 31 | done < <(ldapsearch -LLL -x -h scripts.mit.edu -b ou=People,dc=scripts,dc=mit,dc=edu "(uid=$user)" dn uid uidNumber gidNumber homeDirectory | perl -0pe 's/\n //g;') |
---|
| 32 | |
---|
| 33 | printf "Docroot: $home/web_scripts" >&2 |
---|
| 34 | read subdir |
---|
| 35 | |
---|
| 36 | tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $? |
---|
| 37 | trap 'rm -f "$tmpfile"' EXIT |
---|
| 38 | |
---|
| 39 | cat <<EOF > "$tmpfile" |
---|
| 40 | dn: apacheServerName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu |
---|
| 41 | objectClass: apacheConfig |
---|
| 42 | objectClass: top |
---|
| 43 | apacheServerName: $host |
---|
| 44 | EOF |
---|
| 45 | |
---|
| 46 | if [ "${host%mit.edu}" != "$host" ]; then |
---|
| 47 | cat <<EOF >> "$tmpfile" |
---|
| 48 | apacheServerAlias: ${host%.mit.edu} |
---|
| 49 | EOF |
---|
| 50 | fi |
---|
| 51 | |
---|
| 52 | cat <<EOF >> "$tmpfile" |
---|
| 53 | apacheDocumentRoot: $home/web_scripts$subdir |
---|
| 54 | apacheSuexecUid: $uid |
---|
| 55 | apacheSuexecGid: $gid |
---|
| 56 | |
---|
| 57 | dn: scriptsVhostName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu |
---|
| 58 | objectClass: scriptsVhost |
---|
| 59 | objectClass: top |
---|
| 60 | scriptsVhostName: $host |
---|
| 61 | EOF |
---|
| 62 | |
---|
| 63 | if [ "${host%mit.edu}" != "$host" ]; then |
---|
| 64 | cat <<EOF >> "$tmpfile" |
---|
| 65 | scriptsVhostAlias: ${host%.mit.edu} |
---|
| 66 | EOF |
---|
| 67 | fi |
---|
| 68 | |
---|
| 69 | cat <<EOF >> "$tmpfile" |
---|
| 70 | scriptsVhostAccount: $user_dn |
---|
| 71 | scriptsVhostDirectory: ${subdir#/} |
---|
| 72 | EOF |
---|
| 73 | |
---|
[1749] | 74 | exec ldapvi --bind sasl -Y GSSAPI -h scripts5.mit.edu -b dc=scripts,dc=mit,dc=edu --add --in "$tmpfile" |
---|
Note: See
TracBrowser
for help on using the repository browser.