Date: Sun, 19 Mar 2017 16:22:08 +0000 (UTC) From: Nikolai Lifanov <lifanov@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r436504 - in head/net-mgmt/seafile-server: . files Message-ID: <201703191622.v2JGM8xl015243@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: lifanov Date: Sun Mar 19 16:22:08 2017 New Revision: 436504 URL: https://svnweb.freebsd.org/changeset/ports/436504 Log: fixes for net-mgmt/seafile-server Fix the setup scripts changing the generated configuration files to the correct uid/gid. The directions were also fixed for how to start and setup seafile/seahub correctly. This should fix any confusion when setting up seafile. This also augments pkg-message with better directions for setup. PR: 217873 Submitted by: ultima1252@gmail.com (maintainer) Added: head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile-mysql.py (contents, props changed) Modified: head/net-mgmt/seafile-server/Makefile head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile.sh head/net-mgmt/seafile-server/files/pkg-message.in Modified: head/net-mgmt/seafile-server/Makefile ============================================================================== --- head/net-mgmt/seafile-server/Makefile Sun Mar 19 16:11:40 2017 (r436503) +++ head/net-mgmt/seafile-server/Makefile Sun Mar 19 16:22:08 2017 (r436504) @@ -4,6 +4,7 @@ PORTNAME= seafile-server PORTVERSION= 6.0.8 DISTVERSIONPREFIX= v DISTVERSIONSUFFIX= -server +PORTREVISION= 1 CATEGORIES= net-mgmt MAINTAINER= ultima1252@gmail.com @@ -94,6 +95,8 @@ post-patch: ${REINPLACE_CMD} 's/<evhtp.h>/<evhtp\/evhtp.h>/' ${WRKSRC}/server/upload-file.c \ ${WRKSRC}/server/access-file.c ${WRKSRC}/server/http-server.c ${REINPLACE_CMD} -E 's/stat.+\$$/stat -f %Su $$/' ${WRKSRC}/scripts/seafile.sh + ${REINPLACE_CMD} 's/%%SEAFILE_USER%%/${USERS:[1]}/ ; s/%%SEAFILE_GROUP%%/${GROUPS:[1]}/' \ + ${WRKSRC}/scripts/setup-seafile.sh ${WRKSRC}/scripts/setup-seafile-mysql.py post-install: @${MKDIR} ${STAGEDIR}${PREFIX}/${SEABIN} ${STAGEDIR}${PREFIX}/${SEALIB} \ ${STAGEDIR}${PREFIX}/${SEAFILE_SERVER}/seafile/share/doc/seafile \ Added: head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile-mysql.py ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile-mysql.py Sun Mar 19 16:22:08 2017 (r436504) @@ -0,0 +1,80 @@ +--- scripts/setup-seafile-mysql.py.orig 2017-03-18 16:19:38 UTC ++++ scripts/setup-seafile-mysql.py +@@ -19,6 +19,8 @@ from ConfigParser import ConfigParser + + import MySQLdb + ++import pwd ++import grp + + try: + import readline # pylint: disable=W0611 +@@ -422,8 +424,6 @@ Please choose a way to initialize seafile databases: + if not re.match(r'^[a-zA-Z0-9_\-\.]+$', host): + raise InvalidAnswer('%s is not a valid host' % Utils.highlight(host)) + +- if host == 'localhost': +- host = '127.0.0.1' + return host + + def ask_mysql_host(self): +@@ -1167,17 +1167,23 @@ share_name = / + + class UserManualHandler(object): + def __init__(self): +- self.src_docs_dir = os.path.join(env_mgr.install_path, 'seafile', 'docs') ++ self.src_docs_dir = os.path.join(env_mgr.install_path, 'seafile', 'share', 'doc', 'seafile') + 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) + ++ uid = pwd.getpwnam("%%SEAFILE_USER%%").pw_uid ++ gid = grp.getgrnam("%%SEAFILE_GROUP%%").gr_gid ++ os.chown(self.library_template_dir, uid, gid) ++ + pattern = os.path.join(self.src_docs_dir, '*.doc') + + for doc in glob.glob(pattern): + Utils.must_copy(doc, self.library_template_dir) ++ doc_full = os.path.join(self.library_template_dir, os.path.basename(doc)) ++ os.chown(doc_full, uid, gid) + + def report_config(): + print +@@ -1242,6 +1248,8 @@ def create_seafile_server_symlink(): + def set_file_perm(): + filemode = 0600 + dirmode = 0700 ++ uid = pwd.getpwnam("%%SEAFILE_USER%%").pw_uid ++ gid = grp.getgrnam("%%SEAFILE_GROUP%%").gr_gid + files = [ + seahub_config.seahub_settings_py, + ] +@@ -1253,8 +1261,10 @@ def set_file_perm(): + ] + for fpath in files: + os.chmod(fpath, filemode) ++ os.chown(fpath, uid, gid) + for dpath in dirs: + os.chmod(dpath, dirmode) ++ os.chown(dpath, uid, gid) + + env_mgr = EnvManager() + ccnet_config = CcnetConfigurator() +@@ -1445,8 +1455,12 @@ def report_success(): + Your seafile server configuration has been finished successfully. + ----------------------------------------------------------------- + +-run seafile server: ./seafile.sh { start | stop | restart } +-run seahub server: ./seahub.sh { start <port> | stop | restart <port> } ++run seafile server: sysrc seafile_enable=YES ++ service seafile { start | stop | restart } ++run seahub server: sysrc seahub_enable=YES ++fastcgi (optional): sysrc seahub_fastcgi=1 ++ service seahub { start | stop | restart } ++run reset-admin: ./reset-admin.sh + + ----------------------------------------------------------------- + If you are behind a firewall, remember to allow input/output of these tcp ports: Modified: head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile.sh ============================================================================== --- head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile.sh Sun Mar 19 16:11:40 2017 (r436503) +++ head/net-mgmt/seafile-server/files/patch-scripts_setup-seafile.sh Sun Mar 19 16:22:08 2017 (r436504) @@ -1,11 +1,20 @@ ---- scripts/setup-seafile.sh.orig 2016-10-21 22:12:15 UTC +--- scripts/setup-seafile.sh.orig 2017-03-13 02:59:56 UTC +++ scripts/setup-seafile.sh -@@ -318,7 +318,11 @@ fi +@@ -15,6 +15,8 @@ use_existing_seafile="false" + + server_manual_http="https://github.com/haiwen/seafile/wiki" + ++os_bsd=$(uname | grep -cm1 -e BSD -e DragonFly) ++ + function welcome () { + echo "-----------------------------------------------------------------" + echo "This script will guide you to config and setup your seafile server." +@@ -318,10 +320,17 @@ fi } function copy_user_manuals() { - src_docs_dir=${INSTALLPATH}/seafile/docs/ -+ if [ $(uname | grep -e BSD -e DragonFly | wc -l) == "1" ]; then ++ if [ $os_bsd == "1" ]; then + src_docs_dir=${INSTALLPATH}/seafile/share/doc/seafile/ + else + src_docs_dir=${INSTALLPATH}/seafile/docs/ @@ -13,3 +22,45 @@ library_template_dir=${seafile_data_dir}/library-template mkdir -p ${library_template_dir} cp -f ${src_docs_dir}/*.doc ${library_template_dir} ++ if [ $os_bsd == "1" ]; then ++ chown -R %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "${library_template_dir}" ++ fi + } + + function parse_params() { +@@ -673,6 +682,13 @@ chmod 0600 "$dest_settings_py" + chmod 0700 "$default_ccnet_conf_dir" + chmod 0700 "$seafile_data_dir" + chmod 0700 "$default_conf_dir" ++if [ $os_bsd == "1" ]; then ++ chown %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$dest_settings_py" ++ chown %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$default_ccnet_conf_dir" ++ chown -R %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$seafile_data_dir" ++ chown %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$default_conf_dir" ++ chown %%SEAFILE_USER%%:%%SEAFILE_GROUP%% "$seahub_db" ++fi + + # ------------------------------------------- + # copy user manuals to library template +@@ -689,9 +705,18 @@ echo + echo "-----------------------------------------------------------------" + echo "Your seafile server configuration has been completed successfully." + echo "-----------------------------------------------------------------" +-echo +-echo "run seafile server: ./seafile.sh { start | stop | restart }" +-echo "run seahub server: ./seahub.sh { start <port> | stop | restart <port> }" ++echo ++if [ $os_bsd == "1" ]; then ++ echo "run seafile server: sysrc seafile_enable=YES" ++ echo " service seafile { start | stop | restart }" ++ echo "run seahub server: sysrc seahub_enable=YES" ++ echo "fastcgi (optional): sysrc seahub_fastcgi=1" ++ echo " service seahub { start | stop | restart }" ++ echo "run reset-admin: ./reset-admin.sh" ++else ++ echo "run seafile server: ./seafile.sh { start | stop | restart }" ++ echo "run seahub server: ./seahub.sh { start <port> | stop | restart <port> }" ++fi + echo + echo "-----------------------------------------------------------------" + echo "If the server is behind a firewall, remember to open these tcp ports:" Modified: head/net-mgmt/seafile-server/files/pkg-message.in ============================================================================== --- head/net-mgmt/seafile-server/files/pkg-message.in Sun Mar 19 16:11:40 2017 (r436503) +++ head/net-mgmt/seafile-server/files/pkg-message.in Sun Mar 19 16:22:08 2017 (r436504) @@ -1,10 +1,10 @@ -For an existing config, or creating a new one, fix the UID/GID. -Do not change %%PREFIX%%/%%SEAFILE_SERVER%% unless your front -end is using the seafile UID/GID as well. +To generate a new config, +cd %%PREFIX%%/%%SEAFILE_SERVER%% +Then choose sqlite or mysql, mysql needs to be setup with root. +sqlite: ./setup-seafile.sh +mysql: ./setup-seafile-mysql.sh +Further instructions will be provided after the setup script is finished. -chown -R seafile:seafile %%PREFIX%%/%%HAIWENDIR%%/conf \ - %%PREFIX%%/%%HAIWENDIR%%/ccnet %%PREFIX%%/%%HAIWENDIR%%/seafile-data \ - %%PREFIX%%/%%HAIWENDIR%%/pids %%PREFIX%%/%%HAIWENDIR%%/logs Don't forget to run update scripts after every minor and major update located in %%PREFIX%%/%%SEAFILE_SERVER%%/upgrade
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703191622.v2JGM8xl015243>