#!/usr/bin/python3
# -*- mode: python -*-
# Generates passwd, shadow and group files from the ldap directory.

#   Copyright (c) 2000-2001  Jason Gunthorpe <jgg@debian.org>
#   Copyright (c) 2003-2004  James Troup <troup@debian.org>
#   Copyright (c) 2004-2005,7  Joey Schulze <joey@infodrom.org>
#   Copyright (c) 2001-2007  Ryan Murray <rmurray@debian.org>
#   Copyright (c) 2008,2009,2010,2011 Peter Palfrader <peter@palfrader.org>
#   Copyright (c) 2008 Andreas Barth <aba@not.so.argh.org>
#   Copyright (c) 2008 Mark Hymers <mhy@debian.org>
#   Copyright (c) 2008 Luk Claes <luk@debian.org>
#   Copyright (c) 2008 Thomas Viehmann <tv@beamnet.de>
#   Copyright (c) 2009 Stephen Gran <steve@lobefin.net>
#   Copyright (c) 2010 Helmut Grohne <helmut@subdivi.de>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

from __future__ import print_function

import os
import sys

from userdir_ldap.generate import ud_generate


if os.getuid() == 0:
   sys.stderr.write("You should probably not run ud-generate as root.\n")
   sys.exit(1)

if 'UD_PROFILE' in os.environ:
   import cProfile
   import pstats
   cProfile.run('ud_generate()', "udg_prof")
   p = pstats.Stats('udg_prof')
   # p.sort_stats('time').print_stats()
   p.sort_stats('cumulative').print_stats()
else:
   ud_generate()


# vim:set et:
# vim:set ts=3:
# vim:set shiftwidth=3:
