ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/adduser.sh
Revision: 562
Committed: 2005-08-27T21:46:39-07:00 (19 years, 10 months ago) by douglas
Content type: text/x-sh
File size: 1490 byte(s)
Log Message:
Moo!

File Contents

# Content
1 #!/usr/local/bin/bash
2 # Douglas Thrift
3 #
4 # CCS Computer Science
5 #
6 # Add User
7
8 LDAPSEARCH='/usr/local/bin/ldapsearch'
9 SED='/usr/bin/sed'
10 LDAPADD='/usr/local/bin/ldapadd'
11 SLAPPASSWD='/usr/local/sbin/slappasswd'
12 DATE='/bin/date'
13 LDAPMODIFY='/usr/local/bin/ldapmodify'
14 SMBPASSWD='/usr/local/bin/smbpasswd'
15
16 BASE='dc=ccs,dc=ucsb,dc=edu'
17 SECRET='/ccs/etc/secret'
18
19 ID=$((`$LDAPSEARCH -b "ou=People,$BASE" -LLL -S 'uidNumber' 'uidNumber' \
20 | $SED -Ee 's/^uidNumber: (1[0-9]{3})$/\1/p;d' | tail -n 1` + 1))
21
22 $LDAPADD -D "uid=root,ou=People,$BASE" -x -y $SECRET <<EOF
23 dn: uid=$USER,ou=People,$BASE
24 objectclass: top
25 objectclass: account
26 objectclass: posixAccount
27 objectclass: ucsbCcsLoginShells
28 objectclass: sambaSamAccount
29 cn: $NAME
30 uid: $USER
31 uidNumber: $ID
32 gidNumber: $ID
33 homeDirectory: /home/$USER
34 userPassword: `$SLAPPASSWD -T $FILE`
35 ucsbCcsFreebsd: /usr/local/bin/bash
36 ucsbCcsLinux: /bin/bash
37 ucsbCcsDarwin: /bin/bash
38 sambaPwdLastSet: `$DATE '+%s'`
39 sambaAcctFlags: [U ]
40 sambaSID: S-1-5-21-3739982181-3886045993-82308153-$ID
41 sambaPrimaryGroupSID: S-1-5-21-3739982181-3886045993-82308153-$((ID + 1000))
42
43 dn: cn=$USER,ou=Group,$BASE
44 objectclass: top
45 objectclass: posixGroup
46 objectclass: sambaGroupMapping
47 cn: $USER
48 gidNumber: $ID
49 sambaSID: S-1-5-21-3739982181-3886045993-82308153-$((ID + 1000))
50 sambaGroupType: 4
51 EOF
52
53 $LDAPMODIFY -D "uid=root,ou=People,$BASE" -x -y $SECRET <<<"`$LDAPSEARCH -b \
54 "ou=Group,$BASE" -LLL 'cn=wheel' | $SED -e "s/^$/memberUid: $USER/"`"
55
56 $SMBPASSWD -s $USER

Properties

Name Value
svn:executable *