| Last change
                  on this file since 2787 was
                  2771,
                  checked in by leee, 9 years ago | 
        
          | use scripts-ldap-1 for vhostadd/edit | 
        
          | 
              
                  Property svn:executable set to
                  * | 
        | File size:
            1.3 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 | 
|---|
| [2735] | 35 | subdir=${subdir%/} | 
|---|
|  | 36 | docroot=$home/web_scripts$subdir | 
|---|
|  | 37 | path=${subdir#/} | 
|---|
|  | 38 | path=${path:-.} | 
|---|
| [1748] | 39 |  | 
|---|
|  | 40 | tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $? | 
|---|
|  | 41 | trap 'rm -f "$tmpfile"' EXIT | 
|---|
|  | 42 |  | 
|---|
|  | 43 | cat <<EOF > "$tmpfile" | 
|---|
|  | 44 | dn: scriptsVhostName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu | 
|---|
|  | 45 | objectClass: scriptsVhost | 
|---|
|  | 46 | objectClass: top | 
|---|
|  | 47 | scriptsVhostName: $host | 
|---|
|  | 48 | EOF | 
|---|
|  | 49 |  | 
|---|
|  | 50 | if [ "${host%mit.edu}" != "$host" ]; then | 
|---|
|  | 51 | cat <<EOF >> "$tmpfile" | 
|---|
|  | 52 | scriptsVhostAlias: ${host%.mit.edu} | 
|---|
|  | 53 | EOF | 
|---|
|  | 54 | fi | 
|---|
|  | 55 |  | 
|---|
|  | 56 | cat <<EOF >> "$tmpfile" | 
|---|
|  | 57 | scriptsVhostAccount: $user_dn | 
|---|
| [2735] | 58 | scriptsVhostDirectory: $path | 
|---|
| [1748] | 59 | EOF | 
|---|
|  | 60 |  | 
|---|
| [2771] | 61 | exec ldapvi --bind sasl -Y GSSAPI -h scripts-ldap-1.mit.edu -b dc=scripts,dc=mit,dc=edu --add --in "$tmpfile" | 
|---|
       
      
      Note: See 
TracBrowser
        for help on using the repository browser.