mirror of
https://github.com/YunoHost-Apps/seafile_ynh.git
synced 2024-09-03 20:26:01 +02:00
Use Seafile install script instead of a copy
This commit is contained in:
parent
2e47976ec5
commit
b97655ebde
5402 changed files with 13 additions and 1041059 deletions
|
@ -11,20 +11,25 @@ if [[ ! $? -eq 0 ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
sudo apt-get install -y python2.7 python-setuptools python-simplejson python-imaging sqlite3
|
sudo apt-get install -y python2.7 python-setuptools python-simplejson python-imaging python-mysqldb
|
||||||
|
|
||||||
# Copy files to the right place
|
# Copy files to the right place
|
||||||
sudo mkdir -p $final_path
|
sudo mkdir -p $final_path
|
||||||
sudo cp -R ../sources/* $final_path/
|
sudo mkdir -p $final_path/installed
|
||||||
|
sudo mkdir -p $final_path/seafile-data
|
||||||
|
sudo mkdir -p $final_path/seafile-server-$seafile_version
|
||||||
|
sudo tar xvzf ../sources/'seafile-server_'$seafile_version'_x86-64.tar'
|
||||||
|
sudo mv ../sources/seafile-server-$seafile_version/* $final_path/seafile-server-$seafile_version
|
||||||
|
sudo mv ../sources/'seafile-server_'$seafile_version'_x86-64.tar' $final_path/installed
|
||||||
|
|
||||||
# Set permissions to seafile directory
|
# Set permissions to seafile directory
|
||||||
#sudo chown -R www-data: $final_path
|
sudo chown -R www-data: $final_path
|
||||||
sudo chmod +x $final_path/seafile-server-$seafile_version/seafile.sh
|
|
||||||
|
# Run install script
|
||||||
|
|
||||||
|
|
||||||
|
# Start Seafile Server
|
||||||
|
|
||||||
# Change configuration
|
|
||||||
# Port
|
|
||||||
# Domain
|
|
||||||
# Admin account
|
|
||||||
|
|
||||||
# Add Seafile Server to startup
|
# Add Seafile Server to startup
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -34,10 +39,6 @@ sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/seafile.conf
|
||||||
|
|
||||||
# Start Seafile Server
|
|
||||||
cd $final_path/seafile-server-*
|
|
||||||
sudo ./seafile.sh start
|
|
||||||
sudo ./seahub.sh start
|
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
# Reload Nginx and regenerate SSOwat conf
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,11 +0,0 @@
|
||||||
[General]
|
|
||||||
USER_NAME = Yunohost
|
|
||||||
ID = c1ee2e49c1517ee297a25f3bad4c674341956b9c
|
|
||||||
NAME = Yunohost
|
|
||||||
SERVICE_URL = http://wireynh2.mikangali.com:8000
|
|
||||||
|
|
||||||
[Network]
|
|
||||||
PORT = 10001
|
|
||||||
|
|
||||||
[Client]
|
|
||||||
PORT = 13418
|
|
|
@ -1,4 +0,0 @@
|
||||||
peer/c1ee2e49c1517ee297a25f3bad4c674341956b9c
|
|
||||||
name Yunohost
|
|
||||||
service-url http://wireynh2.mikangali.com:8000
|
|
||||||
pubkey 40K2tAhc2dcQU68MCU+zX3+fzJCZwCMbIcWahbfaBDEue684qPXO7Tr19WSJQvKHmZc/fpYUKQNFPM9r471cqPHhfzhatdI8SkZw/w8sORmif1S9EHxSoxDxEzafCR9efqPQejbu4fe64muhyeACIL0ru0hZNqdRGu/BjWldMIwz/WdPqqQnp4ghCH/sndYr34u52V+vnkMiTOR9tlUHZzl9TAz/LffnGBwN29gCxg43ZG+f7WhWVpap7Kb7HN91aIEMoW3EZgLMF2GsWfc2jxxaB3Q1xKYPMlU2gOlGez1/QOp7qz4CDb4ohl+lIhKaa6LDxL3zgu7/RLMsVkaJkw== Iw==
|
|
Binary file not shown.
|
@ -1,27 +0,0 @@
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEogIBAAKCAQEA40K2tAhc2dcQU68MCU+zX3+fzJCZwCMbIcWahbfaBDEue684
|
|
||||||
qPXO7Tr19WSJQvKHmZc/fpYUKQNFPM9r471cqPHhfzhatdI8SkZw/w8sORmif1S9
|
|
||||||
EHxSoxDxEzafCR9efqPQejbu4fe64muhyeACIL0ru0hZNqdRGu/BjWldMIwz/WdP
|
|
||||||
qqQnp4ghCH/sndYr34u52V+vnkMiTOR9tlUHZzl9TAz/LffnGBwN29gCxg43ZG+f
|
|
||||||
7WhWVpap7Kb7HN91aIEMoW3EZgLMF2GsWfc2jxxaB3Q1xKYPMlU2gOlGez1/QOp7
|
|
||||||
qz4CDb4ohl+lIhKaa6LDxL3zgu7/RLMsVkaJkwIBIwKCAQB04Hs4BE0CUVjalInY
|
|
||||||
5ykMisc2ATkg/ByVBon7oGF+f7GBcA6Cx479qUtLAIEbHaTSpY5eW8/ak/e437PU
|
|
||||||
NYAcXyODQY28mAG/zHSgbjQAG8/pto0ea9K6QzonI2e7jHm9eNGd8F2YyIv/ao24
|
|
||||||
R1GNLhZ9kuwNep69ZVw6GO4Y9q0yFykeE/XVxP5DVptnJNv/bJ0LvJ8YyN92vxJn
|
|
||||||
qsiu3v8cO+kcT8v4cudJcL1xy31ig1V1eSiNRc3qq+wQJi6cSufv+OPPzf2DpHNG
|
|
||||||
3J1vTCYDZJSgocXCn5msVwHUVdI18Lxam3HST9yCUxOAFlL7R6hcFtwtctzDAor4
|
|
||||||
5p7rAoGBAP+jimy8z7TEBGtivDxnqcLL1/5fm4KeNrVIOXmxBOn2uj20BFbRljHi
|
|
||||||
Lwc+2Qb/TQj3pEAc7HyJ0X/4sS1altIMSX8JJrk6JtEUTLPeMkFQyLWet4sLWKqu
|
|
||||||
OZgmT19Xa+8mnVgHBtBl8Yxt5z7lWyqMLpWwXrM8DrS9Imv1iTubAoGBAOOU6L2l
|
|
||||||
H2o1oRyUm0kmgS8U0lE4RzCIvrqBU+50oHrHIvo2d7hscTbS1Laqo8RNCtcQzADB
|
|
||||||
ZZkr2eCrp4K/U7qBpecMxqWJko4RVTTHUN+QlOi3eRfyvYBtOp42KZx4uOkjMe5J
|
|
||||||
XkYdFOEbD8BR4Vy99xFhTz7SDyt+KEBgUjVpAoGBAPhVuat1lpJYBEsPdQd6pOkd
|
|
||||||
yoITu6N1HzPCgPnfKVhOw4xluxKCdKV8oraU0tOY67+Revxz3mpZ/rbUVFfxmdNc
|
|
||||||
ZKdKt+cijBuQD/8vnoiXnmdJuZ0DtTgW9h7GITgLx++h2q1Ip4idi4+7OGj8D2sp
|
|
||||||
F0+VY08HJDqL2EueEEiHAoGAdQrA1o9vPe+x8XD/Z3LjWgq1Tld1EaVpZzsyeqJh
|
|
||||||
KTM2j082QZbbI4JexFfB7+0bhIxLqJ35vHzztV+X+hlBANT2PE+2nkbAZlIOkCv9
|
|
||||||
tM4DcF5biKi5OrvVAOinr46K+45xczus05ntexU7TPbo7d4KCPA3YiLjOvBseOEU
|
|
||||||
VfsCgYEA/xsbL2d9HfXnHUMzXSbFuBDHQndwnXZrz9W5gSq4N4N/ZyEtUbytBYsI
|
|
||||||
VFYwn4edPNTk8ye6bw/WMGlMS/YM0zFqcwPoIxCzipz9jRoHmaUBYmdm9R5OLmhG
|
|
||||||
980RjA9eDt0qO+jROHMCdfoc4owPg6DeqxC9G14kSJFkh5qKKZQ=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
|
@ -1 +0,0 @@
|
||||||
/var/www/seafile/seafile-data
|
|
|
@ -1,5 +0,0 @@
|
||||||
[WEBDAV]
|
|
||||||
enabled = false
|
|
||||||
port = 8080
|
|
||||||
fastcgi = false
|
|
||||||
share_name = /
|
|
|
@ -1,9 +0,0 @@
|
||||||
[08/06/14 22:20:03] ../common/session.c(385): Listen on 127.0.0.1 13418
|
|
||||||
[08/06/14 22:20:03] ../common/session.c(257): Update pubinfo file
|
|
||||||
[08/06/14 22:20:03] ../common/connect-mgr.c(515): Opened port 10001 to listen for incoming peer connections
|
|
||||||
[08/06/14 22:20:04] ../common/session.c(365): Accepted a local client
|
|
||||||
[08/06/14 22:20:04] ../common/session.c(365): Accepted a local client
|
|
||||||
[08/06/14 22:20:04] ../common/session.c(365): Accepted a local client
|
|
||||||
[08/06/14 22:20:04] ../common/session.c(365): Accepted a local client
|
|
||||||
[08/06/14 22:20:13] ../common/session.c(365): Accepted a local client
|
|
||||||
[08/06/14 22:20:38] ../common/peer.c(942): Local peer down
|
|
|
@ -1,15 +0,0 @@
|
||||||
[08/06/14 22:20:03] seafile-controller.c(155): starting ccnet-server ...
|
|
||||||
[08/06/14 22:20:03] seafile-controller.c(74): spawn_process: ccnet-server -c /var/www/seafile/ccnet -f /var/www/seafile/logs/ccnet.log -d -P /var/www/seafile/pids/ccnet.pid
|
|
||||||
[08/06/14 22:20:03] seafile-controller.c(89): spawned ccnet-server, pid 8067
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(594): ccnet daemon connected.
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(186): starting seaf-server ...
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(74): spawn_process: seaf-server -c /var/www/seafile/ccnet -d /var/www/seafile/seafile-data -l /var/www/seafile/logs/seafile.log -P /var/www/seafile/pids/seaf-server.pid
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(89): spawned seaf-server, pid 8071
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(423): pid file /var/www/seafile/pids/fileserver.pid does not exist
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(74): spawn_process: fileserver -c /var/www/seafile/ccnet -d /var/www/seafile/seafile-data -l /var/www/seafile/logs/fileserver.log -P /var/www/seafile/pids/fileserver.pid
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(89): spawned fileserver, pid 8072
|
|
||||||
[08/06/14 22:20:04] seafile-controller.c(567): seafdav not enabled.
|
|
||||||
[08/06/14 22:20:14] seafile-controller.c(423): pid file /var/www/seafile/pids/fileserver.pid does not exist
|
|
||||||
[08/06/14 22:20:14] seafile-controller.c(448): fileserver need restart...
|
|
||||||
[08/06/14 22:20:14] seafile-controller.c(74): spawn_process: fileserver -c /var/www/seafile/ccnet -d /var/www/seafile/seafile-data -l /var/www/seafile/logs/fileserver.log -P /var/www/seafile/pids/fileserver.pid
|
|
||||||
[08/06/14 22:20:14] seafile-controller.c(89): spawned fileserver, pid 8092
|
|
|
@ -1,3 +0,0 @@
|
||||||
[08/06/14 22:20:04] Seafile tmp dir /var/www/seafile/seafile-data/tmpfiles does not exist and is unable to create
|
|
||||||
[08/06/14 22:20:04] Failed to create seafile session.
|
|
||||||
[08/06/14 22:20:14] fileserver.c(337): host = 0.0.0.0, port = 8082
|
|
|
@ -1,3 +0,0 @@
|
||||||
[08/06/14 22:20:05] ../common/mq-mgr.c(60): [mq client] mq cilent is started
|
|
||||||
[08/06/14 22:20:05] ../common/mq-mgr.c(106): [mq mgr] publish to hearbeat mq: seaf_server.heartbeat
|
|
||||||
[08/06/14 22:20:05] listen-mgr.c(115): listen on port 12001 for block tranfer
|
|
|
@ -1 +0,0 @@
|
||||||
8070
|
|
|
@ -1 +0,0 @@
|
||||||
8093
|
|
|
@ -1 +0,0 @@
|
||||||
8074
|
|
Binary file not shown.
|
@ -1,5 +0,0 @@
|
||||||
[network]
|
|
||||||
port=12001
|
|
||||||
|
|
||||||
[fileserver]
|
|
||||||
port=8082
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +0,0 @@
|
||||||
{"description": "Added \"seafile-tutorial.doc\"", "root_id": "9831d33808cb73a85d4f56bdd6d767f85c4714a8", "no_local_history": 1, "repo_category": null, "commit_id": "033e4ead0ed10e2fbae39ed8b2a1785632553181", "repo_name": "My Library Template", "parent_id": "1f4714e629603dc5b0fc5c7ff7301d5cdbb54fcc", "repo_id": "4b859100-8af7-44f9-b6ed-aad56267a223", "creator_name": "System", "version": 1, "second_parent_id": null, "creator": "0000000000000000000000000000000000000000", "ctime": 1407378005, "repo_desc": "Template for creating 'My Libray' for users"}
|
|
|
@ -1 +0,0 @@
|
||||||
{"description": "Template for creating 'My Libray' for users", "root_id": "0000000000000000000000000000000000000000", "no_local_history": 1, "repo_category": null, "commit_id": "1f4714e629603dc5b0fc5c7ff7301d5cdbb54fcc", "repo_name": "My Library Template", "parent_id": null, "repo_id": "4b859100-8af7-44f9-b6ed-aad56267a223", "creator_name": "System", "version": 1, "second_parent_id": null, "creator": "0000000000000000000000000000000000000000", "ctime": 1407378005, "repo_desc": "Template for creating 'My Libray' for users"}
|
|
|
@ -1 +0,0 @@
|
||||||
xœ%ŒË E¥™µÊ£¥þ†KãdH&i‹4©Mÿ]ÀÕÜ99÷îà(âš\»ûäÊ«µ±Ó0J†^ .';9Þ{+¼áš)¦%çÃ`
œ:X‚ÃÒ¢×úÿ’'Œu涥ŒK“2-Õê%ŨS®¦1Hh<ÍxÎï"™ùâ³–}Ûr±¥<…äíÕH‰Œ‰ÂZ7<5A>5§7¥
|
|
|
@ -1 +0,0 @@
|
||||||
xœËA@0@ѫȬ-¦:r™2’† *ÄÝÕî¿ÅÀÏk?uaˆPg
8k5—(£F6•+=²-9Íc<C38D>DžE 2´y1Ü’.<2E>hˆ’<CB86>kûRž²Ç°.¿Þ„ŒŽ
|
|
|
@ -1,371 +0,0 @@
|
||||||
#coding: UTF-8
|
|
||||||
|
|
||||||
'''This script would check if there is admin, and prompt the user to create a new one if non exist'''
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
import time
|
|
||||||
import re
|
|
||||||
import shutil
|
|
||||||
import glob
|
|
||||||
import subprocess
|
|
||||||
import hashlib
|
|
||||||
import getpass
|
|
||||||
import uuid
|
|
||||||
import warnings
|
|
||||||
|
|
||||||
from ConfigParser import ConfigParser
|
|
||||||
|
|
||||||
try:
|
|
||||||
import readline # pylint: disable=W0611
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
SERVER_MANUAL_HTTP = 'https://github.com/haiwen/seafile/wiki'
|
|
||||||
|
|
||||||
class Utils(object):
|
|
||||||
'''Groups all helper functions here'''
|
|
||||||
@staticmethod
|
|
||||||
def welcome():
|
|
||||||
'''Show welcome message'''
|
|
||||||
welcome_msg = '''\
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
This script will guide you to setup your seafile server using MySQL.
|
|
||||||
Make sure you have read seafile server manual at
|
|
||||||
|
|
||||||
%s
|
|
||||||
|
|
||||||
Press ENTER to continue
|
|
||||||
-----------------------------------------------------------------''' % SERVER_MANUAL_HTTP
|
|
||||||
print welcome_msg
|
|
||||||
raw_input()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def highlight(content):
|
|
||||||
'''Add ANSI color to content to get it highlighted on terminal'''
|
|
||||||
return '\x1b[33m%s\x1b[m' % content
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def info(msg):
|
|
||||||
print msg
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def error(msg):
|
|
||||||
'''Print error and exit'''
|
|
||||||
print
|
|
||||||
print 'Error: ' + msg
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run_argv(argv, cwd=None, env=None, suppress_stdout=False, suppress_stderr=False):
|
|
||||||
'''Run a program and wait it to finish, and return its exit code. The
|
|
||||||
standard output of this program is supressed.
|
|
||||||
|
|
||||||
'''
|
|
||||||
with open(os.devnull, 'w') as devnull:
|
|
||||||
if suppress_stdout:
|
|
||||||
stdout = devnull
|
|
||||||
else:
|
|
||||||
stdout = sys.stdout
|
|
||||||
|
|
||||||
if suppress_stderr:
|
|
||||||
stderr = devnull
|
|
||||||
else:
|
|
||||||
stderr = sys.stderr
|
|
||||||
|
|
||||||
proc = subprocess.Popen(argv,
|
|
||||||
cwd=cwd,
|
|
||||||
stdout=stdout,
|
|
||||||
stderr=stderr,
|
|
||||||
env=env)
|
|
||||||
return proc.wait()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def run(cmdline, cwd=None, env=None, suppress_stdout=False, suppress_stderr=False):
|
|
||||||
'''Like run_argv but specify a command line string instead of argv'''
|
|
||||||
with open(os.devnull, 'w') as devnull:
|
|
||||||
if suppress_stdout:
|
|
||||||
stdout = devnull
|
|
||||||
else:
|
|
||||||
stdout = sys.stdout
|
|
||||||
|
|
||||||
if suppress_stderr:
|
|
||||||
stderr = devnull
|
|
||||||
else:
|
|
||||||
stderr = sys.stderr
|
|
||||||
|
|
||||||
proc = subprocess.Popen(cmdline,
|
|
||||||
cwd=cwd,
|
|
||||||
stdout=stdout,
|
|
||||||
stderr=stderr,
|
|
||||||
env=env,
|
|
||||||
shell=True)
|
|
||||||
return proc.wait()
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def prepend_env_value(name, value, env=None, seperator=':'):
|
|
||||||
'''prepend a new value to a list'''
|
|
||||||
if env is None:
|
|
||||||
env = os.environ
|
|
||||||
|
|
||||||
try:
|
|
||||||
current_value = env[name]
|
|
||||||
except KeyError:
|
|
||||||
current_value = ''
|
|
||||||
|
|
||||||
new_value = value
|
|
||||||
if current_value:
|
|
||||||
new_value += seperator + current_value
|
|
||||||
|
|
||||||
env[name] = new_value
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def must_mkdir(path):
|
|
||||||
'''Create a directory, exit on failure'''
|
|
||||||
try:
|
|
||||||
os.mkdir(path)
|
|
||||||
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:
|
|
||||||
sep = ';'
|
|
||||||
else:
|
|
||||||
sep = ':'
|
|
||||||
|
|
||||||
dirs = os.environ['PATH'].split(sep)
|
|
||||||
for d in dirs:
|
|
||||||
d = d.strip()
|
|
||||||
if d == '':
|
|
||||||
continue
|
|
||||||
path = os.path.join(d, prog)
|
|
||||||
if os.path.exists(path):
|
|
||||||
return path
|
|
||||||
|
|
||||||
return None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def get_python_executable():
|
|
||||||
'''Return the python executable. This should be the PYTHON environment
|
|
||||||
variable which is set in setup-seafile-mysql.sh
|
|
||||||
|
|
||||||
'''
|
|
||||||
return os.environ['PYTHON']
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def read_config(fn):
|
|
||||||
'''Return a case sensitive ConfigParser by reading the file "fn"'''
|
|
||||||
cp = ConfigParser()
|
|
||||||
cp.optionxform = str
|
|
||||||
cp.read(fn)
|
|
||||||
|
|
||||||
return cp
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def write_config(cp, fn):
|
|
||||||
'''Return a case sensitive ConfigParser by reading the file "fn"'''
|
|
||||||
with open(fn, 'w') as fp:
|
|
||||||
cp.write(fp)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def ask_question(desc,
|
|
||||||
key=None,
|
|
||||||
note=None,
|
|
||||||
default=None,
|
|
||||||
validate=None,
|
|
||||||
yes_or_no=False,
|
|
||||||
password=False):
|
|
||||||
'''Ask a question, return the answer.
|
|
||||||
@desc description, e.g. "What is the port of ccnet?"
|
|
||||||
|
|
||||||
@key a name to represent the target of the question, e.g. "port for
|
|
||||||
ccnet server"
|
|
||||||
|
|
||||||
@note additional information for the question, e.g. "Must be a valid
|
|
||||||
port number"
|
|
||||||
|
|
||||||
@default the default value of the question. If the default value is
|
|
||||||
not None, when the user enter nothing and press [ENTER], the default
|
|
||||||
value would be returned
|
|
||||||
|
|
||||||
@validate a function that takes the user input as the only parameter
|
|
||||||
and validate it. It should return a validated value, or throws an
|
|
||||||
"InvalidAnswer" exception if the input is not valid.
|
|
||||||
|
|
||||||
@yes_or_no If true, the user must answer "yes" or "no", and a boolean
|
|
||||||
value would be returned
|
|
||||||
|
|
||||||
@password If true, the user input would not be echoed to the
|
|
||||||
console
|
|
||||||
|
|
||||||
'''
|
|
||||||
assert key or yes_or_no
|
|
||||||
# Format description
|
|
||||||
print
|
|
||||||
if note:
|
|
||||||
desc += '\n' + note
|
|
||||||
|
|
||||||
desc += '\n'
|
|
||||||
if yes_or_no:
|
|
||||||
desc += '[ yes or no ]'
|
|
||||||
else:
|
|
||||||
if default:
|
|
||||||
desc += '[ default "%s" ]' % default
|
|
||||||
else:
|
|
||||||
desc += '[ %s ]' % key
|
|
||||||
|
|
||||||
desc += ' '
|
|
||||||
while True:
|
|
||||||
# prompt for user input
|
|
||||||
if password:
|
|
||||||
answer = getpass.getpass(desc).strip()
|
|
||||||
else:
|
|
||||||
answer = raw_input(desc).strip()
|
|
||||||
|
|
||||||
# No user input: use default
|
|
||||||
if not answer:
|
|
||||||
if default:
|
|
||||||
answer = default
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# Have user input: validate answer
|
|
||||||
if yes_or_no:
|
|
||||||
if answer not in ['yes', 'no']:
|
|
||||||
print Utils.highlight('\nPlease answer yes or no\n')
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return answer == 'yes'
|
|
||||||
else:
|
|
||||||
if validate:
|
|
||||||
try:
|
|
||||||
return validate(answer)
|
|
||||||
except InvalidAnswer, e:
|
|
||||||
print Utils.highlight('\n%s\n' % e)
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
return answer
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def validate_port(port):
|
|
||||||
try:
|
|
||||||
port = int(port)
|
|
||||||
except ValueError:
|
|
||||||
raise InvalidAnswer('%s is not a valid port' % Utils.highlight(port))
|
|
||||||
|
|
||||||
if port <= 0 or port > 65535:
|
|
||||||
raise InvalidAnswer('%s is not a valid port' % Utils.highlight(port))
|
|
||||||
|
|
||||||
return port
|
|
||||||
|
|
||||||
|
|
||||||
class InvalidAnswer(Exception):
|
|
||||||
def __init__(self, msg):
|
|
||||||
Exception.__init__(self)
|
|
||||||
self.msg = msg
|
|
||||||
def __str__(self):
|
|
||||||
return self.msg
|
|
||||||
|
|
||||||
### END of Utils
|
|
||||||
####################
|
|
||||||
|
|
||||||
class RPC(object):
|
|
||||||
def __init__(self):
|
|
||||||
import ccnet
|
|
||||||
ccnet_dir = os.environ['CCNET_CONF_DIR']
|
|
||||||
self.rpc_client = ccnet.CcnetThreadedRpcClient(ccnet.ClientPool(ccnet_dir))
|
|
||||||
|
|
||||||
def get_db_email_users(self):
|
|
||||||
return self.rpc_client.get_emailusers('DB', 0, 1)
|
|
||||||
|
|
||||||
def create_admin(self, email, user):
|
|
||||||
return self.rpc_client.add_emailuser(email, user, 1, 1)
|
|
||||||
|
|
||||||
def need_create_admin():
|
|
||||||
users = rpc.get_db_email_users()
|
|
||||||
return len(users) == 0
|
|
||||||
|
|
||||||
def create_admin(email, passwd):
|
|
||||||
if rpc.create_admin(email, passwd) < 0:
|
|
||||||
raise Exception('failed to create admin')
|
|
||||||
else:
|
|
||||||
print '\n\n'
|
|
||||||
print '----------------------------------------'
|
|
||||||
print 'Successfully created seafile admin'
|
|
||||||
print '----------------------------------------'
|
|
||||||
print '\n\n'
|
|
||||||
|
|
||||||
def ask_admin_email():
|
|
||||||
print
|
|
||||||
print '----------------------------------------'
|
|
||||||
print 'It\'s the first time you start the seafile server. Now let\'s create the admin account'
|
|
||||||
print '----------------------------------------'
|
|
||||||
def validate(email):
|
|
||||||
# whitespace is not allowed
|
|
||||||
if re.match(r'[\s]', email):
|
|
||||||
raise InvalidAnswer('%s is not a valid email address' % Utils.highlight(email))
|
|
||||||
# must be a valid email address
|
|
||||||
if not re.match(r'^.+@.*\..+$', email):
|
|
||||||
raise InvalidAnswer('%s is not a valid email address' % Utils.highlight(email))
|
|
||||||
|
|
||||||
return email
|
|
||||||
|
|
||||||
key = 'admin email'
|
|
||||||
question = 'What is the ' + Utils.highlight('email') + ' for the admin account?'
|
|
||||||
return Utils.ask_question(question,
|
|
||||||
key=key,
|
|
||||||
validate=validate)
|
|
||||||
|
|
||||||
def ask_admin_password():
|
|
||||||
def validate(password):
|
|
||||||
key = 'admin password again'
|
|
||||||
question = 'Enter the ' + Utils.highlight('password again:')
|
|
||||||
password_again = Utils.ask_question(question,
|
|
||||||
key=key,
|
|
||||||
password=True)
|
|
||||||
|
|
||||||
if password_again != password:
|
|
||||||
raise InvalidAnswer('password mismatch')
|
|
||||||
|
|
||||||
return password
|
|
||||||
|
|
||||||
key = 'admin password'
|
|
||||||
question = 'What is the ' + Utils.highlight('password') + ' for the admin account?'
|
|
||||||
return Utils.ask_question(question,
|
|
||||||
key=key,
|
|
||||||
password=True,
|
|
||||||
validate=validate)
|
|
||||||
|
|
||||||
rpc = RPC()
|
|
||||||
|
|
||||||
def main():
|
|
||||||
if not need_create_admin():
|
|
||||||
return
|
|
||||||
|
|
||||||
email = ask_admin_email()
|
|
||||||
passwd = ask_admin_password()
|
|
||||||
|
|
||||||
create_admin(email, passwd)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
try:
|
|
||||||
main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
print '\n\n\n'
|
|
||||||
print Utils.highlight('Aborted.')
|
|
||||||
print
|
|
||||||
sys.exit(1)
|
|
||||||
except Exception, e:
|
|
||||||
print
|
|
||||||
print Utils.highlight('Error happened during creating seafile admin.')
|
|
||||||
print
|
|
|
@ -1,55 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
SCRIPT=$(readlink -f "$0")
|
|
||||||
INSTALLPATH=$(dirname "${SCRIPT}")
|
|
||||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
|
||||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
|
||||||
|
|
||||||
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
|
|
||||||
elif which python2.6 2>/dev/null 1>&2; then
|
|
||||||
PYTHON=python2.6
|
|
||||||
elif which python26 2>/dev/null 1>&2; then
|
|
||||||
PYTHON=python26
|
|
||||||
else
|
|
||||||
echo
|
|
||||||
echo "Can't find a python executable of version 2.6 or above in PATH"
|
|
||||||
echo "Install python 2.6+ 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
|
|
||||||
}
|
|
||||||
|
|
||||||
check_python_executable;
|
|
||||||
read_seafile_data_dir;
|
|
||||||
|
|
||||||
export CCNET_CONF_DIR=${default_ccnet_conf_dir}
|
|
||||||
export SEAFILE_CONF_DIR=${seafile_data_dir}
|
|
||||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.6/site-packages:${INSTALLPATH}/seafile/lib64/python2.6/site-packages:${INSTALLPATH}/seahub/thirdpart:$PYTHONPATH
|
|
||||||
export PYTHONPATH=${INSTALLPATH}/seafile/lib/python2.7/site-packages:${INSTALLPATH}/seafile/lib64/python2.7/site-packages:$PYTHONPATH
|
|
||||||
|
|
||||||
manage_py=${INSTALLPATH}/seahub/manage.py
|
|
||||||
exec "$PYTHON" "$manage_py" createsuperuser
|
|
|
@ -1,12 +0,0 @@
|
||||||
import os
|
|
||||||
|
|
||||||
daemon = True
|
|
||||||
workers = 3
|
|
||||||
|
|
||||||
# Logging
|
|
||||||
runtime_dir = os.path.dirname(__file__)
|
|
||||||
pidfile = os.path.join(runtime_dir, 'seahub.pid')
|
|
||||||
errorlog = os.path.join(runtime_dir, 'error.log')
|
|
||||||
accesslog = os.path.join(runtime_dir, 'access.log')
|
|
||||||
# for file upload, we need a longer timeout value (default is only 30s, too short)
|
|
||||||
timeout = 1200
|
|
|
@ -1 +0,0 @@
|
||||||
8112
|
|
|
@ -1,133 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
SCRIPT=$(readlink -f "$0")
|
|
||||||
INSTALLPATH=$(dirname "${SCRIPT}")
|
|
||||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
|
||||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
|
||||||
seaf_fuse=${INSTALLPATH}/seafile/bin/seaf-fuse
|
|
||||||
|
|
||||||
export PATH=${INSTALLPATH}/seafile/bin:$PATH
|
|
||||||
export SEAFILE_LD_LIBRARY_PATH=${INSTALLPATH}/seafile/lib/:${INSTALLPATH}/seafile/lib64:${LD_LIBRARY_PATH}
|
|
||||||
|
|
||||||
script_name=$0
|
|
||||||
function usage () {
|
|
||||||
echo "usage : "
|
|
||||||
echo "$(basename ${script_name}) { start <mount-point> | stop | restart <mount-point> } "
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# check args
|
|
||||||
if [[ "$1" != "start" && "$1" != "stop" && "$1" != "restart" ]]; then
|
|
||||||
usage;
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ($1 == "start" || $1 == "restart" ) && $# != 2 ]]; then
|
|
||||||
usage;
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $1 == "stop" && $# != 1 ]]; then
|
|
||||||
usage;
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
mount_point=$2
|
|
||||||
|
|
||||||
function validate_ccnet_conf_dir () {
|
|
||||||
if [[ ! -d ${default_ccnet_conf_dir} ]]; then
|
|
||||||
echo "Error: there is no ccnet config directory."
|
|
||||||
echo "Have you run setup-seafile.sh before this?"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
function validate_already_running () {
|
|
||||||
if pid=$(pgrep -f "seaf-fuse -c ${default_ccnet_conf_dir}" 2>/dev/null); then
|
|
||||||
echo "seaf-fuse is already running, pid $pid"
|
|
||||||
echo
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function warning_if_seafile_not_running () {
|
|
||||||
if ! pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
|
|
||||||
echo
|
|
||||||
echo "Warning: seafile-controller not running. Have you run \"./seafile.sh start\" ?"
|
|
||||||
echo
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_seaf_fuse () {
|
|
||||||
validate_already_running;
|
|
||||||
warning_if_seafile_not_running;
|
|
||||||
validate_ccnet_conf_dir;
|
|
||||||
read_seafile_data_dir;
|
|
||||||
|
|
||||||
echo "Starting seaf-fuse, please wait ..."
|
|
||||||
|
|
||||||
logfile=${TOPDIR}/logs/seaf-fuse.log
|
|
||||||
|
|
||||||
LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_fuse} \
|
|
||||||
-c "${default_ccnet_conf_dir}" -d "${seafile_data_dir}" -l "${logfile}" \
|
|
||||||
"${mount_point}"
|
|
||||||
|
|
||||||
sleep 2
|
|
||||||
|
|
||||||
# check if seaf-fuse started successfully
|
|
||||||
if ! pgrep -f "seaf-fuse -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
|
|
||||||
echo "Failed to start seaf-fuse"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "seaf-fuse started"
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop_seaf_fuse() {
|
|
||||||
if ! pgrep -f "seaf-fuse -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
|
|
||||||
echo "seaf-fuse not running yet"
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Stopping seaf-fuse ..."
|
|
||||||
pkill -SIGTERM -f "seaf-fuse -c ${default_ccnet_conf_dir}"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function restart_seaf_fuse () {
|
|
||||||
stop_seaf_fuse
|
|
||||||
sleep 2
|
|
||||||
start_seaf_fuse
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
"start" )
|
|
||||||
start_seaf_fuse;
|
|
||||||
;;
|
|
||||||
"stop" )
|
|
||||||
stop_seaf_fuse;
|
|
||||||
;;
|
|
||||||
"restart" )
|
|
||||||
restart_seaf_fuse;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Done."
|
|
|
@ -1,152 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
### BEGIN INIT INFO
|
|
||||||
# Provides: seafile
|
|
||||||
# Required-Start: $local_fs $remote_fs $network
|
|
||||||
# Required-Stop: $local_fs
|
|
||||||
# Default-Start: 1 2 3 4 5
|
|
||||||
# Default-Stop:
|
|
||||||
# Short-Description: Starts Seafile Server
|
|
||||||
# Description: starts Seafile Server
|
|
||||||
### END INIT INFO
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
SCRIPT=$(readlink -f "$0")
|
|
||||||
INSTALLPATH=$(dirname "${SCRIPT}")
|
|
||||||
TOPDIR=$(dirname "${INSTALLPATH}")
|
|
||||||
default_ccnet_conf_dir=${TOPDIR}/ccnet
|
|
||||||
ccnet_pidfile=${INSTALLPATH}/runtime/ccnet.pid
|
|
||||||
seaf_controller="${INSTALLPATH}/seafile/bin/seafile-controller"
|
|
||||||
|
|
||||||
|
|
||||||
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}
|
|
||||||
|
|
||||||
script_name=$0
|
|
||||||
function usage () {
|
|
||||||
echo "usage : "
|
|
||||||
echo "$(basename ${script_name}) { start | stop | restart } "
|
|
||||||
echo ""
|
|
||||||
}
|
|
||||||
|
|
||||||
# check args
|
|
||||||
if [[ $# != 1 || ( "$1" != "start" && "$1" != "stop" && "$1" != "restart" ) ]]; then
|
|
||||||
usage;
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
function validate_ccnet_conf_dir () {
|
|
||||||
if [[ ! -d ${default_ccnet_conf_dir} ]]; then
|
|
||||||
echo "Error: there is no ccnet config directory."
|
|
||||||
echo "Have you run setup-seafile.sh before this?"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
function test_config() {
|
|
||||||
if ! LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} --test -c "${default_ccnet_conf_dir}" -d "${seafile_data_dir}"; then
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function check_component_running() {
|
|
||||||
name=$1
|
|
||||||
cmd=$2
|
|
||||||
if pid=$(pgrep -f "$cmd" 2>/dev/null); then
|
|
||||||
echo "[$name] is running, pid $pid. You can stop it by: "
|
|
||||||
echo
|
|
||||||
echo " kill $pid"
|
|
||||||
echo
|
|
||||||
echo "Stop it and try again."
|
|
||||||
echo
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function validate_already_running () {
|
|
||||||
if pid=$(pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null); then
|
|
||||||
echo "Seafile controller is already running, pid $pid"
|
|
||||||
echo
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
check_component_running "ccnet-server" "ccnet-server -c ${default_ccnet_conf_dir}"
|
|
||||||
check_component_running "seaf-server" "seaf-server -c ${default_ccnet_conf_dir}"
|
|
||||||
check_component_running "fileserver" "fileserver -c ${default_ccnet_conf_dir}"
|
|
||||||
check_component_running "seafdav" "wsgidav.server.run_server"
|
|
||||||
}
|
|
||||||
|
|
||||||
function start_seafile_server () {
|
|
||||||
validate_already_running;
|
|
||||||
validate_ccnet_conf_dir;
|
|
||||||
read_seafile_data_dir;
|
|
||||||
test_config;
|
|
||||||
|
|
||||||
echo "Starting seafile server, please wait ..."
|
|
||||||
|
|
||||||
LD_LIBRARY_PATH=$SEAFILE_LD_LIBRARY_PATH ${seaf_controller} -c "${default_ccnet_conf_dir}" -d "${seafile_data_dir}"
|
|
||||||
|
|
||||||
sleep 3
|
|
||||||
|
|
||||||
# check if seafile server started successfully
|
|
||||||
if ! pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
|
|
||||||
echo "Failed to start seafile server"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Seafile server started"
|
|
||||||
echo
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop_seafile_server () {
|
|
||||||
if ! pgrep -f "seafile-controller -c ${default_ccnet_conf_dir}" 2>/dev/null 1>&2; then
|
|
||||||
echo "seafile server not running yet"
|
|
||||||
return 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Stopping seafile server ..."
|
|
||||||
pkill -SIGTERM -f "seafile-controller -c ${default_ccnet_conf_dir}"
|
|
||||||
pkill -f "ccnet-server -c ${default_ccnet_conf_dir}"
|
|
||||||
pkill -f "seaf-server -c ${default_ccnet_conf_dir}"
|
|
||||||
pkill -f "fileserver -c ${default_ccnet_conf_dir}"
|
|
||||||
pkill -f "soffice.*--invisible --nocrashreport"
|
|
||||||
pkill -f "wsgidav.server.run_server"
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function restart_seafile_server () {
|
|
||||||
stop_seafile_server;
|
|
||||||
sleep 2
|
|
||||||
start_seafile_server;
|
|
||||||
}
|
|
||||||
|
|
||||||
case $1 in
|
|
||||||
"start" )
|
|
||||||
start_seafile_server;
|
|
||||||
;;
|
|
||||||
"stop" )
|
|
||||||
stop_seafile_server;
|
|
||||||
;;
|
|
||||||
"restart" )
|
|
||||||
restart_seafile_server;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "Done."
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +0,0 @@
|
||||||
from ccnet.errors import NetworkError
|
|
||||||
from ccnet.sync_client import SyncClient
|
|
||||||
|
|
||||||
from ccnet.pool import ClientPool
|
|
||||||
from ccnet.rpc import RpcClientBase, CcnetRpcClient, CcnetThreadedRpcClient
|
|
||||||
|
|
||||||
from ccnet.message import Message
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,14 +0,0 @@
|
||||||
'''
|
|
||||||
@module: ccnet.async
|
|
||||||
@description: The async client of ccnet depends on python-libevent,
|
|
||||||
so we move it to a standalone package.
|
|
||||||
|
|
||||||
'''
|
|
||||||
from .async_client import AsyncClient
|
|
||||||
|
|
||||||
from .processor import Processor
|
|
||||||
from .rpcserverproc import RpcServerProc
|
|
||||||
from .sendcmdproc import SendCmdProc
|
|
||||||
from .mqclientproc import MqClientProc
|
|
||||||
|
|
||||||
from .timer import Timer
|
|
Binary file not shown.
|
@ -1,250 +0,0 @@
|
||||||
import logging
|
|
||||||
import libevent
|
|
||||||
|
|
||||||
from ccnet.client import Client, parse_update, parse_response
|
|
||||||
|
|
||||||
from ccnet.packet import response_to_packet, parse_header, Packet
|
|
||||||
from ccnet.packet import to_response_id, to_master_id, to_slave_id, to_packet_id
|
|
||||||
from ccnet.packet import CCNET_MSG_REQUEST, CCNET_MSG_UPDATE, CCNET_MSG_RESPONSE, \
|
|
||||||
CCNET_HEADER_LENGTH, CCNET_MAX_PACKET_LENGTH
|
|
||||||
|
|
||||||
from ccnet.status_code import SC_PROC_DONE, SC_PROC_DEAD, SS_PROC_DEAD, \
|
|
||||||
SC_UNKNOWN_SERVICE, SC_PROC_KEEPALIVE, SS_PROC_KEEPALIVE, SC_PERM_ERR
|
|
||||||
|
|
||||||
from ccnet.status_code import PROC_NO_SERVICE, PROC_PERM_ERR, \
|
|
||||||
PROC_BAD_RESP, PROC_REMOTE_DEAD
|
|
||||||
|
|
||||||
from ccnet.errors import NetworkError
|
|
||||||
|
|
||||||
from .processor import Processor
|
|
||||||
from .sendcmdproc import SendCmdProc
|
|
||||||
from .mqclientproc import MqClientProc
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
'AsyncClient',
|
|
||||||
]
|
|
||||||
|
|
||||||
def debug_print(msg):
|
|
||||||
print msg
|
|
||||||
|
|
||||||
class AsyncClient(Client):
|
|
||||||
'''Async mode client'''
|
|
||||||
def __init__(self, config_dir, event_base):
|
|
||||||
Client.__init__(self, config_dir)
|
|
||||||
self.proc_types = {}
|
|
||||||
self.procs = {}
|
|
||||||
self.register_processors()
|
|
||||||
self._bev = None
|
|
||||||
|
|
||||||
self._evbase = event_base
|
|
||||||
|
|
||||||
def get_event_base(self):
|
|
||||||
return self._evbase
|
|
||||||
|
|
||||||
def add_processor(self, proc):
|
|
||||||
self.procs[proc.id] = proc
|
|
||||||
|
|
||||||
def remove_processor(self, proc):
|
|
||||||
if proc.id in self.procs:
|
|
||||||
del self.procs[proc.id]
|
|
||||||
|
|
||||||
def get_proc(self, id):
|
|
||||||
return self.procs.get(id, None)
|
|
||||||
|
|
||||||
def write_packet(self, pkt):
|
|
||||||
outbuf = self._bev.output
|
|
||||||
|
|
||||||
outbuf.add(pkt.header.to_string())
|
|
||||||
outbuf.add(pkt.body)
|
|
||||||
|
|
||||||
def send_response(self, id, code, code_msg, content=''):
|
|
||||||
id = to_response_id(id)
|
|
||||||
pkt = response_to_packet(id, code, code_msg, content)
|
|
||||||
self.write_packet(pkt)
|
|
||||||
|
|
||||||
def handle_packet(self, pkt):
|
|
||||||
ptype = pkt.header.ptype
|
|
||||||
if ptype == CCNET_MSG_REQUEST:
|
|
||||||
self.handle_request(pkt.header.id, pkt.body)
|
|
||||||
|
|
||||||
elif ptype == CCNET_MSG_UPDATE:
|
|
||||||
code, code_msg, content = parse_update(pkt.body)
|
|
||||||
self.handle_update(pkt.header.id, code, code_msg, content)
|
|
||||||
|
|
||||||
elif ptype == CCNET_MSG_RESPONSE:
|
|
||||||
code, code_msg, content = parse_response(pkt.body)
|
|
||||||
self.handle_response(pkt.header.id, code, code_msg, content)
|
|
||||||
|
|
||||||
else:
|
|
||||||
logging.warning("unknown packet type %d", ptype)
|
|
||||||
|
|
||||||
def handle_request(self, id, req):
|
|
||||||
commands = req.split()
|
|
||||||
self.create_slave_processor(to_slave_id(id), commands)
|
|
||||||
|
|
||||||
def create_slave_processor(self, id, commands):
|
|
||||||
peer_id = self.peer_id
|
|
||||||
if commands[0] == 'remote':
|
|
||||||
if len(commands) < 3:
|
|
||||||
logging.warning("invalid request %s", commands)
|
|
||||||
return
|
|
||||||
peer_id = commands[1]
|
|
||||||
commands = commands[2:]
|
|
||||||
|
|
||||||
proc_name = commands[0]
|
|
||||||
|
|
||||||
if not proc_name in self.proc_types:
|
|
||||||
logging.warning("unknown processor type %s", proc_name)
|
|
||||||
return
|
|
||||||
|
|
||||||
cls = self.proc_types[proc_name]
|
|
||||||
|
|
||||||
proc = cls(proc_name, id, peer_id, self)
|
|
||||||
self.add_processor(proc)
|
|
||||||
proc.start(*commands[1:])
|
|
||||||
|
|
||||||
def create_master_processor(self, proc_name):
|
|
||||||
id = self.get_request_id()
|
|
||||||
|
|
||||||
cls = self.proc_types.get(proc_name, None)
|
|
||||||
if cls == None:
|
|
||||||
logging.error('unknown processor type %s', proc_name)
|
|
||||||
return None
|
|
||||||
|
|
||||||
proc = cls(proc_name, id, self.peer_id, self)
|
|
||||||
self.add_processor(proc)
|
|
||||||
return proc
|
|
||||||
|
|
||||||
def handle_update(self, id, code, code_msg, content):
|
|
||||||
proc = self.get_proc(to_slave_id(id))
|
|
||||||
if proc == None:
|
|
||||||
if code != SC_PROC_DEAD:
|
|
||||||
self.send_response(id, SC_PROC_DEAD, SS_PROC_DEAD)
|
|
||||||
return
|
|
||||||
|
|
||||||
if code[0] == '5':
|
|
||||||
logging.info('shutdown processor %s(%d): %s %s\n',
|
|
||||||
proc.name, to_packet_id(proc.id), code, code_msg)
|
|
||||||
if code == SC_UNKNOWN_SERVICE:
|
|
||||||
proc.shutdown(PROC_NO_SERVICE)
|
|
||||||
elif code == SC_PERM_ERR:
|
|
||||||
proc.shutdown(PROC_PERM_ERR)
|
|
||||||
else:
|
|
||||||
proc.shutdown(PROC_BAD_RESP)
|
|
||||||
|
|
||||||
elif code == SC_PROC_KEEPALIVE:
|
|
||||||
proc.send_response(SC_PROC_KEEPALIVE, SS_PROC_KEEPALIVE)
|
|
||||||
|
|
||||||
elif code == SC_PROC_DEAD:
|
|
||||||
logging.info('shutdown processor %s(%d): when peer(%.8s) processor is dead\n',
|
|
||||||
proc.name, to_packet_id(proc.id), proc.peer_id)
|
|
||||||
proc.shutdown(PROC_REMOTE_DEAD)
|
|
||||||
|
|
||||||
elif code == SC_PROC_DONE:
|
|
||||||
proc.done(True)
|
|
||||||
|
|
||||||
else:
|
|
||||||
proc.handle_update(code, code_msg, content)
|
|
||||||
|
|
||||||
def handle_response(self, id, code, code_msg, content):
|
|
||||||
proc = self.get_proc(to_master_id(id))
|
|
||||||
if proc == None:
|
|
||||||
if code != SC_PROC_DEAD:
|
|
||||||
self.send_update(id, SC_PROC_DEAD, SS_PROC_DEAD)
|
|
||||||
return
|
|
||||||
|
|
||||||
if code[0] == '5':
|
|
||||||
logging.info('shutdown processor %s(%d): %s %s\n',
|
|
||||||
proc.name, to_packet_id(proc.id), code, code_msg)
|
|
||||||
if code == SC_UNKNOWN_SERVICE:
|
|
||||||
proc.shutdown(PROC_NO_SERVICE)
|
|
||||||
elif code == SC_PERM_ERR:
|
|
||||||
proc.shutdown(PROC_PERM_ERR)
|
|
||||||
else:
|
|
||||||
proc.shutdown(PROC_BAD_RESP)
|
|
||||||
|
|
||||||
elif code == SC_PROC_KEEPALIVE:
|
|
||||||
proc.send_update(id, SC_PROC_KEEPALIVE, SS_PROC_KEEPALIVE)
|
|
||||||
|
|
||||||
elif code == SC_PROC_DEAD:
|
|
||||||
logging.info('shutdown processor %s(%d): when peer(%.8s) processor is dead\n',
|
|
||||||
proc.name, to_packet_id(proc.id), proc.peer_id)
|
|
||||||
proc.shutdown(PROC_REMOTE_DEAD)
|
|
||||||
|
|
||||||
else:
|
|
||||||
proc.handle_response(code, code_msg, content)
|
|
||||||
|
|
||||||
def register_processor(self, proc_name, proc_type):
|
|
||||||
assert Processor in proc_type.mro()
|
|
||||||
|
|
||||||
self.proc_types[proc_name] = proc_type
|
|
||||||
|
|
||||||
def register_processors(self):
|
|
||||||
self.register_processor("send-cmd", SendCmdProc)
|
|
||||||
self.register_processor("mq-client", MqClientProc)
|
|
||||||
|
|
||||||
def register_service(self, service, group, proc_type, callback=None):
|
|
||||||
self.register_processor(service, proc_type)
|
|
||||||
cmd = 'register-service %s %s' % (service, group)
|
|
||||||
self.send_cmd(cmd, callback)
|
|
||||||
|
|
||||||
def send_cmd(self, cmd, callback=None):
|
|
||||||
proc = self.create_master_processor("send-cmd")
|
|
||||||
if callback:
|
|
||||||
proc.set_callback(callback)
|
|
||||||
proc.start()
|
|
||||||
proc.send_cmd(cmd)
|
|
||||||
|
|
||||||
def _read_cb(self, bev, cb_data):
|
|
||||||
dummy = bev, cb_data
|
|
||||||
|
|
||||||
inbuf = self._bev.input
|
|
||||||
while (True):
|
|
||||||
raw = inbuf.copyout(CCNET_HEADER_LENGTH)
|
|
||||||
header = parse_header(raw)
|
|
||||||
if len(inbuf) < CCNET_HEADER_LENGTH + header.length:
|
|
||||||
break
|
|
||||||
|
|
||||||
inbuf.drain(CCNET_HEADER_LENGTH)
|
|
||||||
data = inbuf.copyout(header.length)
|
|
||||||
pkt = Packet(header, data)
|
|
||||||
|
|
||||||
self.handle_packet(pkt)
|
|
||||||
|
|
||||||
inbuf.drain(header.length)
|
|
||||||
|
|
||||||
if len(inbuf) < CCNET_HEADER_LENGTH:
|
|
||||||
break
|
|
||||||
|
|
||||||
def _event_cb(self, bev, what, cb_data):
|
|
||||||
dummy = bev, cb_data
|
|
||||||
logging.warning('libevent error: what = %s' % what)
|
|
||||||
if what & libevent.BEV_EVENT_EOF or \
|
|
||||||
what & libevent.BEV_EVENT_ERROR or \
|
|
||||||
what & libevent.BEV_EVENT_READING or \
|
|
||||||
what & libevent.BEV_EVENT_WRITING:
|
|
||||||
if self._bev is not None:
|
|
||||||
self._bev = None
|
|
||||||
raise NetworkError('libevent error: what = %s' % what)
|
|
||||||
|
|
||||||
def base_loop(self):
|
|
||||||
'''Create an event base -> register socket events -> loop'''
|
|
||||||
self._bev = libevent.BufferEvent(self._evbase,
|
|
||||||
self._connfd.fileno())
|
|
||||||
|
|
||||||
self._bev.set_watermark(libevent.EV_READ,
|
|
||||||
CCNET_HEADER_LENGTH, # low wartermark
|
|
||||||
CCNET_MAX_PACKET_LENGTH * 2) # highmark
|
|
||||||
|
|
||||||
self._bev.set_callbacks(self._read_cb, # read callback
|
|
||||||
None, # write callback
|
|
||||||
self._event_cb) # event callback
|
|
||||||
|
|
||||||
self._bev.enable(libevent.EV_READ | libevent.EV_WRITE)
|
|
||||||
|
|
||||||
self._evbase.loop()
|
|
||||||
|
|
||||||
def main_loop(self):
|
|
||||||
self.base_loop()
|
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue