mirror of
https://github.com/haiwen/seahub.git
synced 2025-05-11 17:34:56 +00:00
Upgrade 9.0 10.0 (#5374)
* upgrade_9.0_10.0 * seafile-monitor.sh * rm seahub-extra in scripts * rm seafile_auth_token
This commit is contained in:
parent
f086d4705b
commit
78ba95f82f
@ -411,7 +411,6 @@ def validate_args(usage, options):
|
||||
|
||||
check_targz_src_no_version('seafes', srcdir)
|
||||
check_targz_src_no_version('seafevents', srcdir)
|
||||
check_targz_src_no_version('seahub-extra', srcdir)
|
||||
check_targz_src_no_version('libevent', srcdir)
|
||||
check_targz_src_no_version('elasticsearch', srcdir)
|
||||
check_targz_src_no_version('seafdav', srcdir)
|
||||
@ -702,13 +701,6 @@ def copy_pro_libs():
|
||||
pro_py = os.path.join(Seafile().projdir, 'scripts', 'pro.py')
|
||||
must_copy(pro_py, pro_program_dir)
|
||||
|
||||
seahub_extra_sql_sqlite3 = os.path.join(Seafile().projdir, 'scripts',
|
||||
'seahub_extra.sqlite3.sql')
|
||||
seahub_extra_sql_mysql = os.path.join(Seafile().projdir, 'scripts',
|
||||
'seahub_extra.mysql.sql')
|
||||
must_copy(seahub_extra_sql_sqlite3, pro_misc_dir)
|
||||
must_copy(seahub_extra_sql_mysql, pro_misc_dir)
|
||||
|
||||
uncompress_seafes_seafevents()
|
||||
|
||||
|
||||
@ -859,7 +851,6 @@ def copy_scripts_and_libs():
|
||||
seahub_thirdpart = os.path.join(dst_seahubdir, 'thirdpart')
|
||||
copy_seahub_thirdpart_libs(seahub_thirdpart)
|
||||
copy_seafdav()
|
||||
copy_seahub_extra()
|
||||
|
||||
# copy pro libs & elasticsearch
|
||||
copy_pro_libs()
|
||||
@ -958,16 +949,6 @@ def copy_seahub_thirdpart_libs(seahub_thirdpart):
|
||||
must_copytree(src, dst)
|
||||
|
||||
|
||||
def copy_seahub_extra():
|
||||
'''uncompress seahub-extra.tar.gz to seafile-server/seahub-extra'''
|
||||
tarball = os.path.join(conf[CONF_SRCDIR], 'seahub-extra.tar.gz')
|
||||
builddir = conf[CONF_BUILDDIR]
|
||||
seahub_dir = os.path.join(builddir, 'seafile-server')
|
||||
|
||||
if run('tar xf %s -C %s' % (tarball, seahub_dir)) != 0:
|
||||
error('failed to uncompress elasticsearch')
|
||||
|
||||
|
||||
def strip_symbols():
|
||||
def do_strip(fn):
|
||||
run('chmod u+w %s' % fn)
|
||||
|
@ -24,7 +24,6 @@ The diretory layout:
|
||||
- seaf-dav/
|
||||
- elasticsearch/
|
||||
- misc
|
||||
- seahub_extra.sql
|
||||
|
||||
- seafile-license.txt
|
||||
- seahub.db
|
||||
@ -355,8 +354,6 @@ class EnvManager(object):
|
||||
|
||||
os.path.join(self.top_dir, 'conf'), # LDAP sync has to access seahub_settings.py
|
||||
os.path.join(self.install_path, 'seahub', 'thirdpart'),
|
||||
os.path.join(self.install_path, 'seahub-extra'),
|
||||
os.path.join(self.install_path, 'seahub-extra', 'thirdparts'),
|
||||
|
||||
os.path.join(self.install_path, 'seafile/lib/python3/site-packages'),
|
||||
os.path.join(self.install_path, 'seafile/lib64/python3/site-packages'),
|
||||
@ -405,9 +402,6 @@ class DBConf(object):
|
||||
def generate_conf(self, config):
|
||||
raise NotImplementedError
|
||||
|
||||
def create_extra_tables(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def generate_config_text(self):
|
||||
config = Utils.read_config()
|
||||
self.generate_conf(config)
|
||||
@ -451,22 +445,6 @@ class MySQLDBConf(DBConf):
|
||||
config.set(self.DB_SECTION, 'password', self.mysql_password)
|
||||
config.set(self.DB_SECTION, 'name', self.mysql_db)
|
||||
|
||||
def create_extra_tables(self):
|
||||
self.get_conn()
|
||||
sql_file = os.path.join(env_mgr.pro_misc_dir, 'seahub_extra.mysql.sql')
|
||||
with open(sql_file, 'r') as fp:
|
||||
content = fp.read()
|
||||
|
||||
sqls = content.split(';')
|
||||
|
||||
for sql in sqls:
|
||||
sql = sql.strip()
|
||||
if not sql:
|
||||
continue
|
||||
|
||||
print('>>> sql is', sql, len(sql))
|
||||
self.exec_sql(sql)
|
||||
|
||||
def exec_sql(self, sql):
|
||||
cursor = self.conn.cursor()
|
||||
try:
|
||||
@ -509,16 +487,6 @@ class SQLiteDBConf(DBConf):
|
||||
config.set(self.DB_SECTION, 'type', 'sqlite3')
|
||||
config.set(self.DB_SECTION, 'path', self.db_path)
|
||||
|
||||
def create_extra_tables(self):
|
||||
seahub_db = os.path.join(env_mgr.top_dir, 'seahub.db')
|
||||
sql_file = os.path.join(env_mgr.pro_misc_dir, 'seahub_extra.sqlite3.sql')
|
||||
|
||||
Utils.info('Create extra database tables ... ', newline=False)
|
||||
cmd = 'sqlite3 %s < %s' % (seahub_db, sql_file)
|
||||
if os.system(cmd) != 0:
|
||||
Utils.error('\nfailed to create seahub extra database tables')
|
||||
Utils.info('Done')
|
||||
|
||||
|
||||
class ProfessionalConfigurator(object):
|
||||
'''Main abstract class for the config process '''
|
||||
@ -586,7 +554,6 @@ class MigratingProfessionalConfigurator(ProfessionalConfigurator):
|
||||
|
||||
def config(self):
|
||||
self.detect_db_type()
|
||||
# self.create_extra_tables()
|
||||
self.update_avatars_link()
|
||||
|
||||
def detect_db_type(self):
|
||||
@ -643,9 +610,6 @@ class MigratingProfessionalConfigurator(ProfessionalConfigurator):
|
||||
|
||||
Utils.info('Done')
|
||||
|
||||
def create_extra_tables(self):
|
||||
'''Create seahub-extra database tables'''
|
||||
self.db_config.create_extra_tables()
|
||||
|
||||
class SetupProfessionalConfigurator(ProfessionalConfigurator):
|
||||
'''This script is invokded by setup-seafile.sh/setup-seafile-mysql.sh to
|
||||
|
@ -68,8 +68,6 @@ export SEAHUB_DIR=$seahubdir
|
||||
|
||||
if [[ -d ${INSTALLPATH}/pro ]]; then
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export SEAFES_DIR=$seafesdir
|
||||
export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime
|
||||
fi
|
||||
|
@ -67,8 +67,6 @@ function before_start() {
|
||||
export SEAFES_DIR=$pro_pylibs_dir/seafes
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export EVENTS_CONFIG_FILE=${SEAFILE_CENTRAL_CONF_DIR}/seafevents.conf
|
||||
export INDEX_MASTER_CONFIG_FILE=${SEAFILE_CENTRAL_CONF_DIR}/index-master.conf
|
||||
}
|
||||
|
@ -65,8 +65,6 @@ function before_start() {
|
||||
export SEAFES_DIR=$pro_pylibs_dir/seafes
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export EVENTS_CONFIG_FILE=${SEAFILE_CENTRAL_CONF_DIR}/seafevents.conf
|
||||
export INDEX_SLAVE_CONFIG_FILE=${SEAFILE_CENTRAL_CONF_DIR}/index-slave.conf
|
||||
}
|
||||
|
@ -107,8 +107,6 @@ function before_start() {
|
||||
export SEAFILE_RPC_PIPE_PATH=${INSTALLPATH}/runtime
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
# Allow LDAP user sync to import seahub_settings.py
|
||||
export PYTHONPATH=$PYTHONPATH:${central_config_dir}
|
||||
export SEAFES_DIR=$pro_pylibs_dir/seafes
|
||||
|
62
scripts/seafile-monitor.sh
Executable file
62
scripts/seafile-monitor.sh
Executable file
@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
INSTALLPATH=$(dirname "${SCRIPT}")
|
||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
||||
default_seafile_data_dir=${TOPDIR}/seafile-data
|
||||
central_config_dir=${TOPDIR}/conf
|
||||
seaf_controller="${INSTALLPATH}/seafile/bin/seafile-controller"
|
||||
pro_pylibs_dir=${INSTALLPATH}/pro/python
|
||||
seafesdir=$pro_pylibs_dir/seafes
|
||||
|
||||
export PATH=${INSTALLPATH}/seafile/bin:$PATH
|
||||
export ORIG_LD_LIBRARY_PATH=${LD_LIBRARY_PATH}
|
||||
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
# log function
|
||||
function log() {
|
||||
local time=$(date +"%F %T")
|
||||
echo "[$time] $1 "
|
||||
}
|
||||
|
||||
# check process number
|
||||
# $1 : process name
|
||||
function check_process() {
|
||||
if [ -z $1 ]; then
|
||||
log "Input parameter is empty."
|
||||
return 0
|
||||
fi
|
||||
|
||||
process_num=$(ps -ef | grep "$1" | grep -v "grep" | wc -l)
|
||||
echo $process_num
|
||||
}
|
||||
|
||||
# start
|
||||
function start_notification_server() {
|
||||
notification-server -c ${central_config_dir} -l ${TOPDIR}/logs/notification-server.log &
|
||||
sleep 1
|
||||
}
|
||||
|
||||
# monitor
|
||||
function monitor_notification_server() {
|
||||
process_name="notification-server"
|
||||
check_num=$(check_process $process_name)
|
||||
if [ $check_num -eq 0 ]; then
|
||||
log "Start $process_name"
|
||||
start_notification_server
|
||||
fi
|
||||
}
|
||||
|
||||
# check enabled
|
||||
ENABLE_NOTIFICATION_SERVER=`awk -F '=' '/\[notification\]/{a=1}a==1&&$1~/^enabled/{print $2;exit}' ${central_config_dir}/seafile.conf`
|
||||
|
||||
log "Start Monitor"
|
||||
|
||||
while [ 1 ]; do
|
||||
if [ $ENABLE_NOTIFICATION_SERVER = "true" ]; then
|
||||
monitor_notification_server
|
||||
fi
|
||||
|
||||
sleep 30
|
||||
done
|
@ -53,8 +53,6 @@ function validate_running_user () {
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
if [[ -d ${INSTALLPATH}/pro ]]; then
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export SEAFES_DIR=$seafesdir
|
||||
fi
|
||||
|
||||
@ -154,6 +152,13 @@ function start_seafile_server () {
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# notification-sever
|
||||
ENABLE_NOTIFICATION_SERVER=`awk -F '=' '/\[notification\]/{a=1}a==1&&$1~/^enabled/{print $2;exit}' ${central_config_dir}/seafile.conf`
|
||||
if [ $ENABLE_NOTIFICATION_SERVER == "true" ]; then
|
||||
notification-server -c ${central_config_dir} -l ${TOPDIR}/logs/notification-server.log &
|
||||
${INSTALLPATH}/seafile-monitor.sh &>> ${TOPDIR}/logs/seafile-monitor.log &
|
||||
fi
|
||||
|
||||
echo "Seafile server started"
|
||||
echo
|
||||
}
|
||||
@ -165,6 +170,8 @@ function kill_all () {
|
||||
pkill -f "convert_server.py"
|
||||
pkill -f "soffice.*--invisible --nocrashreport"
|
||||
pkill -f "wsgidav.server.server_cli"
|
||||
pkill -f "notification-server -c ${central_config_dir}"
|
||||
pkill -f "seafile-monitor.sh"
|
||||
}
|
||||
|
||||
function stop_seafile_server () {
|
||||
|
@ -161,8 +161,6 @@ function before_start() {
|
||||
fi
|
||||
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export SEAFES_DIR=$seafesdir
|
||||
export SEAHUB_DIR=$seahubdir
|
||||
fi
|
||||
@ -251,8 +249,6 @@ function run_python_env() {
|
||||
|
||||
if [[ -d ${INSTALLPATH}/pro ]]; then
|
||||
export PYTHONPATH=$PYTHONPATH:$pro_pylibs_dir
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/
|
||||
export PYTHONPATH=$PYTHONPATH:${INSTALLPATH}/seahub-extra/thirdparts
|
||||
export SEAFES_DIR=$seafesdir
|
||||
export SEAHUB_DIR=$seahubdir
|
||||
fi
|
||||
|
@ -932,6 +932,7 @@ 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
|
||||
|
||||
@ -959,6 +960,32 @@ 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=
|
||||
# jwt_private_key=
|
||||
script = os.path.join(env_mgr.install_path, 'seahub/tools/secret_key_generator.py')
|
||||
cmd = [
|
||||
Utils.get_python_executable(),
|
||||
script,
|
||||
]
|
||||
jwt_private_key = Utils.get_command_output(cmd).strip()
|
||||
|
||||
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.0')
|
||||
config.set(db_section, 'port', '8083')
|
||||
config.set(db_section, 'log_level', 'info')
|
||||
config.set(db_section, 'jwt_private_key', jwt_private_key)
|
||||
|
||||
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))
|
||||
|
@ -135,11 +135,7 @@ class DBUpdater(object):
|
||||
|
||||
@staticmethod
|
||||
def get_ccnet_mysql_info(version):
|
||||
if version > '5.0.0':
|
||||
config_path = env_mgr.central_config_dir
|
||||
else:
|
||||
config_path = env_mgr.ccnet_dir
|
||||
|
||||
config_path = env_mgr.central_config_dir
|
||||
ccnet_conf = os.path.join(config_path, 'ccnet.conf')
|
||||
defaults = {
|
||||
'HOST': '127.0.0.1',
|
||||
@ -172,11 +168,7 @@ class DBUpdater(object):
|
||||
|
||||
@staticmethod
|
||||
def get_seafile_mysql_info(version):
|
||||
if version > '5.0.0':
|
||||
config_path = env_mgr.central_config_dir
|
||||
else:
|
||||
config_path = env_mgr.seafile_dir
|
||||
|
||||
config_path = env_mgr.central_config_dir
|
||||
seafile_conf = os.path.join(config_path, 'seafile.conf')
|
||||
defaults = {
|
||||
'HOST': '127.0.0.1',
|
||||
|
6
scripts/upgrade/sql/10.0.0/mysql/ccnet.sql
Normal file
6
scripts/upgrade/sql/10.0.0/mysql/ccnet.sql
Normal file
@ -0,0 +1,6 @@
|
||||
CREATE TABLE IF NOT EXISTS OrgWhiteList (
|
||||
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
org_id INTEGER,
|
||||
white_list TEXT,
|
||||
UNIQUE INDEX (org_id)
|
||||
) ENGINE=INNODB;
|
30
scripts/upgrade/sql/10.0.0/mysql/seafile.sql
Normal file
30
scripts/upgrade/sql/10.0.0/mysql/seafile.sql
Normal file
@ -0,0 +1,30 @@
|
||||
CREATE TABLE IF NOT EXISTS RoleUploadRateLimit (
|
||||
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
role VARCHAR(255),
|
||||
upload_limit BIGINT,
|
||||
UNIQUE INDEX(role)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS RoleDownloadRateLimit (
|
||||
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
role VARCHAR(255),
|
||||
download_limit BIGINT,
|
||||
UNIQUE INDEX(role)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UserUploadRateLimit (
|
||||
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
user VARCHAR(255),
|
||||
upload_limit BIGINT,
|
||||
UNIQUE INDEX(user)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS UserDownloadRateLimit (
|
||||
id BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
user VARCHAR(255),
|
||||
download_limit BIGINT,
|
||||
UNIQUE INDEX(user)
|
||||
) ENGINE=INNODB;
|
||||
|
||||
ALTER TABLE `WebUploadTempFiles` ADD INDEX IF NOT EXISTS `repo_id` (`repo_id`);
|
||||
ALTER TABLE `RepoTokenPeerInfo` CHANGE COLUMN `peer_ip` `peer_ip` varchar(50);
|
21
scripts/upgrade/sql/10.0.0/mysql/seahub.sql
Normal file
21
scripts/upgrade/sql/10.0.0/mysql/seahub.sql
Normal file
@ -0,0 +1,21 @@
|
||||
CREATE TABLE IF NOT EXISTS `org_saml_config` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`org_id` int(11) NOT NULL,
|
||||
`metadata_url` longtext NOT NULL,
|
||||
`single_sign_on_service` longtext NOT NULL,
|
||||
`single_logout_service` longtext NOT NULL,
|
||||
`valid_days` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `org_id` (`org_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `base_usermonitoredrepos` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email` varchar(254) NOT NULL,
|
||||
`repo_id` varchar(36) NOT NULL,
|
||||
`timestamp` datetime(6) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `base_usermonitoredrepos_email_repo_id_b4ab00e4_uniq` (`email`,`repo_id`),
|
||||
KEY `base_usermonitoredrepos_email_55ead1b9` (`email`),
|
||||
KEY `base_usermonitoredrepos_repo_id_00e624c3` (`repo_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
1
scripts/upgrade/sql/10.0.0/sqlite3/ccnet.sql
Normal file
1
scripts/upgrade/sql/10.0.0/sqlite3/ccnet.sql
Normal file
@ -0,0 +1 @@
|
||||
CREATE TABLE IF NOT EXISTS "OrgWhiteList" ("id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, "org_id" integer UNIQUE, "white_list" TEXT);
|
15
scripts/upgrade/sql/10.0.0/sqlite3/seafile.sql
Normal file
15
scripts/upgrade/sql/10.0.0/sqlite3/seafile.sql
Normal file
@ -0,0 +1,15 @@
|
||||
CREATE TABLE IF NOT EXISTS "RoleUploadRateLimit" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "role" varchar(255) UNIQUE, "upload_limit" bigint);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "RoleDownloadRateLimit" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "role" varchar(255) UNIQUE, "download_limit" bigint);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "UserUploadRateLimit" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user" varchar(255) UNIQUE, "upload_limit" bigint);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "UserDownloadRateLimit" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "user" varchar(255) UNIQUE, "download_limit" bigint);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS "repo_id" ON "WebUploadTempFiles" ("repo_id");
|
||||
|
||||
DROP TABLE IF EXISTS "RepoTokenPeerInfo_old";
|
||||
ALTER TABLE "RepoTokenPeerInfo" RENAME TO "RepoTokenPeerInfo_old";
|
||||
CREATE TABLE IF NOT EXISTS RepoTokenPeerInfo (token CHAR(41) PRIMARY KEY, peer_id CHAR(41), peer_ip VARCHAR(50), peer_name VARCHAR(255), sync_time BIGINT, client_ver VARCHAR(20));
|
||||
INSERT INTO "RepoTokenPeerInfo" ("token", "peer_id", "peer_ip", "peer_name", "sync_time", "client_ver") SELECT "token", "peer_id", "peer_ip", "peer_name", "sync_time", "client_ver" FROM "RepoTokenPeerInfo_old";
|
||||
DROP TABLE "RepoTokenPeerInfo_old";
|
5
scripts/upgrade/sql/10.0.0/sqlite3/seahub.sql
Normal file
5
scripts/upgrade/sql/10.0.0/sqlite3/seahub.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS "org_saml_config" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "org_id" integer NOT NULL UNIQUE, "metadata_url" TEXT NOT NULL, "single_sign_on_service" TEXT NOT NULL, "single_logout_service" TEXT NOT NULL, "valid_days" integer NOT NULL);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "base_usermonitoredrepos" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "email" varchar(254) NOT NULL, "repo_id" varchar(36) NOT NULL, "timestamp" datetime NOT NULL, UNIQUE ("email", "repo_id"));
|
||||
CREATE INDEX IF NOT EXISTS "base_usermonitoredrepos_email_55ead1b9" ON "base_usermonitoredrepos" ("email");
|
||||
CREATE INDEX IF NOT EXISTS "base_usermonitoredrepos_repo_id_00e624c3" ON "base_usermonitoredrepos" ("repo_id");
|
240
scripts/upgrade/upgrade_9.0_10.0.sh
Executable file
240
scripts/upgrade/upgrade_9.0_10.0.sh
Executable file
@ -0,0 +1,240 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT=$(readlink -f "$0") # haiwen/seafile-server-1.3.0/upgrade/upgrade_xx_xx.sh
|
||||
UPGRADE_DIR=$(dirname "$SCRIPT") # haiwen/seafile-server-1.3.0/upgrade/
|
||||
INSTALLPATH=$(dirname "$UPGRADE_DIR") # haiwen/seafile-server-1.3.0/
|
||||
TOPDIR=$(dirname "${INSTALLPATH}") # haiwen/
|
||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
||||
default_conf_dir=${TOPDIR}/conf
|
||||
default_pids_dir=${TOPDIR}/pids
|
||||
default_logs_dir=${TOPDIR}/logs
|
||||
default_seafile_data_dir=${TOPDIR}/seafile-data
|
||||
seafile_server_symlink=${TOPDIR}/seafile-server-latest
|
||||
seahub_data_dir=${TOPDIR}/seahub-data
|
||||
|
||||
manage_py=${INSTALLPATH}/seahub/manage.py
|
||||
|
||||
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
|
||||
export SEAFILE_CONF_DIR=${default_seafile_data_dir}
|
||||
export SEAFILE_CENTRAL_CONF_DIR=${default_conf_dir}
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python3/site-packages:${INSTALLPATH}/seafile/lib64/python3/site-packages:${INSTALLPATH}/seahub:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
prev_version=9.0
|
||||
current_version=10.0
|
||||
|
||||
echo
|
||||
echo "-------------------------------------------------------------"
|
||||
echo "This script would upgrade your seafile server from ${prev_version} to ${current_version}"
|
||||
echo "Press [ENTER] to contiune"
|
||||
echo "-------------------------------------------------------------"
|
||||
echo
|
||||
read dummy
|
||||
|
||||
function check_python_executable() {
|
||||
if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if which python3 2>/dev/null 1>&2; then
|
||||
PYTHON=python3
|
||||
elif !(python --version 2>&1 | grep "3\.[0-9]\.[0-9]") 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "The current version of python is not 3.x.x, please use Python 3.x.x ."
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
PYTHON="python"$(python --version | cut -b 8-10)
|
||||
if !which $PYTHON 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "Can't find a python executable of $PYTHON in PATH"
|
||||
echo "Install $PYTHON before continue."
|
||||
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment variable to it"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function check_seafile_data_dir () {
|
||||
if [[ ! -d ${default_seafile_data_dir} ]]; then
|
||||
echo "Your seafile server data directory \"${default_seafile_data_dir}\" is invalid or doesn't exits."
|
||||
echo "Please check it first, or create this directory yourself."
|
||||
echo ""
|
||||
exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
function ensure_server_not_running() {
|
||||
# test whether seafile server has been stopped.
|
||||
if pgrep seaf-server 2>/dev/null 1>&2 ; then
|
||||
echo
|
||||
echo "seafile server is still running !"
|
||||
echo "stop it using scripts before upgrade."
|
||||
echo
|
||||
exit 1
|
||||
elif pgrep -f "${manage_py} run_gunicorn" 2>/dev/null 1>&2 \
|
||||
|| pgrep -f "seahub.wsgi:application" 2>/dev/null 1>&2; then
|
||||
echo
|
||||
echo "seahub server is still running !"
|
||||
echo "stop it before upgrade."
|
||||
echo
|
||||
exit 1
|
||||
elif pgrep -f "${manage_py} runfcgi" 2>/dev/null 1>&2 ; then
|
||||
echo
|
||||
echo "seahub server is still running !"
|
||||
echo "stop it before upgrade."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function migrate_avatars() {
|
||||
echo
|
||||
echo "migrating avatars ..."
|
||||
echo
|
||||
media_dir=${INSTALLPATH}/seahub/media
|
||||
orig_avatar_dir=${INSTALLPATH}/seahub/media/avatars
|
||||
dest_avatar_dir=${TOPDIR}/seahub-data/avatars
|
||||
|
||||
# move "media/avatars" directory outside
|
||||
if [[ ! -d ${dest_avatar_dir} ]]; then
|
||||
mkdir -p "${TOPDIR}/seahub-data"
|
||||
mv "${orig_avatar_dir}" "${dest_avatar_dir}" 2>/dev/null 1>&2
|
||||
ln -s ../../../seahub-data/avatars "${media_dir}"
|
||||
|
||||
elif [[ ! -L ${orig_avatar_dir} ]]; then
|
||||
mv "${orig_avatar_dir}"/* "${dest_avatar_dir}" 2>/dev/null 1>&2
|
||||
rm -rf "${orig_avatar_dir}"
|
||||
ln -s ../../../seahub-data/avatars "${media_dir}"
|
||||
fi
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
function update_database() {
|
||||
echo
|
||||
echo "Updating seafile/seahub database ..."
|
||||
echo
|
||||
|
||||
db_update_helper=${UPGRADE_DIR}/db_update_helper.py
|
||||
if ! $PYTHON "${db_update_helper}" 10.0.0; then
|
||||
echo
|
||||
echo "Failed to upgrade your database"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
echo "Done"
|
||||
}
|
||||
|
||||
function upgrade_seafile_server_latest_symlink() {
|
||||
# update the symlink seafile-server to the new server version
|
||||
if [[ -L "${seafile_server_symlink}" || ! -e "${seafile_server_symlink}" ]]; then
|
||||
echo
|
||||
printf "updating \033[33m${seafile_server_symlink}\033[m symbolic link to \033[33m${INSTALLPATH}\033[m ...\n\n"
|
||||
echo
|
||||
if ! rm -f "${seafile_server_symlink}"; then
|
||||
echo "Failed to remove ${seafile_server_symlink}"
|
||||
echo
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
if ! ln -s "$(basename ${INSTALLPATH})" "${seafile_server_symlink}"; then
|
||||
echo "Failed to update ${seafile_server_symlink} symbolic link."
|
||||
echo
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function make_media_custom_symlink() {
|
||||
media_symlink=${INSTALLPATH}/seahub/media/custom
|
||||
if [[ -L "${media_symlink}" ]]; then
|
||||
return
|
||||
|
||||
elif [[ ! -e "${media_symlink}" ]]; then
|
||||
ln -s ../../../seahub-data/custom "${media_symlink}"
|
||||
return
|
||||
|
||||
|
||||
elif [[ -d "${media_symlink}" ]]; then
|
||||
cp -rf "${media_symlink}" "${seahub_data_dir}/"
|
||||
rm -rf "${media_symlink}"
|
||||
ln -s ../../../seahub-data/custom "${media_symlink}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
function move_old_customdir_outside() {
|
||||
# find the path of the latest seafile server folder
|
||||
if [[ -L ${seafile_server_symlink} ]]; then
|
||||
latest_server=$(readlink -f "${seafile_server_symlink}")
|
||||
else
|
||||
return
|
||||
fi
|
||||
|
||||
old_customdir=${latest_server}/seahub/media/custom
|
||||
|
||||
# old customdir is already a symlink, do nothing
|
||||
if [[ -L "${old_customdir}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# old customdir does not exist, do nothing
|
||||
if [[ ! -e "${old_customdir}" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# media/custom exist and is not a symlink
|
||||
cp -rf "${old_customdir}" "${seahub_data_dir}/"
|
||||
}
|
||||
|
||||
function add_notification_conf () {
|
||||
seahub_secret_keygen=${INSTALLPATH}/seahub/tools/secret_key_generator.py
|
||||
jwt_private_key=$($PYTHON "${seahub_secret_keygen}")
|
||||
cat >> ${default_conf_dir}/seafile.conf <<EOF
|
||||
[notification]
|
||||
enabled = false
|
||||
host = 127.0.0.1
|
||||
port = 8083
|
||||
log_level = info
|
||||
jwt_private_key = $jwt_private_key
|
||||
EOF
|
||||
}
|
||||
|
||||
function update_nginx_conf () {
|
||||
nginx_conf=/etc/nginx/sites-available/seafile.conf
|
||||
if [[ ! -e /etc/nginx/sites-available/seafile.conf ]]; then
|
||||
nginx_conf=/shared/nginx/conf/seafile.nginx.conf
|
||||
fi
|
||||
|
||||
cp ${nginx_conf} ${nginx_conf}.bak
|
||||
sed -i '/media {/i\ location /notification {\n proxy_pass http://127.0.0.1:8083/;\n proxy_http_version 1.1;\n proxy_set_header Upgrade $http_upgrade;\n proxy_set_header Connection "upgrade";\n access_log /var/log/nginx/notification.access.log seafileformat;\n error_log /var/log/nginx/notification.error.log;\n }' ${nginx_conf}
|
||||
|
||||
nginx -s reload
|
||||
}
|
||||
|
||||
#################
|
||||
# The main execution flow of the script
|
||||
################
|
||||
|
||||
check_python_executable;
|
||||
check_seafile_data_dir;
|
||||
ensure_server_not_running;
|
||||
|
||||
update_database;
|
||||
migrate_avatars;
|
||||
|
||||
add_notification_conf;
|
||||
|
||||
update_nginx_conf;
|
||||
|
||||
move_old_customdir_outside;
|
||||
make_media_custom_symlink;
|
||||
upgrade_seafile_server_latest_symlink;
|
||||
|
||||
|
||||
echo
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo "Upgraded your seafile server successfully."
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo
|
@ -1344,3 +1344,25 @@ CREATE TABLE `onlyoffice_onlyofficedockey` (
|
||||
UNIQUE KEY `repo_id_file_path_md5` (`repo_id_file_path_md5`),
|
||||
KEY `onlyoffice_onlyofficedockey_doc_key_edba1352` (`doc_key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `org_saml_config` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`org_id` int(11) NOT NULL,
|
||||
`metadata_url` longtext NOT NULL,
|
||||
`single_sign_on_service` longtext NOT NULL,
|
||||
`single_logout_service` longtext NOT NULL,
|
||||
`valid_days` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `org_id` (`org_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE `base_usermonitoredrepos` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`email` varchar(254) NOT NULL,
|
||||
`repo_id` varchar(36) NOT NULL,
|
||||
`timestamp` datetime(6) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `base_usermonitoredrepos_email_repo_id_b4ab00e4_uniq` (`email`,`repo_id`),
|
||||
KEY `base_usermonitoredrepos_email_55ead1b9` (`email`),
|
||||
KEY `base_usermonitoredrepos_repo_id_00e624c3` (`repo_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -615,4 +615,8 @@ CREATE INDEX IF NOT EXISTS "ocm_via_webdav_share_received_shared_by_1786d580" ON
|
||||
CREATE TABLE IF NOT EXISTS "onlyoffice_onlyofficedockey" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "doc_key" varchar(36) NOT NULL, "username" varchar(255) NOT NULL, "repo_id" varchar(36) NULL, "file_path" TEXT NOT NULL, "repo_id_file_path_md5" varchar(100) NOT NULL, "created_time" datetime NOT NULL);
|
||||
CREATE INDEX IF NOT EXISTS "onlyoffice_onlyofficedockey_doc_key_edba1352" ON "onlyoffice_onlyofficedockey" ("doc_key");
|
||||
CREATE INDEX IF NOT EXISTS "onlyoffice_onlyofficedockey_repo_id_file_path_md5_52002073" ON "onlyoffice_onlyofficedockey" ("repo_id_file_path_md5");
|
||||
CREATE TABLE IF NOT EXISTS "org_saml_config" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "org_id" integer NOT NULL UNIQUE, "metadata_url" TEXT NOT NULL, "single_sign_on_service" TEXT NOT NULL, "single_logout_service" TEXT NOT NULL, "valid_days" integer NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "base_usermonitoredrepos" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "email" varchar(254) NOT NULL, "repo_id" varchar(36) NOT NULL, "timestamp" datetime NOT NULL, UNIQUE ("email", "repo_id"));
|
||||
CREATE INDEX IF NOT EXISTS "base_usermonitoredrepos_email_55ead1b9" ON "base_usermonitoredrepos" ("email");
|
||||
CREATE INDEX IF NOT EXISTS "base_usermonitoredrepos_repo_id_00e624c3" ON "base_usermonitoredrepos" ("repo_id");
|
||||
COMMIT;
|
||||
|
Loading…
Reference in New Issue
Block a user