You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-2.1-server/scripts/cl-setup

77 lines
2.6 KiB

#!/usr/bin/python
#-*- coding: utf-8 -*-
#Copyright 2008 Calculate Pack, http://www.calculate-linux.ru
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import sys
import os
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-lib/pym'))
sys.path.insert(0,os.path.abspath('/usr/lib/calculate/calculate-server/pym'))
import cl_base
tr = cl_base.lang()
tr.setGlobalDomain('cl_server')
tr.setLanguage(sys.modules[__name__])
import cl_ldap
class tsOpt(cl_base.opt):
def __init__(self, obj):
self.obj =obj
self.shortOpt = self.obj.getAllOpt('short')
self.longOpt = self.obj.getAllOpt('long')
self.opt = []
self.sysArgv = sys.argv[1:]
self.__iter = 0
self.params = {}
cl_base.opt.__init__(self, self.shortOpt, self.longOpt)
if "h" in self.opt or (not self.params.has_key('service')and\
not self.opt):
print self.obj.getHelp()
else:
if not (self.params['service'] in self.obj.allServ):
self.handlerErrOpt()
def handlerOpt(self,option,value):
# Обработчик (опция значение)
#print option, value
shortOpt = self.obj.getShortOpt(option)
if not shortOpt in self.opt:
self.opt.append(shortOpt)
def handlerErrOpt(self):
# Обработчик ошибок
argv = " ".join(sys.argv[1:])
print _("Unrecognized option") + ' "' + argv + '"\n' + \
_("Try") + ' "' + sys.argv[0].split("/")[-1] + ' --help" ' +\
_("for more information.")
def handlerParam(self,param):
# Обработчик хвостов (значение)
self.__iter += 1
# Достаем название сервиса
if self.__iter == 1:
self.params['service'] = param
if __name__ == "__main__":
ldapObj = cl_ldap.cl_ldap("cl-setup")
optObj = tsOpt(ldapObj)
if optObj.params.has_key('service'):
if optObj.params['service'] == "ldap":
ldapObj.setupLdapServer(optObj.opt)
elif optObj.params['service'] == "samba":
ldapObj.setupSambaServer(optObj.opt)