diff --git a/client/fasClient b/client/fasClient index 97ae4f4..a3eef5c 100755 --- a/client/fasClient +++ b/client/fasClient @@ -82,6 +82,11 @@ parser.add_option('--nossh', default = False, action = 'store_true', help = _('Do not create ssh keys')) +parser.add_option('--nogitconfigs', + dest = 'no_gitconfigs', + default = False, + action = 'store_true', + help = _('Do not create Git configuration files')) parser.add_option('-s', '--server', dest = 'FAS_URL', default = None, @@ -502,6 +507,21 @@ class MakeShellAccounts(BaseClient): os.chmod(os.path.join(ssh_dir, 'authorized_keys'), 0600) os.path.walk(ssh_dir, _chown, [person['id'], person['id']]) + def create_gitconfigs(self): + ''' Create config file for Git that sets email addresses. ''' + home_base = prefix + config.get('users', 'home').strip('"') + for person in self.people: + username = person['username'] + if self.valid_user(username): + gitconfig = os.path.join(home_base, username, '.gitconfig') + if not os.path.exists(gitconfig): + f = codecs.open(gitconfig, mode='w', encoding='utf-8') + f.write('[user]\n') + f.write(' name = %s\n' % person['human_name']) + f.write(' email = %s@fedoraproject.org\n' % username) + f.close() + os.chmod(gitconfig, 0644) + def make_aliases_txt(self): ''' update your mail aliases file ''' if not self.groups: @@ -611,6 +631,8 @@ if __name__ == '__main__': fas.remove_stale_homedirs() if not opts.no_ssh_keys: fas.create_ssh_keys() + if not opts.no_gitconfigs: + fas.create_gitconfigs() fas.rm_tempdir() fas.logout() if opts.aliases: