1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-05-12 09:55:53 +00:00

rm ccnet.conf ()

This commit is contained in:
欢乐马 2024-11-11 20:05:26 +08:00 committed by GitHub
parent bf4f101a06
commit a5d4870526
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 32 additions and 73 deletions

View File

@ -8,7 +8,7 @@ pymysql.install_as_MySQLdb()
install_path = os.path.dirname(os.path.abspath(__file__))
top_dir = os.path.dirname(install_path)
ccnet_conf = os.path.join(top_dir, 'conf', 'ccnet.conf')
seafile_conf = os.path.join(top_dir, 'conf', 'seafile.conf')
sql = "INSERT IGNORE INTO EmailUser (email, passwd, is_staff, is_active, ctime) SELECT email, '!', is_staff, is_active, REPLACE(UNIX_TIMESTAMP(CURRENT_TIMESTAMP(6)),'.','') FROM LDAPUsers"
@ -18,14 +18,14 @@ def migrate_ldapusers():
config = configparser.ConfigParser()
try:
config.read(ccnet_conf)
db_user = config.get('Database', 'USER')
db_host = config.get('Database', 'HOST')
db_port = config.getint('Database', 'PORT')
db_password = config.get('Database', 'PASSWD')
db_name = config.get('Database', 'DB')
config.read(seafile_conf)
db_user = config.get('database', 'user')
db_host = config.get('database', 'host')
db_port = config.getint('database', 'port')
db_password = config.get('database', 'password')
db_name = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
except Exception as e:
print("Failed to read ccnet config file %s: %s" % (ccnet_conf, e))
print("Failed to read seafile config file %s: %s" % (seafile_conf, e))
return
try:

View File

@ -894,7 +894,6 @@ class SeafileConfigurator(AbstractConfigurator):
fp.write('[fileserver]\nport=%d\n' % self.fileserver_port)
self.generate_db_conf()
self.generate_notification_conf()
## use default seafile-data path: seafile_data_dir=${TOPDIR}/seafile-data
@ -922,24 +921,6 @@ class SeafileConfigurator(AbstractConfigurator):
Utils.write_config(config, self.seafile_conf)
def generate_notification_conf(self):
config = Utils.read_config(self.seafile_conf)
# [notification]
# enabled=
# host=
# port=
# log_level=
db_section = 'notification'
if not config.has_section(db_section):
config.add_section(db_section)
config.set(db_section, 'enabled', 'false')
config.set(db_section, 'host', '127.0.0.1')
config.set(db_section, 'port', '8083')
config.set(db_section, 'log_level', 'info')
Utils.write_config(config, self.seafile_conf)
def validate_seafile_dir(self, path):
if os.path.exists(path):
raise InvalidAnswer('%s already exists' % Utils.highlight(path))
@ -1562,7 +1543,7 @@ def main():
# Part 2: generate configuration
db_config.generate()
ccnet_config.generate()
# ccnet_config.generate() # do not create ccnet.conf
seafile_config.generate()
seafdav_config.generate()
gunicorn_config.generate()

View File

@ -136,32 +136,32 @@ class DBUpdater(object):
@staticmethod
def get_ccnet_mysql_info(version):
config_path = env_mgr.central_config_dir
ccnet_conf = os.path.join(config_path, 'ccnet.conf')
seafile_conf = os.path.join(config_path, 'seafile.conf')
defaults = {
'HOST': '127.0.0.1',
'PORT': '3306',
'UNIX_SOCKET': '',
}
config = Utils.read_config(ccnet_conf, defaults)
db_section = 'Database'
config = Utils.read_config(seafile_conf, defaults)
db_section = 'database'
if not config.has_section(db_section):
return None
type = config.get(db_section, 'ENGINE')
type = config.get(db_section, 'type')
if type != 'mysql':
return None
try:
host = config.get(db_section, 'HOST')
port = config.getint(db_section, 'PORT')
username = config.get(db_section, 'USER')
password = config.get(db_section, 'PASSWD')
db = config.get(db_section, 'DB')
host = config.get(db_section, 'host')
port = config.getint(db_section, 'port')
username = config.get(db_section, 'user')
password = config.get(db_section, 'password')
db = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
unix_socket = config.get(db_section, 'UNIX_SOCKET')
except configparser.NoOptionError as e:
Utils.error('Database config in ccnet.conf is invalid: %s' % e)
Utils.error('Database config in seafile.conf is invalid: %s' % e)
info = MySQLDBInfo(host, port, username, password, db, unix_socket)
return info

View File

@ -50,30 +50,30 @@ class Utils(object):
return cp
def get_ccnet_mysql_info():
ccnet_conf = os.path.join(env_mgr.ccnet_dir, 'ccnet.conf')
seafile_conf = os.path.join(env_mgr.ccnet_dir, 'seafile.conf')
defaults = {
'HOST': '127.0.0.1',
'PORT': '3306',
}
config = Utils.read_config(ccnet_conf, defaults)
db_section = 'Database'
config = Utils.read_config(seafile_conf, defaults)
db_section = 'database'
if not config.has_section(db_section):
return None
type = config.get(db_section, 'ENGINE')
type = config.get(db_section, 'type')
if type != 'mysql':
return None
try:
host = config.get(db_section, 'HOST')
port = config.getint(db_section, 'PORT')
username = config.get(db_section, 'USER')
password = config.get(db_section, 'PASSWD')
db = config.get(db_section, 'DB')
host = config.get(db_section, 'host')
port = config.getint(db_section, 'port')
username = config.get(db_section, 'user')
password = config.get(db_section, 'password')
db = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
except configparser.NoOptionError as e:
Utils.error('Database config in ccnet.conf is invalid: %s' % e)
Utils.error('Database config in seafile.conf is invalid: %s' % e)
info = MySQLDBInfo(host, port, username, password, db)
return info

View File

@ -113,10 +113,7 @@ class UserObj(object):
def get_user_objs_from_ccnet(email_list):
db_name, error_msg = get_ccnet_db_name()
if error_msg:
logger.error(error_msg)
return list(), api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
db_name = get_ccnet_db_name()
if not email_list:
return list(), None

View File

@ -1,28 +1,9 @@
# -*- coding: utf-8 -*-
import os
import configparser
from django.db import connection
def get_ccnet_db_name():
ccnet_conf_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR') or os.environ.get('CCNET_CONF_DIR')
if not ccnet_conf_dir:
error_msg = 'Environment variable ccnet_conf_dir is not define.'
return None, error_msg
ccnet_conf_path = os.path.join(ccnet_conf_dir, 'ccnet.conf')
config = configparser.ConfigParser()
config.read(ccnet_conf_path)
if config.has_section('Database'):
db_name = config.get('Database', 'DB', fallback='ccnet')
else:
db_name = 'ccnet'
if config.get('Database', 'ENGINE') != 'mysql':
error_msg = 'Failed to init ccnet db, only mysql db supported.'
return None, error_msg
return db_name, None
return os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
class CcnetGroup(object):
@ -51,7 +32,7 @@ class CcnetDB:
def __init__(self):
self.db_name = get_ccnet_db_name()[0]
self.db_name = get_ccnet_db_name()
def list_org_departments(self, org_id):
sql = f"""