[scripts] add server 2.1.0 upgrade scripts

This commit is contained in:
lins05 2013-12-23 10:06:49 +08:00
parent 7a05f774ff
commit 012388d054
8 changed files with 166 additions and 16 deletions

1
.gitignore vendored
View File

@ -119,3 +119,4 @@ tests/test-seafile-fmt
*.pc
seaf-fsck
*.tar.gz
fuse/seaf-fuse

View File

@ -4,4 +4,4 @@ endif
dist_man1_MANS = $(CLIENT_MANUALS)
EXTRA_DIST = cli-readme.txt
EXTRA_DIST = cli-readme.txt seafile-tutorial.doc Seafile使用指南.doc

View File

@ -512,6 +512,16 @@ def setup_build_env():
prepend_env_value('PKG_CONFIG_PATH', os.path.join(prefix, 'lib', 'pkgconfig'))
prepend_env_value('PKG_CONFIG_PATH', os.path.join(prefix, 'lib64', 'pkgconfig'))
def copy_user_manuals():
builddir = conf[CONF_BUILDDIR]
src_pattern = os.path.join(builddir, Seafile().projdir, 'doc', '*.doc')
dst_dir = os.path.join(builddir, 'seafile-server', 'seafile', 'docs')
must_mkdir(dst_dir)
for path in glob.glob(src_pattern):
must_copy(path, dst_dir)
def copy_scripts_and_libs():
'''Copy server release scripts and shared libs, as well as seahub
thirdpart libs
@ -564,6 +574,7 @@ def copy_scripts_and_libs():
# copy shared c libs
copy_shared_libs()
copy_user_manuals()
def copy_pdf2htmlex():
'''Copy pdf2htmlEX exectuable and its dependent libs'''

View File

@ -7,6 +7,7 @@ import os
import time
import re
import shutil
import glob
import subprocess
import hashlib
import getpass
@ -128,6 +129,14 @@ Press ENTER to continue
except OSError, e:
Utils.error('failed to create directory %s:%s' % (path, e))
@staticmethod
def must_copy(src, dst):
'''Copy src to dst, exit on failure'''
try:
shutil.copy(src, dst)
except Exception, e:
Utils.error('failed to copy %s to %s: %s' % (src, dst, e))
@staticmethod
def find_in_path(prog):
if 'win32' in sys.platform:
@ -1059,13 +1068,18 @@ DATABASES = {
class SeafDavConfigurator(AbstractConfigurator):
def __init__(self):
AbstractConfigurator.__init__(self)
self.seafile_dir = os.path.join(env_mgr.top_dir, 'seafile-data')
self.seafdav_conf = os.path.join(self.seafile_dir, 'seafdav.conf')
self.conf_dir = None
self.seafdav_conf = None
def ask_questions(self):
pass
def generate(self):
self.conf_dir = os.path.join(env_mgr.top_dir, 'conf')
if not os.path.exists('conf'):
Utils.must_mkdir(self.conf_dir)
self.seafdav_conf = os.path.join(self.conf_dir, 'seafdav.conf')
text = '''
[WEBDAV]
enabled = false
@ -1077,6 +1091,19 @@ share_name = /
with open(self.seafdav_conf, 'w') as fp:
fp.write(text)
class UserManualHandler(object):
def __init__(self):
self.src_docs_dir = os.path.join(env_mgr.install_path, 'seafile', 'docs')
self.library_template_dir = None
def copy_user_manuals(self):
self.library_template_dir = os.path.join(seafile_config.seafile_dir, 'library-template')
Utils.must_mkdir(self.library_template_dir)
pattern = os.path.join(self.src_docs_dir, '*.doc')
for doc in glob.glob(pattern):
Utils.must_copy(doc, self.library_template_dir)
def report_config():
print
@ -1149,6 +1176,7 @@ ccnet_config = CcnetConfigurator()
seafile_config = SeafileConfigurator()
seafdav_config = SeafDavConfigurator()
seahub_config = SeahubConfigurator()
user_manuals_handler = UserManualHandler()
# Would be created after AbstractDBConfigurator.ask_use_existing_db()
db_config = None
@ -1184,6 +1212,7 @@ def main():
seahub_config.do_syncdb()
seahub_config.prepare_avatar_dir()
db_config.create_seahub_admin()
user_manuals_handler.copy_user_manuals()
create_seafile_server_symlink()
report_success()

View File

