mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 07:47:32 +00:00
rm ccnet.conf (#7028)
This commit is contained in:
parent
bf4f101a06
commit
a5d4870526
@ -8,7 +8,7 @@ pymysql.install_as_MySQLdb()
|
|||||||
|
|
||||||
install_path = os.path.dirname(os.path.abspath(__file__))
|
install_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
top_dir = os.path.dirname(install_path)
|
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"
|
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()
|
config = configparser.ConfigParser()
|
||||||
try:
|
try:
|
||||||
config.read(ccnet_conf)
|
config.read(seafile_conf)
|
||||||
db_user = config.get('Database', 'USER')
|
db_user = config.get('database', 'user')
|
||||||
db_host = config.get('Database', 'HOST')
|
db_host = config.get('database', 'host')
|
||||||
db_port = config.getint('Database', 'PORT')
|
db_port = config.getint('database', 'port')
|
||||||
db_password = config.get('Database', 'PASSWD')
|
db_password = config.get('database', 'password')
|
||||||
db_name = config.get('Database', 'DB')
|
db_name = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
|
||||||
except Exception as e:
|
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
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -894,7 +894,6 @@ class SeafileConfigurator(AbstractConfigurator):
|
|||||||
fp.write('[fileserver]\nport=%d\n' % self.fileserver_port)
|
fp.write('[fileserver]\nport=%d\n' % self.fileserver_port)
|
||||||
|
|
||||||
self.generate_db_conf()
|
self.generate_db_conf()
|
||||||
self.generate_notification_conf()
|
|
||||||
|
|
||||||
## use default seafile-data path: seafile_data_dir=${TOPDIR}/seafile-data
|
## 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)
|
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):
|
def validate_seafile_dir(self, path):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
raise InvalidAnswer('%s already exists' % Utils.highlight(path))
|
raise InvalidAnswer('%s already exists' % Utils.highlight(path))
|
||||||
@ -1562,7 +1543,7 @@ def main():
|
|||||||
|
|
||||||
# Part 2: generate configuration
|
# Part 2: generate configuration
|
||||||
db_config.generate()
|
db_config.generate()
|
||||||
ccnet_config.generate()
|
# ccnet_config.generate() # do not create ccnet.conf
|
||||||
seafile_config.generate()
|
seafile_config.generate()
|
||||||
seafdav_config.generate()
|
seafdav_config.generate()
|
||||||
gunicorn_config.generate()
|
gunicorn_config.generate()
|
||||||
|
@ -136,32 +136,32 @@ class DBUpdater(object):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def get_ccnet_mysql_info(version):
|
def get_ccnet_mysql_info(version):
|
||||||
config_path = env_mgr.central_config_dir
|
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 = {
|
defaults = {
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '3306',
|
'PORT': '3306',
|
||||||
'UNIX_SOCKET': '',
|
'UNIX_SOCKET': '',
|
||||||
}
|
}
|
||||||
|
|
||||||
config = Utils.read_config(ccnet_conf, defaults)
|
config = Utils.read_config(seafile_conf, defaults)
|
||||||
db_section = 'Database'
|
db_section = 'database'
|
||||||
|
|
||||||
if not config.has_section(db_section):
|
if not config.has_section(db_section):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
type = config.get(db_section, 'ENGINE')
|
type = config.get(db_section, 'type')
|
||||||
if type != 'mysql':
|
if type != 'mysql':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host = config.get(db_section, 'HOST')
|
host = config.get(db_section, 'host')
|
||||||
port = config.getint(db_section, 'PORT')
|
port = config.getint(db_section, 'port')
|
||||||
username = config.get(db_section, 'USER')
|
username = config.get(db_section, 'user')
|
||||||
password = config.get(db_section, 'PASSWD')
|
password = config.get(db_section, 'password')
|
||||||
db = config.get(db_section, 'DB')
|
db = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
|
||||||
unix_socket = config.get(db_section, 'UNIX_SOCKET')
|
unix_socket = config.get(db_section, 'UNIX_SOCKET')
|
||||||
except configparser.NoOptionError as e:
|
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)
|
info = MySQLDBInfo(host, port, username, password, db, unix_socket)
|
||||||
return info
|
return info
|
||||||
|
@ -50,30 +50,30 @@ class Utils(object):
|
|||||||
return cp
|
return cp
|
||||||
|
|
||||||
def get_ccnet_mysql_info():
|
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 = {
|
defaults = {
|
||||||
'HOST': '127.0.0.1',
|
'HOST': '127.0.0.1',
|
||||||
'PORT': '3306',
|
'PORT': '3306',
|
||||||
}
|
}
|
||||||
|
|
||||||
config = Utils.read_config(ccnet_conf, defaults)
|
config = Utils.read_config(seafile_conf, defaults)
|
||||||
db_section = 'Database'
|
db_section = 'database'
|
||||||
|
|
||||||
if not config.has_section(db_section):
|
if not config.has_section(db_section):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
type = config.get(db_section, 'ENGINE')
|
type = config.get(db_section, 'type')
|
||||||
if type != 'mysql':
|
if type != 'mysql':
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
host = config.get(db_section, 'HOST')
|
host = config.get(db_section, 'host')
|
||||||
port = config.getint(db_section, 'PORT')
|
port = config.getint(db_section, 'port')
|
||||||
username = config.get(db_section, 'USER')
|
username = config.get(db_section, 'user')
|
||||||
password = config.get(db_section, 'PASSWD')
|
password = config.get(db_section, 'password')
|
||||||
db = config.get(db_section, 'DB')
|
db = os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
|
||||||
except configparser.NoOptionError as e:
|
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)
|
info = MySQLDBInfo(host, port, username, password, db)
|
||||||
return info
|
return info
|
||||||
|
@ -113,10 +113,7 @@ class UserObj(object):
|
|||||||
|
|
||||||
|
|
||||||
def get_user_objs_from_ccnet(email_list):
|
def get_user_objs_from_ccnet(email_list):
|
||||||
db_name, error_msg = get_ccnet_db_name()
|
db_name = get_ccnet_db_name()
|
||||||
if error_msg:
|
|
||||||
logger.error(error_msg)
|
|
||||||
return list(), api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, 'Internal Server Error')
|
|
||||||
|
|
||||||
if not email_list:
|
if not email_list:
|
||||||
return list(), None
|
return list(), None
|
||||||
|
@ -1,28 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import os
|
import os
|
||||||
import configparser
|
|
||||||
from django.db import connection
|
from django.db import connection
|
||||||
|
|
||||||
|
|
||||||
def get_ccnet_db_name():
|
def get_ccnet_db_name():
|
||||||
ccnet_conf_dir = os.environ.get('SEAFILE_CENTRAL_CONF_DIR') or os.environ.get('CCNET_CONF_DIR')
|
return os.environ.get('SEAFILE_MYSQL_DB_CCNET_DB_NAME', '') or 'ccnet_db'
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
class CcnetGroup(object):
|
class CcnetGroup(object):
|
||||||
@ -51,7 +32,7 @@ class CcnetDB:
|
|||||||
|
|
||||||
def __init__(self):
|
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):
|
def list_org_departments(self, org_id):
|
||||||
sql = f"""
|
sql = f"""
|
||||||
|
Loading…
Reference in New Issue
Block a user