1 |
douglas |
587 |
#!/usr/bin/env python |
2 |
|
|
# CCS Computer Science |
3 |
|
|
# Change Shell |
4 |
|
|
# |
5 |
|
|
# Douglas Thrift |
6 |
|
|
# |
7 |
|
|
# $Id$ |
8 |
|
|
|
9 |
douglas |
591 |
import admin |
10 |
douglas |
590 |
import common |
11 |
douglas |
593 |
import ldap |
12 |
douglas |
587 |
import re |
13 |
|
|
|
14 |
|
|
if __name__ == '__main__': |
15 |
|
|
try: |
16 |
douglas |
598 |
user = common.user() |
17 |
douglas |
590 |
shells = map(lambda shells: shells[0], common.SHELLS) |
18 |
douglas |
587 |
shell = None |
19 |
|
|
|
20 |
|
|
while shell not in shells: |
21 |
|
|
shell = raw_input('Shell (%s): ' % ', '.join(shells)) |
22 |
|
|
|
23 |
|
|
if shell == 'custom': |
24 |
douglas |
591 |
shells = dict(common.SHELLS)[shell] |
25 |
douglas |
587 |
path = re.compile('^/.*[^/]$') |
26 |
|
|
|
27 |
douglas |
590 |
for system in common.SYSTEMS: |
28 |
douglas |
587 |
while shells[system] is None or path.match(shells[system]) is None: |
29 |
|
|
shells[system] = raw_input((system.capitalize() if not system.endswith('bsd') else system[:-3].capitalize() + 'BSD') + ': ') |
30 |
douglas |
591 |
else: |
31 |
|
|
shells = None |
32 |
|
|
|
33 |
|
|
if admin.master(): |
34 |
|
|
admin.chsh(user, shell, shells) |
35 |
douglas |
592 |
|
36 |
|
|
admin.run(common.chsh_all(user, shell, shells)) |
37 |
douglas |
593 |
except ldap.LDAPError, error: |
38 |
|
|
admin.error(error) |
39 |
douglas |
587 |
except (EOFError, KeyboardInterrupt): |
40 |
douglas |
592 |
admin.eof() |