mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-01 23:46:53 +00:00
update sql
This commit is contained in:
1
scripts/upgrade/sql/7.0.0/mysql/ccnet.sql
Normal file
1
scripts/upgrade/sql/7.0.0/mysql/ccnet.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE UserRole ADD COLUMN is_manual_set INTEGER DEFAULT 0;
|
2
scripts/upgrade/sql/7.0.0/mysql/seafile.sql
Normal file
2
scripts/upgrade/sql/7.0.0/mysql/seafile.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
ALTER TABLE RepoInfo ADD COLUMN status INTEGER DEFAULT 0;
|
||||
ALTER TABLE RepoSyncError MODIFY COLUMN error_con VARCHAR(1024);
|
114
scripts/upgrade/sql/7.0.0/mysql/seahub.sql
Normal file
114
scripts/upgrade/sql/7.0.0/mysql/seahub.sql
Normal file
@@ -0,0 +1,114 @@
|
||||
CREATE TABLE IF NOT EXISTS `drafts_draft` (
|
||||
`id` int(11) NOT NULL,
|
||||
`created_at` datetime(6) NOT NULL,
|
||||
`updated_at` datetime(6) NOT NULL,
|
||||
`username` varchar(255) NOT NULL,
|
||||
`origin_repo_id` varchar(36) NOT NULL,
|
||||
`origin_file_version` varchar(100) NOT NULL,
|
||||
`draft_file_path` varchar(1024) NOT NULL,
|
||||
`origin_file_uuid` char(32) NOT NULL,
|
||||
`publish_file_version` varchar(100) DEFAULT NULL,
|
||||
`status` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `drafts_draft_origin_file_uuid_id_f150319e_fk_tags_file` (`origin_file_uuid`),
|
||||
KEY `drafts_draft_created_at_e9f4523f` (`created_at`),
|
||||
KEY `drafts_draft_updated_at_0a144b05` (`updated_at`),
|
||||
KEY `drafts_draft_username_73e6738b` (`username`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `drafts_draftreviewer` (
|
||||
`id` int(11) NOT NULL,
|
||||
`reviewer` varchar(255) NOT NULL,
|
||||
`draft_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `drafts_draftreviewer_reviewer_e4c777ac` (`reviewer`),
|
||||
KEY `drafts_draftreviewer_draft_id_4ea59775_fk_drafts_draft_id` (`draft_id`),
|
||||
CONSTRAINT `drafts_draftreviewer_draft_id_4ea59775_fk_drafts_draft_id` FOREIGN KEY (`draft_id`) REFERENCES `drafts_draft` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
ALTER TABLE `options_useroptions` ADD INDEX `options_useroptions_option_key_7bf7ae4b` (`option_key`);
|
||||
|
||||
ALTER TABLE TotalStorageStat DROP primary key;
|
||||
ALTER TABLE TotalStorageStat ADD `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
|
||||
ALTER TABLE TotalStorageStat ADD `org_id` INT NOT NULL DEFAULT -1;
|
||||
ALTER TABLE TotalStorageStat ADD INDEX `idx_storage_time_org` (`timestamp`, `org_id`);
|
||||
|
||||
ALTER TABLE FileOpsStat ADD `org_id` INT NOT NULL DEFAULT -1;
|
||||
ALTER TABLE FileOpsStat ADD INDEX `idx_file_ops_time_org` (`timestamp`, `org_id`);
|
||||
|
||||
ALTER TABLE UserActivityStat DROP primary key;
|
||||
ALTER TABLE UserActivityStat ADD `id` BIGINT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
|
||||
ALTER TABLE UserActivityStat ADD UNIQUE (name_time_md5);
|
||||
ALTER TABLE UserActivityStat ADD `org_id` INT NOT NULL DEFAULT -1;
|
||||
ALTER TABLE UserActivityStat ADD INDEX `idx_activity_time_org` (`timestamp`, `org_id`);
|
||||
|
||||
DROP TABLE UserTrafficStat;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `repo_tags_repotags` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`repo_id` varchar(36) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`color` varchar(255) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `repo_tags_repotags_repo_id_1163a48f` (`repo_id`),
|
||||
KEY `repo_tags_repotags_name_3f4c9027` (`name`),
|
||||
KEY `repo_tags_repotags_color_1292b6c1` (`color`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `file_tags_filetags` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`file_uuid_id` char(32) NOT NULL,
|
||||
`repo_tag_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `file_tags_filetags_file_uuid_id_e30f0ec8_fk_tags_file` (`file_uuid_id`),
|
||||
KEY `file_tags_filetags_repo_tag_id_c39660cb_fk_repo_tags_repotags_id` (`repo_tag_id`),
|
||||
CONSTRAINT `file_tags_filetags_file_uuid_id_e30f0ec8_fk_tags_file` FOREIGN KEY (`file_uuid_id`) REFERENCES `tags_fileuuidmap` (`uuid`),
|
||||
CONSTRAINT `file_tags_filetags_repo_tag_id_c39660cb_fk_repo_tags_repotags_id` FOREIGN KEY (`repo_tag_id`) REFERENCES `repo_tags_repotags` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `related_files_relatedfiles` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`o_uuid_id` char(32) NOT NULL,
|
||||
`r_uuid_id` char(32) NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `related_files_relate_o_uuid_id_aaa8e613_fk_tags_file` (`o_uuid_id`),
|
||||
KEY `related_files_relate_r_uuid_id_031751df_fk_tags_file` (`r_uuid_id`),
|
||||
CONSTRAINT `related_files_relate_o_uuid_id_aaa8e613_fk_tags_file` FOREIGN KEY (`o_uuid_id`) REFERENCES `tags_fileuuidmap` (`uuid`),
|
||||
CONSTRAINT `related_files_relate_r_uuid_id_031751df_fk_tags_file` FOREIGN KEY (`r_uuid_id`) REFERENCES `tags_fileuuidmap` (`uuid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `organizations_orgsettings` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`org_id` int(11) NOT NULL,
|
||||
`role` varchar(100) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `organizations_orgsettings_org_id_630f6843_uniq` (`org_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
DROP INDEX `profile_profile_contact_email_0975e4bf_uniq` ON `profile_profile`;
|
||||
ALTER TABLE `profile_profile` ADD CONSTRAINT `profile_profile_contact_email_0975e4bf_uniq` UNIQUE (`contact_email`);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `social_auth_usersocialauth` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`username` varchar(255) NOT NULL,
|
||||
`provider` varchar(32) NOT NULL,
|
||||
`uid` varchar(150) NOT NULL,
|
||||
`extra_data` longtext NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `social_auth_usersocialauth_provider_uid_e6b5e668_uniq` (`provider`,`uid`),
|
||||
KEY `social_auth_usersocialauth_username_3f06b5cf` (`username`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
|
||||
ALTER TABLE `base_filecomment` ADD `detail` LONGTEXT DEFAULT NULL;
|
||||
ALTER TABLE `base_filecomment` ADD `resolved` TINYINT(1) NOT NULL DEFAULT 0;
|
||||
ALTER TABLE `base_filecomment` ADD INDEX `resolved` (`resolved`);
|
1
scripts/upgrade/sql/7.0.0/sqlite3/ccnet/usermgr.sql
Normal file
1
scripts/upgrade/sql/7.0.0/sqlite3/ccnet/usermgr.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE UserRole ADD COLUMN is_manual_set INTEGER DEFAULT 0;
|
5
scripts/upgrade/sql/7.0.0/sqlite3/seafile.sql
Normal file
5
scripts/upgrade/sql/7.0.0/sqlite3/seafile.sql
Normal file
@@ -0,0 +1,5 @@
|
||||
ALTER TABLE RepoInfo ADD COLUMN status INTEGER DEFAULT 0;
|
||||
ALTER TABLE RepoSyncError RENAME TO TmpRepoSyncError;
|
||||
CREATE TABLE RepoSyncError (token CHAR(41) PRIMARY KEY, error_time BIGINT, error_con VARCHAR(1024));
|
||||
INSERT INTO RepoSyncError SELECT * FROM TmpRepoSyncError;
|
||||
DROP TABLE TmpRepoSyncError;
|
36
scripts/upgrade/sql/7.0.0/sqlite3/seahub.sql
Normal file
36
scripts/upgrade/sql/7.0.0/sqlite3/seahub.sql
Normal file
@@ -0,0 +1,36 @@
|
||||
CREATE TABLE IF NOT EXISTS "drafts_draft" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "username" varchar(255) NOT NULL, "origin_repo_id" varchar(36) NOT NULL, "origin_file_version" varchar(100) NOT NULL, "draft_file_path" varchar(1024) NOT NULL, "publish_file_version" varchar(100) NULL, "status" varchar(20) NOT NULL, "origin_file_uuid" char(32) NOT NULL);
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draft_created_at_e9f4523f" ON "drafts_draft" ("created_at");
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draft_updated_at_0a144b05" ON "drafts_draft" ("updated_at");
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draft_username_73e6738b" ON "drafts_draft" ("username");
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draft_origin_file_uuid_7c003c98" ON "drafts_draft" ("origin_file_uuid");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "drafts_draftreviewer" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "reviewer" varchar(255) NOT NULL, "draft_id" integer NOT NULL REFERENCES "drafts_draft" ("id"));
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draftreviewer_reviewer_e4c777ac" ON "drafts_draftreviewer" ("reviewer");
|
||||
CREATE INDEX IF NOT EXISTS "drafts_draftreviewer_draft_id_4ea59775" ON "drafts_draftreviewer" ("draft_id");
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_association" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "server_url" varchar(255) NOT NULL, "handle" varchar(255) NOT NULL, "secret" varchar(255) NOT NULL, "issued" integer NOT NULL, "lifetime" integer NOT NULL, "assoc_type" varchar(64) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_code" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "email" varchar(254) NOT NULL, "code" varchar(32) NOT NULL, "verified" bool NOT NULL, "timestamp" datetime NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_nonce" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "server_url" varchar(255) NOT NULL, "timestamp" integer NOT NULL, "salt" varchar(65) NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_partial" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "token" varchar(32) NOT NULL, "next_step" smallint unsigned NOT NULL, "backend" varchar(32) NOT NULL, "data" text NOT NULL, "timestamp" datetime NOT NULL);
|
||||
CREATE TABLE IF NOT EXISTS "social_auth_usersocialauth" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "username" varchar(255) NOT NULL, "provider" varchar(32) NOT NULL, "uid" varchar(255) NOT NULL, "extra_data" text NOT NULL);
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "repo_tags_repotags" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "repo_id" varchar(36) NOT NULL, "name" varchar(255) NOT NULL, "color" varchar(255) NOT NULL);
|
||||
CREATE INDEX IF NOT EXISTS "repo_tags_repotags_repo_id_1163a48f" ON "repo_tags_repotags" ("repo_id");
|
||||
CREATE INDEX IF NOT EXISTS "repo_tags_repotags_name_3f4c9027" ON "repo_tags_repotags" ("name");
|
||||
CREATE INDEX IF NOT EXISTS "repo_tags_repotags_color_1292b6c1" ON "repo_tags_repotags" ("color");
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "file_tags_filetags" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "file_uuid_id" char(32) NOT NULL REFERENCES "tags_fileuuidmap" ("uuid"), "repo_tag_id" integer NOT NULL REFERENCES "repo_tags_repotags" ("id"));
|
||||
CREATE INDEX IF NOT EXISTS "file_tags_filetags_file_uuid_id_e30f0ec8" ON "file_tags_filetags" ("file_uuid_id");
|
||||
CREATE INDEX IF NOT EXISTS "file_tags_filetags_repo_tag_id_c39660cb" ON "file_tags_filetags" ("repo_tag_id");
|
||||
|
||||
|
||||
CREATE TABLE IF NOT EXISTS "related_files_relatedfiles" ("id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, "o_uuid_id" char(32) NOT NULL REFERENCES "tags_fileuuidmap" ("uuid"), "r_uuid_id" char(32) NOT NULL REFERENCES "tags_fileuuidmap" ("uuid"));
|
||||
CREATE INDEX IF NOT EXISTS "related_files_relatedfiles_o_uuid_id_aaa8e613" ON "related_files_relatedfiles" ("o_uuid_id");
|
||||
CREATE INDEX IF NOT EXISTS "related_files_relatedfiles_r_uuid_id_031751df" ON "related_files_relatedfiles" ("r_uuid_id");
|
||||
|
||||
|
||||
ALTER TABLE "base_filecomment" ADD COLUMN "detail" text DEFAULT NULL;
|
||||
ALTER TABLE "base_filecomment" ADD COLUMN "resolved" bool NOT NULL DEFAULT 0;
|
||||
CREATE INDEX IF NOT EXISTS "base_filecomment_resolved_e0717eca" ON "base_filecomment" ("resolved");
|
239
scripts/upgrade/upgrade_6.3_7.0.sh
Executable file
239
scripts/upgrade/upgrade_6.3_7.0.sh
Executable file
@@ -0,0 +1,239 @@
|
||||
#!/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
|
||||
seafile_server_symlink=${TOPDIR}/seafile-server-latest
|
||||
seahub_data_dir=${TOPDIR}/seahub-data
|
||||
seahub_settings_py=${TOPDIR}/seahub_settings.py
|
||||
|
||||
manage_py=${INSTALLPATH}/seahub/manage.py
|
||||
|
||||
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
|
||||
export SEAFILE_CENTRAL_CONF_DIR=${default_conf_dir}
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:$PYTHONPATH
|
||||
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
|
||||
|
||||
prev_version=6.3
|
||||
current_version=7.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 python2.7 2>/dev/null 1>&2; then
|
||||
PYTHON=python2.7
|
||||
elif which python27 2>/dev/null 1>&2; then
|
||||
PYTHON=python27
|
||||
else
|
||||
echo
|
||||
echo "Can't find a python executable of version 2.7 or above in PATH"
|
||||
echo "Install python 2.7+ before continue."
|
||||
echo "Or if you installed it in a non-standard PATH, set the PYTHON enviroment varirable to it"
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function read_seafile_data_dir () {
|
||||
seafile_ini=${default_ccnet_conf_dir}/seafile.ini
|
||||
if [[ ! -f ${seafile_ini} ]]; then
|
||||
echo "${seafile_ini} not found. Now quit"
|
||||
exit 1
|
||||
fi
|
||||
seafile_data_dir=$(cat "${seafile_ini}")
|
||||
if [[ ! -d ${seafile_data_dir} ]]; then
|
||||
echo "Your seafile server data directory \"${seafile_data_dir}\" is invalid or doesn't exits."
|
||||
echo "Please check it first, or create this directory yourself."
|
||||
echo ""
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
export SEAFILE_CONF_DIR=$seafile_data_dir
|
||||
}
|
||||
|
||||
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}" 7.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_gunicorn_conf() {
|
||||
gunicorn_conf=${default_conf_dir}/gunicorn.conf
|
||||
if ! $(cat > ${gunicorn_conf} <<EOF
|
||||
import os
|
||||
|
||||
daemon = True
|
||||
workers = 5
|
||||
|
||||
# default localhost:8000
|
||||
bind = "127.0.0.1:8000"
|
||||
|
||||
# Pid
|
||||
pids_dir = '$default_pids_dir'
|
||||
pidfile = os.path.join(pids_dir, 'seahub.pid')
|
||||
|
||||
# for file upload, we need a longer timeout value (default is only 30s, too short)
|
||||
timeout = 1200
|
||||
|
||||
limit_request_line = 8190
|
||||
EOF
|
||||
); then
|
||||
echo "failed to generate gunicorn.conf";
|
||||
fi
|
||||
}
|
||||
|
||||
#################
|
||||
# The main execution flow of the script
|
||||
################
|
||||
|
||||
check_python_executable;
|
||||
read_seafile_data_dir;
|
||||
ensure_server_not_running;
|
||||
|
||||
update_database;
|
||||
migrate_avatars;
|
||||
|
||||
move_old_customdir_outside;
|
||||
make_media_custom_symlink;
|
||||
upgrade_seafile_server_latest_symlink;
|
||||
|
||||
add_gunicorn_conf;
|
||||
|
||||
echo
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo "Upgraded your seafile server successfully."
|
||||
echo "-----------------------------------------------------------------"
|
||||
echo
|
Reference in New Issue
Block a user