source: trunk/server/common/oursrc/accountadm/vhostadd @ 2843

Last change on this file since 2843 was 2759, checked in by andersk, 9 years ago
Remove all remaining traces of apacheConfig records
  • Property svn:executable set to *
File size: 1.2 KB
Line 
1#!/bin/bash
2set -e
3
4printf "Host name: " >&2
5if [ "$1" ]; then
6    host="$1"; shift
7    echo "$host"
8else
9    read host
10fi
11
12if ! grep -Fq "." <<< "$host"; then host=$host.mit.edu; fi
13
14printf "User: " >&2
15if [ "$1" ]; then
16    user="$1"; shift
17    echo "$user"
18else
19    read user
20fi
21
22while 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
31done < <(ldapsearch -LLL -x -b ou=People,dc=scripts,dc=mit,dc=edu "(uid=$user)" dn uid uidNumber gidNumber homeDirectory | perl -0pe 's/\n //g;')
32
33printf "Docroot: $home/web_scripts" >&2
34read subdir
35subdir=${subdir%/}
36docroot=$home/web_scripts$subdir
37path=${subdir#/}
38path=${path:-.}
39
40tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $?
41trap 'rm -f "$tmpfile"' EXIT
42
43cat <<EOF > "$tmpfile"
44dn: scriptsVhostName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu
45objectClass: scriptsVhost
46objectClass: top
47scriptsVhostName: $host
48EOF
49
50if [ "${host%mit.edu}" != "$host" ]; then
51    cat <<EOF >> "$tmpfile"
52scriptsVhostAlias: ${host%.mit.edu}
53EOF
54fi
55
56cat <<EOF >> "$tmpfile"
57scriptsVhostAccount: $user_dn
58scriptsVhostDirectory: $path
59EOF
60
61exec ldapvi --add --in "$tmpfile"
Note: See TracBrowser for help on using the repository browser.