Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read database config from seafile.conf and env #713

Merged
merged 6 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ci/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def _env_add(*a, **kw):

_env_add('JWT_PRIVATE_KEY', '@%ukmcl$k=9u-grs4azdljk(sn0kd!=mzc17xd7x8#!u$1x@kl')

_env_add('SEAFILE_MYSQL_DB_CCNET_DB_NAME', 'ccnet')

# Prepend the seafile-server/python to PYTHONPATH so we don't need to "make
# install" each time after editing python files.
_env_add('PYTHONPATH', join(SeafileServer().projectdir, 'python'))
Expand Down
33 changes: 1 addition & 32 deletions ci/serverctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,40 +55,8 @@ def setup(self):
os.mkdir (self.seafile_conf_dir, 0o755)
os.mkdir (self.ccnet_conf_dir, 0o755)

self.init_ccnet()
self.init_seafile()

def init_ccnet(self):
if self.db == 'mysql':
self.add_ccnet_db_conf()
else:
self.add_ccnet_sqlite_db_conf()

def add_ccnet_sqlite_db_conf(self):
ccnet_conf = join(self.central_conf_dir, 'ccnet.conf')
ccnet_db_conf = '''\
[Database]
'''
with open(ccnet_conf, 'a+') as fp:
fp.write('\n')
fp.write(ccnet_db_conf)

def add_ccnet_db_conf(self):
ccnet_conf = join(self.central_conf_dir, 'ccnet.conf')
ccnet_db_conf = '''\
[Database]
ENGINE = mysql
HOST = 127.0.0.1
PORT = 3306
USER = seafile
PASSWD = seafile
DB = ccnet
CONNECTION_CHARSET = utf8
'''
with open(ccnet_conf, 'a+') as fp:
fp.write('\n')
fp.write(ccnet_db_conf)

def init_seafile(self):
seafile_conf = join(self.central_conf_dir, 'seafile.conf')
if self.fileserver == 'go_fileserver':
Expand Down Expand Up @@ -265,6 +233,7 @@ def get_seaserv_envs(self):
'SEAFILE_CENTRAL_CONF_DIR': self.central_conf_dir,
'CCNET_CONF_DIR': self.ccnet_conf_dir,
'SEAFILE_CONF_DIR': self.seafile_conf_dir,
'SEAFILE_MYSQL_DB_CCNET_DB_NAME': 'ccnet',
})
return envs

Expand Down
5 changes: 3 additions & 2 deletions common/group-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ ccnet_group_manager_init (CcnetGroupManager *manager)
int
ccnet_group_manager_prepare (CcnetGroupManager *manager)
{
if (!g_key_file_has_key (manager->session->ccnet_config, "GROUP", "TABLE_NAME", NULL))
const char *table_name = g_getenv("SEAFILE_MYSQL_DB_GROUP_TABLE_NAME");
if (!table_name)
manager->priv->table_name = g_strdup ("Group");
else
manager->priv->table_name = g_key_file_get_string (manager->session->ccnet_config, "GROUP", "TABLE_NAME", NULL);
manager->priv->table_name = g_strdup (table_name);

return open_db(manager);
}
Expand Down
Loading
Loading