~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to remakeallusers.py

  • Committer: dcoles
  • Date: 2008-04-18 07:37:50 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:742
Libs: lxml requires extra shared objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
import pwd
31
31
import conf
32
32
import common.makeuser
33
 
import optparse
34
 
import shutil
35
33
# Import modules from the website is tricky since they're in the www
36
34
# directory.
37
35
sys.path.append(os.path.join(os.getcwd(), 'www'))
38
36
 
39
 
p = optparse.OptionParser()
40
 
p.add_option('--incremental', '-i', action='store_true')
41
 
options, arguments = p.parse_args()
42
 
 
43
37
if os.getuid() != 0:
44
38
    print "Must run remakeallusers.py as root."
45
39
    sys.exit()
56
50
    print "Error: " + str(message)
57
51
    sys.exit(1)
58
52
 
59
 
# First check that our __templateuser__ directory exits, if not create it
60
 
templateuserdir = os.path.join(conf.jail_base, '__templateuser__')
61
 
stagingdir = templatedir = os.path.join(conf.jail_base, '__staging__')
62
 
if not os.path.isdir(templateuserdir):
63
 
    os.mkdir(templateuserdir)
64
 
 
65
 
# Generate manifest of files that differ between template user and staging
66
 
if options.incremental:
67
 
    print "Incremental Rebuild selected"
68
 
    manifest = common.makeuser.generate_manifest(stagingdir, templateuserdir)
69
 
    print "Generated change manifest"
70
 
    print "Adding/Updating: %s\nRemoving: %s" % manifest
71
 
else:
72
 
    # Force a full rebuild
73
 
    manifest = None
74
 
 
75
53
list.sort(key=lambda user: user.login)
76
54
for user in list:
77
55
    login = user.login
85
63
            raise Exception("User %s does not have a unixid in the database"
86
64
                % login)
87
65
        # Remake the user's jail
88
 
        common.makeuser.make_jail(login, uid, manifest=manifest)
 
66
        common.makeuser.make_jail(login, uid)
89
67
    except Exception, message:
90
68
        print "Error: " + str(message)
91
69
        continue
92
70
 
93
71
    print "Successfully recreated user %s's jail." % login
94
 
    
95
 
# Update the template user directory
96
 
print "Updating templateuser directory"
97
 
shutil.rmtree(templateuserdir)
98
 
#common.makeuser.linktree(stagingdir, templateuserdir)
99
 
common.makeuser.make_jail('__templateuser__', 0, manifest=manifest)
100
 
shutil.rmtree(os.path.join(templateuserdir, 'home'))
101
 
 
102
 
print "Done!"