source: server/common/oursrc/accountadm/vhostadd @ 800

Last change on this file since 800 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
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
22pw=$(getent passwd "$user")
23if [ $? -ne 0 ]; then
24    echo "User not found." >&2
25    exit $?
26fi
27IFS=: read user x uid gid x home x <<< "$pw"
28
29printf "Docroot: $home/web_scripts" >&2
30read subdir
31
32tmpfile=$(mktemp -t vhostadd.XXXXXX) || exit $?
33trap 'rm -f "$tmpfile"' EXIT
34
35cat <<EOF > "$tmpfile"
36dn: apacheServerName=$host,ou=VirtualHosts,dc=scripts,dc=mit,dc=edu
37objectClass: apacheConfig
38objectClass: top
39apacheServerName: $host
40EOF
41
42if [ "${host%mit.edu}" != "$host" ]; then
43    cat <<EOF >> "$tmpfile"
44apacheServerAlias: ${host%.mit.edu}
45EOF
46fi
47
48cat <<EOF >> "$tmpfile"
49apacheDocumentRoot: $home/web_scripts$subdir
50apacheSuexecUid: $uid
51apacheSuexecGid: $gid
52EOF
53
54exec ldapvi --add --in "$tmpfile"
Note: See TracBrowser for help on using the repository browser.