freeipa/ipa-install/src/ipa-server-install

92 lines
3.2 KiB
Plaintext
Raw Normal View History

0000-12-31 18:09:24 -05:50
#! /usr/bin/python -E
# Authors: Karl MacMillan <kmacmillan@mentalrootkit.com>
#
# Copyright (C) 2007 Red Hat
# see file 'COPYING' for use and warranty information
#
# 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; version 2 only
#
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# requires the following packages:
# fedora-ds-base
# openldap-clients
# nss-tools
VERSION = "%prog .1"
import logging
from optparse import OptionParser
import ipa.dsinstance
import ipa.krbinstance
0000-12-31 18:09:24 -05:50
def parse_options():
parser = OptionParser(version=VERSION)
parser.add_option("-u", "--user", dest="ds_user",
help="ds user")
0000-12-31 18:09:24 -05:50
parser.add_option("-r", "--realm", dest="realm_name",
help="realm name")
parser.add_option("-a", "--host-address", dest="host_name",
help="host address (name or IP address)")
parser.add_option("-p", "--password", dest="password",
help="admin password")
parser.add_option("-m", "--master-password", dest="master_password",
help="kerberos master password")
parser.add_option("-d", "--debug", dest="debug", action="store_true",
dest="debug", default=False, help="print debugging information")
0000-12-31 18:09:24 -05:50
options, args = parser.parse_args()
if not options.realm_name or not options.host_name or not options.password:
parser.error("error: password, realm, and host name required")
return options
def logging_setup(options):
# Always log everything (i.e., DEBUG) to the log
# file.
0000-12-31 18:09:24 -05:50
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename='ipa-install.log',
filemode='w')
console = logging.StreamHandler()
# If the debug option is set, also log debug messages to the console
if options.debug:
console.setLevel(logging.DEBUG)
else:
# Otherwise, log critical and error messages
console.setLevel(logging.ERROR)
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
console.setFormatter(formatter)
logging.getLogger('').addHandler(console)
def main():
0000-12-31 18:09:24 -05:50
options = parse_options()
logging_setup(options)
# Create a directory server instance
0000-12-31 18:09:24 -05:50
ds = ipa.dsinstance.DsInstance()
ds.create_instance(options.ds_user, options.realm_name, options.host_name, options.password)
0000-12-31 18:09:24 -05:50
# Create a kerberos instance
krb = ipa.krbinstance.KrbInstance()
krb.create_instance(options.ds_user, options.realm_name, options.host_name, options.password, options.master_password)
#restart ds after the krb instance have add the sasl map
ds.restart()
0000-12-31 18:09:24 -05:50
return 0
main()