Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
c513f2ab95 | |||
fb956cb777 | |||
bee6bd3200 | |||
6fb12158b0 | |||
69824d3497 | |||
38da3057a3 | |||
8dc75bc553 | |||
27ec24d567 |
@ -2,11 +2,12 @@ pipeline:
|
||||
nginx-conf:
|
||||
image: nginx:mainline
|
||||
commands:
|
||||
- cp nginx.conf /etc/nginx/
|
||||
- cp -r nginx /etc/nginx
|
||||
- nginx -t
|
||||
docker:
|
||||
image: plugins/docker
|
||||
repo: repo.shimun.net/shimun/seafile
|
||||
tag: no_media
|
||||
registry: repo.shimun.net
|
||||
storage_path: /drone/.docker
|
||||
secrets: ["docker_username", "docker_password"]
|
||||
|
@ -14,7 +14,7 @@ RUN apt update && apt install locales -y && apt install -y --no-install-recommen
|
||||
|
||||
COPY conf /opt/seafile/conf
|
||||
COPY conf /etc/seafile
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY nginx /etc/nginx
|
||||
COPY scripts/upgrade.py /usr/local/sbin/upgrade
|
||||
COPY scripts/seafile-server.sh /sbin/seafile-server
|
||||
|
||||
|
83
nginx.conf
83
nginx.conf
@ -1,83 +0,0 @@
|
||||
events {
|
||||
worker_connections 12;
|
||||
}
|
||||
|
||||
http{
|
||||
|
||||
upstream hub {
|
||||
server 127.0.0.1:8000;
|
||||
keepalive 2;
|
||||
}
|
||||
|
||||
upstream files {
|
||||
server 127.0.0.1:8082;
|
||||
keepalive 4;
|
||||
}
|
||||
|
||||
upstream webdav {
|
||||
server 127.0.0.1:8080;
|
||||
keepalive 2;
|
||||
}
|
||||
|
||||
disable_symlinks off;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
error_log syslog:server=unix:/dev/log;
|
||||
access_log syslog:server=unix:/dev/log;
|
||||
|
||||
|
||||
|
||||
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
|
||||
location / {
|
||||
proxy_pass http://hub;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
proxy_read_timeout 1200s;
|
||||
|
||||
# used for view/edit office file via Office Online Server
|
||||
client_max_body_size 0;
|
||||
|
||||
}
|
||||
|
||||
location /seafhttp {
|
||||
rewrite ^/seafhttp(.*)$ $1 break;
|
||||
proxy_pass http://files;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
proxy_connect_timeout 3s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
send_timeout 3600s;
|
||||
}
|
||||
|
||||
location /seafdav {
|
||||
fastcgi_pass webdav;
|
||||
fastcgi_keep_conn on;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
|
||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_param CONTENT_TYPE $content_type;
|
||||
fastcgi_param CONTENT_LENGTH $content_length;
|
||||
fastcgi_param SERVER_ADDR $server_addr;
|
||||
fastcgi_param SERVER_PORT $server_port;
|
||||
fastcgi_param SERVER_NAME $server_name;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
}
|
||||
|
||||
location /media {
|
||||
try_files /var/www /opt/seafile/seafile-server-latest/seahub;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
14
nginx/backends.conf
Normal file
14
nginx/backends.conf
Normal file
@ -0,0 +1,14 @@
|
||||
upstream hub {
|
||||
server 127.0.0.1:8000;
|
||||
keepalive 2;
|
||||
}
|
||||
|
||||
upstream files {
|
||||
server 127.0.0.1:8082;
|
||||
keepalive 4;
|
||||
}
|
||||
|
||||
upstream webdav {
|
||||
server 127.0.0.1:8080;
|
||||
keepalive 2;
|
||||
}
|
0
nginx/extra.conf
Normal file
0
nginx/extra.conf
Normal file
22
nginx/nginx.conf
Normal file
22
nginx/nginx.conf
Normal file
@ -0,0 +1,22 @@
|
||||
events {
|
||||
worker_connections 64;
|
||||
}
|
||||
|
||||
http {
|
||||
|
||||
include backends.conf;
|
||||
|
||||
disable_symlinks off;
|
||||
|
||||
server {
|
||||
|
||||
listen 80;
|
||||
|
||||
error_log /dev/stderr;
|
||||
|
||||
include seafile/*.conf;
|
||||
|
||||
include extra.conf;
|
||||
}
|
||||
|
||||
}
|
0
nginx/seafile/media.conf
Normal file
0
nginx/seafile/media.conf
Normal file
18
nginx/seafile/seafdav.conf
Normal file
18
nginx/seafile/seafdav.conf
Normal file
@ -0,0 +1,18 @@
|
||||
location /seafdav {
|
||||
fastcgi_pass webdav;
|
||||
fastcgi_keep_conn on;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $fastcgi_script_name;
|
||||
|
||||
fastcgi_param SERVER_PROTOCOL $server_protocol;
|
||||
fastcgi_param QUERY_STRING $query_string;
|
||||
fastcgi_param REQUEST_METHOD $request_method;
|
||||
fastcgi_param CONTENT_TYPE $content_type;
|
||||
fastcgi_param CONTENT_LENGTH $content_length;
|
||||
fastcgi_param SERVER_ADDR $server_addr;
|
||||
fastcgi_param SERVER_PORT $server_port;
|
||||
fastcgi_param SERVER_NAME $server_name;
|
||||
|
||||
client_max_body_size 0;
|
||||
|
||||
}
|
10
nginx/seafile/seafhttp.conf
Normal file
10
nginx/seafile/seafhttp.conf
Normal file
@ -0,0 +1,10 @@
|
||||
location /seafhttp {
|
||||
rewrite ^/seafhttp(.*)$ $1 break;
|
||||
proxy_pass http://files;
|
||||
proxy_http_version 1.1;
|
||||
client_max_body_size 0;
|
||||
proxy_connect_timeout 3s;
|
||||
proxy_read_timeout 3600s;
|
||||
proxy_send_timeout 3600s;
|
||||
send_timeout 3600s;
|
||||
}
|
14
nginx/seafile/seahub.conf
Normal file
14
nginx/seafile/seahub.conf
Normal file
@ -0,0 +1,14 @@
|
||||
location / {
|
||||
proxy_pass http://hub;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Host $server_name;
|
||||
proxy_read_timeout 1200s;
|
||||
|
||||
# used for view/edit office file via Office Online Server
|
||||
client_max_body_size 0;
|
||||
|
||||
access_log /dev/stdout;
|
||||
|
||||
}
|
@ -115,6 +115,12 @@ case "$1" in
|
||||
;;
|
||||
maintanance)
|
||||
$0 stop
|
||||
if [ "$2" = "--fsck" ]; then
|
||||
$LATEST/seaf-fsck.sh
|
||||
fi
|
||||
if [ "$2" = "--fsck-repair" ]; then
|
||||
$LATEST/seaf-fsck.sh --repair
|
||||
fi
|
||||
$LATEST/seaf-gc.sh
|
||||
$0 start
|
||||
;;
|
||||
|
@ -58,8 +58,7 @@ def perform_upgrade_command(version,mysql=False,yes=True):
|
||||
print len(current) == 1 and current[0] == 0
|
||||
if len(current) == 1 and current[0] == 0: #Not installed
|
||||
print("Running installer.")
|
||||
installer = os.path.join(seaf_home,"seafile-server-%s" % version,"setup-seafile%s.sh" % ("-mysql" if mysql else ""))
|
||||
if not call(["seafile-server","setup"],stdout=sys.stdout, stdin=sys.stdin):
|
||||
if not call(["seafile-server","setup", os.path.join(seaf_home,"seafile-server-%s" % version) ],stdout=sys.stdout, stdin=sys.stdin):
|
||||
sys.exit(1)
|
||||
sys.exit(126)
|
||||
script_re = "^upgrade_(\d+).(\d+)_(\d+).(\d+)\.sh$"
|
||||
@ -79,9 +78,27 @@ def perform_upgrade_command(version,mysql=False,yes=True):
|
||||
cmd.append(script)
|
||||
call(["/bin/sh", "-c", ''.join(cmd)], stdout=sys.stdout, stdin=(None if yes else sys.stdin))
|
||||
|
||||
def install_command(url):
|
||||
def download(url, version):
|
||||
tmp = tempfile.mkdtemp()
|
||||
if call(["/bin/sh", "-c", 'cd %s; curl %s | tar xzv' % (tmp, url)]) == 0:
|
||||
filename = "server_%s.tar.gz" % version
|
||||
pks = os.path.join(seaf_home, "pkg")
|
||||
if not os.path.exists(pks):
|
||||
os.mkdir(pks)
|
||||
dest = os.path.join(pks, filename)
|
||||
if os.path.exists(dest):
|
||||
return dest
|
||||
if call(["/bin/sh", "-c", 'curl %s --output %s/%s' % (url, tmp, filename)]) == 0:
|
||||
shutil.move(os.path.join(tmp,filename), dest)
|
||||
call(["/bin/chmod", "-w", dest])
|
||||
return dest
|
||||
else:
|
||||
print("Download failed")
|
||||
return 0
|
||||
|
||||
def install_command(url, version):
|
||||
pkg = download(url, version)
|
||||
tmp = tempfile.mkdtemp()
|
||||
if pkg and call(["/bin/sh", "-c", 'cd %s; tar xzvf %s' % (tmp, pkg)]) == 0:
|
||||
for f in os.listdir(tmp):
|
||||
dest = os.path.join(seaf_home, os.path.basename(f))
|
||||
if len(re.findall(version_re, f)) > 0:
|
||||
@ -96,7 +113,7 @@ def install_command(url):
|
||||
else: current = "0.0.0"
|
||||
print("Upgrading from: %s -> %s" % (current, target_version))
|
||||
perform_upgrade_command(target_version,mysql=("SEAF_MYSQL" in os.environ and os.environ["SEAF_MYSQL"]))
|
||||
if os.exists(tmp) and len(os.listdir(tmp)) != 0:
|
||||
if os.path.exists(tmp) and len(os.listdir(tmp)) != 0:
|
||||
print("Failed to unpack update")
|
||||
os.rmdir(tmp)
|
||||
return 1
|
||||
@ -119,7 +136,7 @@ def main_command(version="latest",page="https://www.seafile.com/en/download/"):
|
||||
return perform_upgrade_command(version)
|
||||
if install:
|
||||
print("Installing: %s" % version)
|
||||
sys.exit(install_command(install))
|
||||
sys.exit(install_command(install, version))
|
||||
else:
|
||||
print("Couldn't determine download for %s" % version)
|
||||
sys.exit(1)
|
||||
|
Reference in New Issue
Block a user