Basic working cubrid, currently listening to all interfaces

parent fa268821
...@@ -37,6 +37,15 @@ class Recipe(BaseSlapRecipe): ...@@ -37,6 +37,15 @@ class Recipe(BaseSlapRecipe):
def getTemplateFilename(self, template_name): def getTemplateFilename(self, template_name):
return pkg_resources.resource_filename(__name__, return pkg_resources.resource_filename(__name__,
'template/%s' % template_name) 'template/%s' % template_name)
def _createSimlink(self, source, destination):
if os.path.exists(destination):
if os.path.islink(destination):
os.remove(destination)
else:
raise OSError("Trying to create a simlink, but real file " \
"already exists at destination %s" % destination)
os.symlink(source, destination)
def _install(self): def _install(self):
self.path_list = [] self.path_list = []
...@@ -69,15 +78,17 @@ class Recipe(BaseSlapRecipe): ...@@ -69,15 +78,17 @@ class Recipe(BaseSlapRecipe):
config_dict.update(self.options) config_dict.update(self.options)
config_dict.update(self.parameter_dict) config_dict.update(self.parameter_dict)
config_dict['cubrid_home'] = self.work_directory cubrid_home_path = os.path.join(self.data_root_directory, "cubrid")
config_dict['cubrid_home'] = cubrid_home_path
config_dict['cubrid_ip'] = ip config_dict['cubrid_ip'] = ip
config_dict['cubrid_port'] = port config_dict['cubrid_port'] = port
config_dict['cubrid_database'] = os.path.join(self.var_directory, config_dict['cubrid_database'] = os.path.join('cubrid')
'cubrid.db')
# Create configuration # Create configuration
cubrid_configuration_template_path = self.getTemplateFilename('cubrid.conf.in')
cubrid_configuration_path = self.createConfigurationFile("cubrid.conf", cubrid_configuration_path = self.createConfigurationFile("cubrid.conf",
self.substituteTemplate('template', 'cubrid.conf.in')) self.substituteTemplate(cubrid_configuration_template_path, config_dict))
# Create wrapper # Create wrapper
cubrid_wrapper_template_location = pkg_resources.resource_filename( cubrid_wrapper_template_location = pkg_resources.resource_filename(
...@@ -86,17 +97,18 @@ class Recipe(BaseSlapRecipe): ...@@ -86,17 +97,18 @@ class Recipe(BaseSlapRecipe):
self.substituteTemplate(cubrid_wrapper_template_location, config_dict)) self.substituteTemplate(cubrid_wrapper_template_location, config_dict))
# Create cubrid configuration directory and link config file here. # Create cubrid configuration directory and link config file here.
cubrid_conf_directory = os.path.join(self.work_directory, 'conf') self._createDirectory(cubrid_home_path)
cubrid_conf_directory = os.path.join(cubrid_home_path, 'conf')
self._createDirectory(cubrid_conf_directory) self._createDirectory(cubrid_conf_directory)
os.symlink(cubrid_configuration_path, self._createSimlink(cubrid_configuration_path,
os.path.join(cubrid_conf_directory, 'cubrid.conf')) os.path.join(cubrid_conf_directory, 'cubrid.conf'))
# Create links to cubrid files, otherzise it will whine. # Create links to cubrid files, otherzise it will whine.
os.symlink(os.path.join(self.options['cubrid_location'], 'bin'), self._createSimlink(os.path.join(self.options['cubrid_location'], 'bin'),
os.path.join(self.work_directory, 'bin')) os.path.join(cubrid_home_path, 'bin'))
os.symlink(os.path.join(self.options['cubrid_location'], 'msg'), self._createSimlink(os.path.join(self.options['cubrid_location'], 'msg'),
os.path.join(self.work_directory, 'msg')) os.path.join(cubrid_home_path, 'msg'))
self.path_list.append(cubrid_runner_path) self.path_list.extend([cubrid_runner_path, cubrid_configuration_path])
return config_dict return config_dict
def installCrond(self): def installCrond(self):
......
...@@ -5,7 +5,7 @@ export JAVA_HOME=%(java_home)s ...@@ -5,7 +5,7 @@ export JAVA_HOME=%(java_home)s
if [ ! -f %(cubrid_database)s ]; if [ ! -f %(cubrid_database)s ];
then then
exec %(cubrid_binary)s createdb %(cubrid_database)s %(cubrid_binary)s createdb %(cubrid_database)s
fi fi
exec %(cubrid_binary)s server start %(cubrid_database)s %(cubrid_server_binary)s server start %(cubrid_database)s
...@@ -8,6 +8,9 @@ develop-eggs-directory = ${buildout:develop-eggs-directory} ...@@ -8,6 +8,9 @@ develop-eggs-directory = ${buildout:develop-eggs-directory}
[instance] [instance]
recipe = ${instance-recipe:egg}:${instance-recipe:module} recipe = ${instance-recipe:egg}:${instance-recipe:module}
cubrid_binary = ${cubrid:location}/bin/cubrid cubrid_binary = ${cubrid:location}/bin/cubrid
cubrid_broker_binary = ${cubrid:location}/bin/cub_broker
cubrid_master_binary = ${cubrid:location}/bin/cub_master
cubrid_server_binary = ${cubrid:location}/bin/cub_server
cubrid_location = ${cubrid:location} cubrid_location = ${cubrid:location}
dcrond_binary = ${dcron:location}/sbin/crond dcrond_binary = ${dcron:location}/sbin/crond
java_home = ${java-sdk:location} java_home = ${java-sdk:location}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment