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

Last change on this file since 2759 was 2759, checked in by andersk, 6 years ago
Remove all remaining traces of apacheConfig records
  • Property svn:executable set to *
File size: 1.2 KB
RevLine 
[765]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
[892]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;')
[765]32
33printf "Docroot: $home/web_scripts" >&2
34read subdir
[2735]35subdir=${subdir%/}
36docroot=$home/web_scripts$subdir
37path=${subdir#/}
38path=${path:-.}
[765]39
40tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $?
41trap 'rm -f "$tmpfile"' EXIT
42
43cat <<EOF > "$tmpfile"
[827]44dn: scriptsVhostName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu
45objectClass: scriptsVhost
46objectClass: top
47scriptsVhostName: $host
[765]48EOF
49
[827]50if [ "${host%mit.edu}" != "$host" ]; then
51    cat <<EOF >> "$tmpfile"
52scriptsVhostAlias: ${host%.mit.edu}
53EOF
54fi
55
56cat <<EOF >> "$tmpfile"
57scriptsVhostAccount: $user_dn
[2735]58scriptsVhostDirectory: $path
[827]59EOF
60
[765]61exec ldapvi --add --in "$tmpfile"
Note: See TracBrowser for help on using the repository browser.