@ -340,6 +340,12 @@ EOF
fi
}
function copy_user_manuals() {
src_docs_dir=${INSTALLPATH}/seafile/docs/
library_template_dir=${seafile_data_dir}/library-template
mkdir -p ${library_template_dir}
cp -f ${src_docs_dir}/*.doc ${library_template_dir}
}
# -------------------------------------------
@ -586,6 +592,11 @@ fi
echo "done"
echo
# -------------------------------------------
# copy user manuals to library template
# -------------------------------------------
copy_user_manuals;
# -------------------------------------------
# final message
# -------------------------------------------

View File

@ -0,0 +1,39 @@
CREATE TABLE IF NOT EXISTS `captcha_captchastore` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`challenge` varchar(32) NOT NULL,
`response` varchar(32) NOT NULL,
`hashkey` varchar(40) NOT NULL,
`expiration` datetime NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `hashkey` (`hashkey`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
DROP TABLE IF EXISTS `notifications_usernotification`;
CREATE TABLE IF NOT EXISTS `notifications_usernotification` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`to_user` varchar(255) NOT NULL,
`msg_type` varchar(30) NOT NULL,
`detail` longtext NOT NULL,
`timestamp` datetime NOT NULL,
`seen` tinyint(1) NOT NULL,
PRIMARY KEY (`id`),
KEY `notifications_usernotification_bc172800` (`to_user`),
KEY `notifications_usernotification_265e5521` (`msg_type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `options_useroptions` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`email` varchar(255) NOT NULL,
`option_key` varchar(50) NOT NULL,
`option_val` varchar(50) NOT NULL,
PRIMARY KEY (`id`),
KEY `options_useroptions_830a6ccb` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `profile_detailedprofile` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`user` varchar(255) NOT NULL,
`department` varchar(512) NOT NULL,
`telephone` varchar(100) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -0,0 +1,48 @@
CREATE TABLE IF NOT EXISTS "captcha_captchastore" (
"id" integer NOT NULL PRIMARY KEY,
"challenge" varchar(32) NOT NULL,
"response" varchar(32) NOT NULL,
"hashkey" varchar(40) NOT NULL UNIQUE,
"expiration" datetime NOT NULL
);
DROP TABLE IF EXISTS "notifications_usernotification";
CREATE TABLE IF NOT EXISTS "notifications_usernotification" (
"id" integer NOT NULL PRIMARY KEY,
"to_user" varchar(255) NOT NULL,
"msg_type" varchar(30) NOT NULL,
"detail" text NOT NULL,
"timestamp" datetime NOT NULL,
"seen" bool NOT NULL
);
CREATE INDEX IF NOT EXISTS "notifications_usernotification_265e5521" ON "notifications_usernotification" ("msg_type");
CREATE INDEX IF NOT EXISTS "notifications_usernotification_bc172800" ON "notifications_usernotification" ("to_user");
CREATE TABLE IF NOT EXISTS "options_useroptions" (
"id" integer NOT NULL PRIMARY KEY,
"email" varchar(255) NOT NULL,
"option_key" varchar(50) NOT NULL,
"option_val" varchar(50) NOT NULL
);
CREATE INDEX IF NOT EXISTS "options_useroptions_830a6ccb" ON "options_useroptions" ("email");
CREATE TABLE IF NOT EXISTS "profile_detailedprofile" (
"id" integer NOT NULL PRIMARY KEY,
"user" varchar(255) NOT NULL,
"department" varchar(512) NOT NULL,
"telephone" varchar(100) NOT NULL
);
CREATE INDEX IF NOT EXISTS "profile_detailedprofile_6340c63c" ON "profile_detailedprofile" ("user");
CREATE TABLE IF NOT EXISTS "share_uploadlinkshare" (
"id" integer NOT NULL PRIMARY KEY,
"username" varchar(255) NOT NULL,
"repo_id" varchar(36) NOT NULL,
"path" text NOT NULL,
"token" varchar(10) NOT NULL UNIQUE,
"ctime" datetime NOT NULL,
"view_cnt" integer NOT NULL
);
CREATE INDEX IF NOT EXISTS "share_uploadlinkshare_2059abe4" ON "share_uploadlinkshare" ("repo_id");
CREATE INDEX IF NOT EXISTS "share_uploadlinkshare_ee0cafa2" ON "share_uploadlinkshare" ("username");

View File

@ -119,27 +119,38 @@ echo "------------------------------"
echo "Updating seafile/seahub database ..."
echo
# seahub_db=${TOPDIR}/seahub.db
# seahub_sql=${UPGRADE_DIR}/sql/2.1.0/sqlite3/seahub.sql
# if ! sqlite3 "${seahub_db}" < "${seahub_sql}"; then
# echo "Failed to update seahub database"
# exit 1
# fi
seahub_db=${TOPDIR}/seahub.db
seahub_sql=${UPGRADE_DIR}/sql/2.1.0/sqlite3/seahub.sql
if ! sqlite3 "${seahub_db}" < "${seahub_sql}"; then
echo "Failed to update seahub database"
exit 1
fi
seafdav_conf=${default_conf_dir}/seafdav.conf
mkdir -p ${default_conf_dir}
if ! $(cat > ${seafdav_conf} <<EOF
function gen_seafdav_conf() {
seafdav_conf=${default_conf_dir}/seafdav.conf
mkdir -p ${default_conf_dir}
if ! $(cat > ${seafdav_conf} <<EOF
[WEBDAV]
enabled = false
port = 8080
fastcgi = false
share_name = /
EOF
); then
echo "failed to generate seafdav.conf";
exit 1
fi
); then
echo "failed to generate seafdav.conf";
exit 1
fi
}
function copy_user_manuals() {
src_docs_dir=${INSTALLPATH}/seafile/docs/
library_template_dir=${seafile_data_dir}/library-template
mkdir -p ${library_template_dir}
cp -f ${src_docs_dir}/*.doc ${library_template_dir}
}
gen_seafdav_conf;
copy_user_manuals;
echo "DONE"
echo "------------------------------"