You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

583 lines
24 KiB

seafile-server: Update to 7.1.2, revamp package * Package scripts that are shipped by upstream in their binary download * Includes setup scripts (setup-seafile.sh to use SQLite, setup-seafile-mysql.{sh,py} to use MySQL) and control scripts (seafile.sh, seahub.sh) * Does not include seafile-admin, which is not shipped in upstream's binary download. Combined with the fact that it hasn't been updated to Python 3 suggests the script has been abandoned. * Replace previous init scripts with a simplified script * Previous init scripts (seafile.init, seahub.init) were modified from older versions of seafile.sh and seahub.sh, but they haven't kept up with changes to upstream's scripts * New init script (seafile-server.init) start/stops both Seafile and Seahub (there is no need to control them separately) by calling upstream's control scripts * Replace previous package config file with new config file * Options in previous config file (seafile.conf) were mainly for using Seahub in FastCGI mode. FastCGI was deprecated in Django 1.7 and removed in 1.9; upstream's control script will only start Seahub using Gunicorn. (Options for Gunicorn including port number can be changed by editing /etc/seafile/conf/gunicorn.conf.py.) * New config file (seafile-server.config) has one option that controls where the Seafile/Seahub data directories are stored * Patch scripts/binaries to use standard, system-wide directory locations * Script files (wrappers for binaries) in /usr/bin * Binaries (not meant to be run directly by the user) in /usr/libexec * Config files in /etc/seafile * Pid/socket files in /var/run/seafile * Logs in /var/log/seafile * Include a new script to create the first admin account * With upstream's original scripts, the user is required to interactively create the first admin account when Seahub is started for the first time * The user will now use the new script (create-seafile-admin.sh) to create the first admin account after setup (using setup-seafile.sh or setup-seafile-mysql.sh) and before starting Seafile/Seahub * seahub.sh is patched to only check if there is at least one admin account and exit with an error if there is no admin account * Remove build config options and add seafile-server-fuse package * The console option controls whether the console window is shown when Seafile server is run on Windows. It has no use on Linux. * The fuse option controls whether seaf-fuse is built. (seaf-fuse is a FUSE implementation that allows the Seafile database/file system to be mounted to a local directory.) seaf-fuse is now always built and is available in a separate package (seafile-server-fuse). * Add myself as a maintainer Signed-off-by: Jeffery To <jeffery.to@gmail.com>
5 years ago
  1. --- a/common/seaf-utils.c
  2. +++ b/common/seaf-utils.c
  3. @@ -236,7 +236,12 @@ create_ccnet_rpc_client ()
  4. SearpcNamedPipeClient *transport = NULL;
  5. char *pipe_path = NULL;
  6. - pipe_path = g_build_path ("/", seaf->ccnet_dir, CCNET_RPC_PIPE_NAME, NULL);
  7. + char *socket_dir = g_strdup (g_getenv ("SEAFILE_UCI_SOCKET_DIR"));
  8. + if (!socket_dir) {
  9. + socket_dir = g_strdup (seaf->ccnet_dir);
  10. + }
  11. + pipe_path = g_build_path ("/", socket_dir, CCNET_RPC_PIPE_NAME, NULL);
  12. + g_free (socket_dir);
  13. transport = searpc_create_named_pipe_client(pipe_path);
  14. g_free(pipe_path);
  15. if (!transport)
  16. --- a/controller/seafile-controller.c
  17. +++ b/controller/seafile-controller.c
  18. @@ -480,7 +480,10 @@ stop_services ()
  19. static void
  20. init_pidfile_path (SeafileController *ctl)
  21. {
  22. - char *pid_dir = g_build_filename (topdir, "pids", NULL);
  23. + char *pid_dir = g_strdup (g_getenv ("SEAFILE_UCI_PID_DIR"));
  24. + if (!pid_dir) {
  25. + pid_dir = g_build_filename (topdir, "pids", NULL);
  26. + }
  27. if (!g_file_test(pid_dir, G_FILE_TEST_EXISTS)) {
  28. if (g_mkdir(pid_dir, 0777) < 0) {
  29. seaf_warning("failed to create pid dir %s: %s", pid_dir, strerror(errno));
  30. @@ -492,6 +495,8 @@ init_pidfile_path (SeafileController *ct
  31. ctl->pidfile[PID_SERVER] = g_build_filename (pid_dir, "seaf-server.pid", NULL);
  32. ctl->pidfile[PID_SEAFDAV] = g_build_filename (pid_dir, "seafdav.pid", NULL);
  33. ctl->pidfile[PID_SEAFEVENTS] = g_build_filename (pid_dir, "seafevents.pid", NULL);
  34. +
  35. + g_free (pid_dir);
  36. }
  37. static int
  38. @@ -514,7 +519,10 @@ seaf_controller_init (SeafileController
  39. if (logdir == NULL) {
  40. char *topdir = g_path_get_dirname(config_dir);
  41. - logdir = g_build_filename (topdir, "logs", NULL);
  42. + logdir = g_strdup (g_getenv ("SEAFILE_UCI_LOG_DIR"));
  43. + if (!logdir) {
  44. + logdir = g_build_filename (topdir, "logs", NULL);
  45. + }
  46. if (checkdir_with_mkdir(logdir) < 0) {
  47. fprintf (stderr, "failed to create log folder \"%s\": %s\n",
  48. logdir, strerror(errno));
  49. @@ -523,10 +531,15 @@ seaf_controller_init (SeafileController
  50. g_free (topdir);
  51. }
  52. + char *socket_dir = g_strdup (g_getenv ("SEAFILE_UCI_SOCKET_DIR"));
  53. + if (!socket_dir) {
  54. + socket_dir = g_build_filename (installpath, "runtime", NULL);
  55. + }
  56. +
  57. ctl->central_config_dir = central_config_dir;
  58. ctl->config_dir = config_dir;
  59. ctl->seafile_dir = seafile_dir;
  60. - ctl->rpc_pipe_path = g_build_filename (installpath, "runtime", NULL);
  61. + ctl->rpc_pipe_path = socket_dir;
  62. ctl->logdir = logdir;
  63. if (read_seafdav_config() < 0) {
  64. --- a/python/seaserv/service.py
  65. +++ b/python/seaserv/service.py
  66. @@ -32,11 +32,17 @@ CCNET_CONF_PATH = _load_path_from_env('C
  67. SEAFILE_CONF_DIR = _load_path_from_env('SEAFILE_CONF_DIR')
  68. SEAFILE_CENTRAL_CONF_DIR = _load_path_from_env('SEAFILE_CENTRAL_CONF_DIR', check=False)
  69. SEAFILE_RPC_PIPE_PATH = _load_path_from_env ("SEAFILE_RPC_PIPE_PATH", check=False)
  70. +SEAFILE_UCI_SOCKET_DIR = _load_path_from_env('SEAFILE_UCI_SOCKET_DIR', check=False)
  71. -ccnet_pipe_path = os.path.join (CCNET_CONF_PATH, 'ccnet-rpc.sock')
  72. +ccnet_pipe_path = os.path.join (SEAFILE_UCI_SOCKET_DIR if SEAFILE_UCI_SOCKET_DIR else CCNET_CONF_PATH, 'ccnet-rpc.sock')
  73. ccnet_threaded_rpc = ccnet.CcnetThreadedRpcClient(ccnet_pipe_path)
  74. -seafile_pipe_path = os.path.join(SEAFILE_RPC_PIPE_PATH if SEAFILE_RPC_PIPE_PATH else SEAFILE_CONF_DIR,
  75. +socket_dir = SEAFILE_CONF_DIR
  76. +if SEAFILE_RPC_PIPE_PATH:
  77. + socket_dir = SEAFILE_RPC_PIPE_PATH
  78. +elif SEAFILE_UCI_SOCKET_DIR:
  79. + socket_dir = SEAFILE_UCI_SOCKET_DIR
  80. +seafile_pipe_path = os.path.join(socket_dir,
  81. 'seafile.sock')
  82. seafserv_threaded_rpc = seafile.ServerThreadedRpcClient(seafile_pipe_path)
  83. --- a/scripts/check_init_admin.py
  84. +++ b/scripts/check_init_admin.py
  85. @@ -284,7 +284,7 @@ class RPC(object):
  86. import ccnet
  87. ccnet_dir = os.environ['CCNET_CONF_DIR']
  88. central_config_dir = os.environ['SEAFILE_CENTRAL_CONF_DIR']
  89. - ccnet_named_pipe_path = ccnet_dir + '/' + 'ccnet-rpc.sock'
  90. + ccnet_named_pipe_path = os.environ.get('SEAFILE_UCI_SOCKET_DIR', ccnet_dir) + '/' + 'ccnet-rpc.sock'
  91. self.rpc_client = ccnet.CcnetThreadedRpcClient(ccnet_named_pipe_path)
  92. def get_db_email_users(self):
  93. --- a/scripts/reset-admin.sh
  94. +++ b/scripts/reset-admin.sh
  95. @@ -1,11 +1,13 @@
  96. #!/bin/bash
  97. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  98. +
  99. SCRIPT=$(readlink -f "$0")
  100. INSTALLPATH=/usr/share/seafile/seafile-server
  101. TOPDIR=$(dirname "${INSTALLPATH}")
  102. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  103. -default_seafile_data_dir=${TOPDIR}/seafile-data
  104. -central_config_dir=${TOPDIR}/conf
  105. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  106. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  107. +central_config_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  108. function check_python_executable() {
  109. if [[ "$PYTHON" != "" && -x $PYTHON ]]; then
  110. --- a/scripts/seaf-fsck.sh
  111. +++ b/scripts/seaf-fsck.sh
  112. @@ -2,12 +2,14 @@
  113. echo ""
  114. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  115. +
  116. SCRIPT=$(readlink -f "$0")
  117. INSTALLPATH=/usr/share/seafile/seafile-server
  118. TOPDIR=$(dirname "${INSTALLPATH}")
  119. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  120. -default_seafile_data_dir=${TOPDIR}/seafile-data
  121. -default_conf_dir=${TOPDIR}/conf
  122. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  123. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  124. +default_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  125. seaf_fsck=/usr/libexec/seaf-fsck
  126. export PATH=/usr/libexec:$PATH
  127. --- a/scripts/seaf-fuse.sh
  128. +++ b/scripts/seaf-fuse.sh
  129. @@ -2,12 +2,14 @@
  130. echo ""
  131. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  132. +
  133. SCRIPT=$(readlink -f "$0")
  134. INSTALLPATH=/usr/share/seafile/seafile-server
  135. TOPDIR=$(dirname "${INSTALLPATH}")
  136. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  137. -default_seafile_data_dir=${TOPDIR}/seafile-data
  138. -default_conf_dir=${TOPDIR}/conf
  139. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  140. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  141. +default_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  142. seaf_fuse=/usr/libexec/seaf-fuse
  143. export PATH=/usr/libexec:$PATH
  144. @@ -78,7 +80,7 @@ function start_seaf_fuse () {
  145. echo "Starting seaf-fuse, please wait ..."
  146. - logfile=${TOPDIR}/logs/seaf-fuse.log
  147. + logfile=${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}/seaf-fuse.log
  148. LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_fuse} \
  149. -c "${default_ccnet_conf_dir}" \
  150. --- a/scripts/seaf-gc.sh
  151. +++ b/scripts/seaf-gc.sh
  152. @@ -2,12 +2,14 @@
  153. echo ""
  154. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  155. +
  156. SCRIPT=$(readlink -f "$0")
  157. INSTALLPATH=/usr/share/seafile/seafile-server
  158. TOPDIR=$(dirname "${INSTALLPATH}")
  159. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  160. -default_seafile_data_dir=${TOPDIR}/seafile-data
  161. -default_conf_dir=${TOPDIR}/conf
  162. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  163. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  164. +default_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  165. seaf_gc=/usr/libexec/seafserv-gc
  166. seaf_gc_opts=""
  167. --- a/scripts/seafile.sh
  168. +++ b/scripts/seafile.sh
  169. @@ -12,12 +12,14 @@
  170. echo ""
  171. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  172. +
  173. SCRIPT=$(readlink -f "$0")
  174. INSTALLPATH=/usr/share/seafile/seafile-server
  175. TOPDIR=$(dirname "${INSTALLPATH}")
  176. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  177. -default_seafile_data_dir=${TOPDIR}/seafile-data
  178. -central_config_dir=${TOPDIR}/conf
  179. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  180. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  181. +central_config_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  182. seaf_controller="/usr/libexec/seafile-controller"
  183. export PATH=/usr/libexec:$PATH
  184. @@ -121,7 +123,7 @@ function start_seafile_server () {
  185. echo "Starting seafile server, please wait ..."
  186. - mkdir -p $TOPDIR/logs
  187. + mkdir -p ${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}
  188. LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} \
  189. -c "${default_ccnet_conf_dir}" \
  190. -d "${default_seafile_data_dir}" \
  191. --- a/scripts/seahub.sh
  192. +++ b/scripts/seahub.sh
  193. @@ -12,19 +12,21 @@
  194. echo ""
  195. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  196. +
  197. SCRIPT=$(readlink -f "$0")
  198. INSTALLPATH=/usr/share/seafile/seafile-server
  199. TOPDIR=$(dirname "${INSTALLPATH}")
  200. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  201. -default_seafile_data_dir=${TOPDIR}/seafile-data
  202. -central_config_dir=${TOPDIR}/conf
  203. -seafile_rpc_pipe_path=${INSTALLPATH}/runtime
  204. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  205. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  206. +central_config_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  207. +seafile_rpc_pipe_path=${SEAFILE_UCI_SOCKET_DIR-$INSTALLPATH/runtime}
  208. manage_py=${INSTALLPATH}/seahub/manage.py
  209. -gunicorn_conf=${TOPDIR}/conf/gunicorn.conf.py
  210. -pidfile=${TOPDIR}/pids/seahub.pid
  211. -errorlog=${TOPDIR}/logs/gunicorn_error.log
  212. -accesslog=${TOPDIR}/logs/gunicorn_access.log
  213. +gunicorn_conf=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf/gunicorn.conf.py
  214. +pidfile=${SEAFILE_UCI_PID_DIR-$TOPDIR/pids}/seahub.pid
  215. +errorlog=${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}/gunicorn_error.log
  216. +accesslog=${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}/gunicorn_access.log
  217. gunicorn_exe=/usr/bin/gunicorn3
  218. script_name=$0
  219. @@ -138,7 +140,7 @@ function warning_if_seafile_not_running
  220. }
  221. function prepare_seahub_log_dir() {
  222. - logdir=${TOPDIR}/logs
  223. + logdir=${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}
  224. if ! [[ -d ${logsdir} ]]; then
  225. if ! mkdir -p "${logdir}"; then
  226. echo "ERROR: failed to create logs dir \"${logdir}\""
  227. --- a/scripts/setup-seafile-mysql.py
  228. +++ b/scripts/setup-seafile-mysql.py
  229. @@ -300,9 +300,9 @@ class EnvManager(object):
  230. self.install_path = os.path.dirname(os.path.abspath(__file__))
  231. self.top_dir = os.path.dirname(self.install_path)
  232. self.bin_dir = '/usr/libexec'
  233. - self.central_config_dir = os.path.join(self.top_dir, 'conf')
  234. - self.central_pids_dir = os.path.join(self.top_dir, 'pids')
  235. - self.central_logs_dir = os.path.join(self.top_dir, 'logs')
  236. + self.central_config_dir = os.path.join(os.environ.get('SEAFILE_UCI_CONF_DIR', self.top_dir), 'conf')
  237. + self.central_pids_dir = os.environ.get('SEAFILE_UCI_PID_DIR', os.path.join(self.top_dir, 'pids'))
  238. + self.central_logs_dir = os.environ.get('SEAFILE_UCI_LOG_DIR', os.path.join(self.top_dir, 'logs'))
  239. Utils.must_mkdir(self.central_config_dir)
  240. def check_pre_condiction(self):
  241. @@ -790,7 +790,7 @@ class CcnetConfigurator(AbstractConfigur
  242. def __init__(self):
  243. '''Initialize default values of ccnet configuration'''
  244. AbstractConfigurator.__init__(self)
  245. - self.ccnet_dir = os.path.join(env_mgr.top_dir, 'ccnet')
  246. + self.ccnet_dir = os.path.join(os.environ.get('SEAFILE_UCI_CONF_DIR', env_mgr.top_dir), 'ccnet')
  247. self.port = 10001
  248. self.server_name = None
  249. self.ip_or_domain = None
  250. @@ -919,7 +919,7 @@ class CcnetConfigurator(AbstractConfigur
  251. class SeafileConfigurator(AbstractConfigurator):
  252. def __init__(self):
  253. AbstractConfigurator.__init__(self)
  254. - self.seafile_dir = os.path.join(env_mgr.top_dir, 'seafile-data')
  255. + self.seafile_dir = os.path.join(os.environ.get('SEAFILE_UCI_DATA_DIR', env_mgr.top_dir), 'seafile-data')
  256. self.port = 12001
  257. self.fileserver_port = None
  258. self.seafile_conf = os.path.join(env_mgr.central_config_dir, 'seafile.conf')
  259. @@ -983,7 +983,7 @@ class SeafileConfigurator(AbstractConfig
  260. question = 'Where do you want to put your seafile data?'
  261. key = 'seafile-data'
  262. note = 'Please use a volume with enough free space'
  263. - default = os.path.join(env_mgr.top_dir, 'seafile-data')
  264. + default = os.path.join(os.environ.get('SEAFILE_UCI_DATA_DIR', env_mgr.top_dir), 'seafile-data')
  265. self.seafile_dir = Utils.ask_question(question,
  266. key=key,
  267. note=note,
  268. @@ -1204,7 +1204,7 @@ class SeahubConfigurator(AbstractConfigu
  269. media_dir = os.path.join(env_mgr.install_path, 'seahub', 'media')
  270. orig_avatar_dir = os.path.join(media_dir, 'avatars')
  271. - seahub_data_dir = os.path.join(env_mgr.top_dir, 'seahub-data')
  272. + seahub_data_dir = os.path.join(os.environ.get('SEAFILE_UCI_DATA_DIR', env_mgr.top_dir), 'seahub-data')
  273. dest_avatar_dir = os.path.join(seahub_data_dir, 'avatars')
  274. if os.path.exists(dest_avatar_dir):
  275. @@ -1214,7 +1214,7 @@ class SeahubConfigurator(AbstractConfigu
  276. os.mkdir(seahub_data_dir)
  277. shutil.move(orig_avatar_dir, dest_avatar_dir)
  278. - os.symlink('../../../seahub-data/avatars', orig_avatar_dir)
  279. + os.symlink(dest_avatar_dir, orig_avatar_dir)
  280. except Exception as e:
  281. Utils.error('Failed to prepare seahub avatars dir: %s' % e)
  282. @@ -1390,7 +1390,7 @@ def check_params(args):
  283. seafile_config.fileserver_port = Utils.validate_port(fileserver_port)
  284. seafile_dir = get_param_val(args.seafile_dir, 'SEAFILE_DIR',
  285. - os.path.join(env_mgr.top_dir, 'seafile-data'))
  286. + os.path.join(os.environ.get('SEAFILE_UCI_DATA_DIR', env_mgr.top_dir), 'seafile-data'))
  287. seafile_config.seafile_dir = seafile_config.validate_seafile_dir(seafile_dir)
  288. global db_config
  289. --- a/scripts/setup-seafile-mysql.sh
  290. +++ b/scripts/setup-seafile-mysql.sh
  291. @@ -6,6 +6,8 @@
  292. set -e
  293. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  294. +
  295. SCRIPT=$(readlink -f "$0")
  296. INSTALLPATH=/usr/share/seafile/seafile-server
  297. --- a/scripts/setup-seafile.sh
  298. +++ b/scripts/setup-seafile.sh
  299. @@ -1,14 +1,16 @@
  300. #!/bin/bash
  301. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  302. +
  303. SCRIPT=$(readlink -f "$0")
  304. INSTALLPATH=/usr/share/seafile/seafile-server
  305. TOPDIR=$(dirname "${INSTALLPATH}")
  306. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  307. -default_seafile_data_dir=${TOPDIR}/seafile-data
  308. -default_seahub_db=${TOPDIR}/seahub.db
  309. -default_conf_dir=${TOPDIR}/conf
  310. -default_pids_dir=${TOPDIR}/pids
  311. -default_logs_dir=${TOPDIR}/logs
  312. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  313. +default_seafile_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data
  314. +default_seahub_db=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub.db
  315. +default_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  316. +default_pids_dir=${SEAFILE_UCI_PID_DIR-$TOPDIR/pids}
  317. +default_logs_dir=${SEAFILE_UCI_LOG_DIR-$TOPDIR/logs}
  318. export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
  319. @@ -516,7 +518,7 @@ gen_seafdav_conf;
  320. # -------------------------------------------
  321. # generate seahub/settings.py
  322. # -------------------------------------------
  323. -dest_settings_py=${TOPDIR}/conf/seahub_settings.py
  324. +dest_settings_py=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf/seahub_settings.py
  325. seahub_secret_keygen=${INSTALLPATH}/seahub/tools/secret_key_generator.py
  326. if [[ ! -f ${dest_settings_py} ]]; then
  327. @@ -621,44 +623,44 @@ function get_seahub_admin_passwd () {
  328. echo "Creating database now, it may take one minute, please wait... "
  329. echo
  330. -cd ${TOPDIR}/ccnet && mkdir -m 0755 GroupMgr misc OrgMgr PeerMgr && cd -
  331. +cd ${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet && mkdir -m 0755 GroupMgr misc OrgMgr PeerMgr && cd -
  332. -ccnet_group_db=${TOPDIR}/ccnet/GroupMgr/groupmgr.db
  333. +ccnet_group_db=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet/GroupMgr/groupmgr.db
  334. ccnet_group_sql=${INSTALLPATH}/sql/sqlite/groupmgr.sql
  335. if ! sqlite3 ${ccnet_group_db} ".read ${ccnet_group_sql}" 2>/dev/null 1>&2; then
  336. echo "Failed to sync ccnet groupmgr database."
  337. err_and_quit;
  338. fi
  339. -ccnet_config_db=${TOPDIR}/ccnet/misc/config.db
  340. +ccnet_config_db=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet/misc/config.db
  341. ccnet_config_sql=${INSTALLPATH}/sql/sqlite/config.sql
  342. if ! sqlite3 ${ccnet_config_db} ".read ${ccnet_config_sql}" 2>/dev/null 1>&2; then
  343. echo "Failed to sync ccnet config database."
  344. err_and_quit;
  345. fi
  346. -ccnet_org_db=${TOPDIR}/ccnet/OrgMgr/orgmgr.db
  347. +ccnet_org_db=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet/OrgMgr/orgmgr.db
  348. ccnet_org_sql=${INSTALLPATH}/sql/sqlite/org.sql
  349. if ! sqlite3 ${ccnet_org_db} ".read ${ccnet_org_sql}" 2>/dev/null 1>&2; then
  350. echo "Failed to sync ccnet org database."
  351. err_and_quit;
  352. fi
  353. -ccnet_user_db=${TOPDIR}/ccnet/PeerMgr/usermgr.db
  354. +ccnet_user_db=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet/PeerMgr/usermgr.db
  355. ccnet_user_sql=${INSTALLPATH}/sql/sqlite/user.sql
  356. if ! sqlite3 ${ccnet_user_db} ".read ${ccnet_user_sql}" 2>/dev/null 1>&2; then
  357. echo "Failed to sync ccnet user database."
  358. err_and_quit;
  359. fi
  360. -seafile_db=${TOPDIR}/seafile-data/seafile.db
  361. +seafile_db=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seafile-data/seafile.db
  362. seafile_sql=${INSTALLPATH}/sql/sqlite/seafile.sql
  363. if ! sqlite3 ${seafile_db} ".read ${seafile_sql}" 2>/dev/null 1>&2; then
  364. echo "Failed to sync seafile database."
  365. err_and_quit;
  366. fi
  367. -seahub_db=${TOPDIR}/seahub.db
  368. +seahub_db=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub.db
  369. seahub_sqls=${INSTALLPATH}/seahub/sql/sqlite3.sql
  370. if ! sqlite3 ${seahub_db} ".read ${seahub_sqls}" 2>/dev/null 1>&2; then
  371. echo "Failed to sync seahub database."
  372. @@ -671,12 +673,12 @@ echo "Done."
  373. media_dir=${INSTALLPATH}/seahub/media
  374. orig_avatar_dir=${INSTALLPATH}/seahub/media/avatars
  375. -dest_avatar_dir=${TOPDIR}/seahub-data/avatars
  376. +dest_avatar_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/avatars
  377. if [[ ! -d ${dest_avatar_dir} ]]; then
  378. - mkdir -p "${TOPDIR}/seahub-data"
  379. + mkdir -p "${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data"
  380. mv "${orig_avatar_dir}" "${dest_avatar_dir}"
  381. - ln -s ../../../seahub-data/avatars ${media_dir}
  382. + ln -s ${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/avatars ${media_dir}
  383. fi
  384. # Make a seafile-server symlink, like this:
  385. --- a/scripts/sqlite2mysql.sh
  386. +++ b/scripts/sqlite2mysql.sh
  387. @@ -13,17 +13,19 @@
  388. # (mysql> source ccnet-db.sql)
  389. #
  390. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  391. +
  392. CCNET_DB='ccnet-db.sql'
  393. SEAFILE_DB='seafile-db.sql'
  394. SEAHUB_DB='seahub-db.sql'
  395. ########## ccnet
  396. seafile_path=$(pwd)
  397. -if [ -f "${seafile_path}/conf/ccnet.conf" ]; then
  398. - USER_MGR_DB=${seafile_path}/ccnet/PeerMgr/usermgr.db
  399. - GRP_MGR_DB=${seafile_path}/ccnet/GroupMgr/groupmgr.db
  400. +if [ -f "${SEAFILE_UCI_CONF_DIR-$seafile_path}/conf/ccnet.conf" ]; then
  401. + USER_MGR_DB=${SEAFILE_UCI_CONF_DIR-$seafile_path}/ccnet/PeerMgr/usermgr.db
  402. + GRP_MGR_DB=${SEAFILE_UCI_CONF_DIR-$seafile_path}/ccnet/GroupMgr/groupmgr.db
  403. else
  404. - echo "${seafile_path}/conf/ccnet.conf does not exists."
  405. + echo "${SEAFILE_UCI_CONF_DIR-$seafile_path}/conf/ccnet.conf does not exists."
  406. read -p "Please provide your ccnet.conf path(e.g. /data/haiwen/conf/ccnet.conf): " ccnet_conf_path
  407. if [ -f ${ccnet_conf_path} ]; then
  408. USER_MGR_DB=$(dirname $(dirname "${ccnet_conf_path}"))/ccnet/PeerMgr/usermgr.db
  409. @@ -50,11 +52,11 @@ sed 's/email TEXT, role TEXT/email VARCH
  410. ########## seafile
  411. rm -rf ${SEAFILE_DB}
  412. -if [ -f "${seafile_path}/seafile-data/seafile.db" ]; then
  413. - echo "sqlite3 ${seafile_path}/seafile-data/seafile.db .dump | python sqlite2mysql.py > ${SEAFILE_DB}"
  414. - sqlite3 ${seafile_path}/seafile-data/seafile.db .dump | python sqlite2mysql.py > ${SEAFILE_DB}
  415. +if [ -f "${SEAFILE_UCI_DATA_DIR-$seafile_path}/seafile-data/seafile.db" ]; then
  416. + echo "sqlite3 ${SEAFILE_UCI_DATA_DIR-$seafile_path}/seafile-data/seafile.db .dump | python sqlite2mysql.py > ${SEAFILE_DB}"
  417. + sqlite3 ${SEAFILE_UCI_DATA_DIR-$seafile_path}/seafile-data/seafile.db .dump | python sqlite2mysql.py > ${SEAFILE_DB}
  418. else
  419. - echo "${seafile_path}/seafile-data/seafile.db does not exists."
  420. + echo "${SEAFILE_UCI_DATA_DIR-$seafile_path}/seafile-data/seafile.db does not exists."
  421. read -p "Please provide your seafile.db path(e.g. /data/haiwen/seafile-data/seafile.db): " seafile_db_path
  422. if [ -f ${seafile_db_path} ];then
  423. echo "sqlite3 ${seafile_db_path} .dump | python sqlite2mysql.py > ${SEAFILE_DB}"
  424. @@ -74,11 +76,11 @@ sed 's/user_name TEXT/user_name VARCHAR(
  425. ########## seahub
  426. rm -rf ${SEAHUB_DB}
  427. -if [ -f "${seafile_path}/seahub.db" ]; then
  428. - echo "sqlite3 ${seafile_path}/seahub.db .dump | tr -d '\n' | sed 's/;/;\n/g' | python sqlite2mysql.py > ${SEAHUB_DB}"
  429. - sqlite3 ${seafile_path}/seahub.db .dump | tr -d '\n' | sed 's/;/;\n/g' | python sqlite2mysql.py > ${SEAHUB_DB}
  430. +if [ -f "${SEAFILE_UCI_DATA_DIR-$seafile_path}/seahub.db" ]; then
  431. + echo "sqlite3 ${SEAFILE_UCI_DATA_DIR-$seafile_path}/seahub.db .dump | tr -d '\n' | sed 's/;/;\n/g' | python sqlite2mysql.py > ${SEAHUB_DB}"
  432. + sqlite3 ${SEAFILE_UCI_DATA_DIR-$seafile_path}/seahub.db .dump | tr -d '\n' | sed 's/;/;\n/g' | python sqlite2mysql.py > ${SEAHUB_DB}
  433. else
  434. - echo "${seafile_path}/seahub.db does not exists."
  435. + echo "${SEAFILE_UCI_DATA_DIR-$seafile_path}/seahub.db does not exists."
  436. read -p "Please prove your seahub.db path(e.g. /data/haiwen/seahub.db): " seahub_db_path
  437. if [ -f ${seahub_db_path} ]; then
  438. echo "sqlite3 ${seahub_db_path} .dump | tr -d '\n' | sed 's/;/;\n/g' | python sqlite2mysql.py > ${SEAHUB_DB}"
  439. --- a/scripts/upgrade/minor-upgrade.sh
  440. +++ b/scripts/upgrade/minor-upgrade.sh
  441. @@ -1,5 +1,7 @@
  442. #!/bin/bash
  443. +/etc/init.d/seafile-server generate_uci_conf && . /var/run/seafile/uci.conf
  444. +
  445. SCRIPT=$(readlink -f "$0") # haiwen/seafile-server-1.3.0/upgrade/upgrade_xx_xx.sh
  446. UPGRADE_DIR=$(dirname "$SCRIPT") # haiwen/seafile-server-1.3.0/upgrade/
  447. INSTALLPATH=$(dirname "$UPGRADE_DIR") # haiwen/seafile-server-1.3.0/
  448. @@ -15,11 +17,11 @@ read dummy
  449. media_dir=${INSTALLPATH}/seahub/media
  450. orig_avatar_dir=${INSTALLPATH}/seahub/media/avatars
  451. -dest_avatar_dir=${TOPDIR}/seahub-data/avatars
  452. +dest_avatar_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/avatars
  453. seafile_server_symlink=${TOPDIR}/seafile-server-latest
  454. -default_conf_dir=${TOPDIR}/conf
  455. -default_ccnet_conf_dir=${TOPDIR}/ccnet
  456. -seahub_data_dir=${TOPDIR}/seahub-data
  457. +default_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/conf
  458. +default_ccnet_conf_dir=${SEAFILE_UCI_CONF_DIR-$TOPDIR}/ccnet
  459. +seahub_data_dir=${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data
  460. elasticsearch_config_file=${seafile_server_symlink}/pro/elasticsearch/config/jvm.options
  461. function migrate_avatars() {
  462. @@ -37,7 +39,7 @@ function migrate_avatars() {
  463. elif [[ ! -L ${orig_avatar_dir} ]]; then
  464. mv "${orig_avatar_dir}"/* "${dest_avatar_dir}" 2>/dev/null 1>&2
  465. rm -rf "${orig_avatar_dir}"
  466. - ln -s ../../../seahub-data/avatars "${media_dir}"
  467. + ln -s ${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/avatars "${media_dir}"
  468. fi
  469. echo
  470. echo "DONE"
  471. @@ -51,14 +53,14 @@ function make_media_custom_symlink() {
  472. return
  473. elif [[ ! -e "${media_symlink}" ]]; then
  474. - ln -s ../../../seahub-data/custom "${media_symlink}"
  475. + ln -s ${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/custom "${media_symlink}"
  476. return
  477. elif [[ -d "${media_symlink}" ]]; then
  478. cp -rf "${media_symlink}" "${seahub_data_dir}/"
  479. rm -rf "${media_symlink}"
  480. - ln -s ../../../seahub-data/custom "${media_symlink}"
  481. + ln -s ${SEAFILE_UCI_DATA_DIR-$TOPDIR}/seahub-data/custom "${media_symlink}"
  482. fi
  483. }
  484. --- a/server/seaf-server.c
  485. +++ b/server/seaf-server.c
  486. @@ -767,8 +767,12 @@ static void start_rpc_service (const cha
  487. "set_server_config_boolean",
  488. searpc_signature_int__string_string_int());
  489. + const char *socket_dir = g_getenv ("SEAFILE_UCI_SOCKET_DIR");
  490. +
  491. if (rpc_pipe_path) {
  492. pipe_path = g_build_path ("/", rpc_pipe_path, SEAFILE_RPC_PIPE_NAME, NULL);
  493. + } else if (socket_dir) {
  494. + pipe_path = g_build_path ("/", socket_dir, SEAFILE_RPC_PIPE_NAME, NULL);
  495. } else {
  496. pipe_path = g_build_path ("/", seafile_dir, SEAFILE_RPC_PIPE_NAME, NULL);
  497. }
  498. @@ -973,8 +977,14 @@ main (int argc, char **argv)
  499. if (seafile_dir == NULL)
  500. seafile_dir = g_build_filename (ccnet_dir, "seafile", NULL);
  501. - if (logfile == NULL)
  502. - logfile = g_build_filename (seafile_dir, "seafile.log", NULL);
  503. + if (logfile == NULL) {
  504. + char *log_dir = g_strdup (g_getenv("SEAFILE_UCI_LOG_DIR"));
  505. + if (!log_dir) {
  506. + log_dir = g_strdup (seafile_dir);
  507. + }
  508. + logfile = g_build_filename (log_dir, "seafile.log", NULL);
  509. + g_free (log_dir);
  510. + }
  511. if (seafile_log_init (logfile, "info", "debug") < 0) {
  512. seaf_warning ("Failed to init log.\n");