Skip to content

Commit

Permalink
winserver 5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lins05 committed Dec 19, 2015
1 parent a7c9abe commit 1d0a480
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 38 deletions.
8 changes: 4 additions & 4 deletions lib/net.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifdef WIN32
#define WINVER 0x0501
#include <inttypes.h>
#include <winsock2.h>
#include <ctype.h>
#include <ws2tcpip.h>
#endif
#include "include.h"

Expand All @@ -12,10 +16,6 @@


#ifdef WIN32
#include <inttypes.h>
#include <winsock2.h>
#include <ctype.h>
#include <ws2tcpip.h>
#define UNUSED
#else
#include <sys/types.h>
Expand Down
21 changes: 9 additions & 12 deletions scripts/upgrade/win32/py/gc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,18 @@
import traceback
import ccnet

from upgrade_common import install_path, seafile_dir, ccnet_dir, run_argv
from upgrade_common import install_path, seafile_dir, ccnet_dir, run_argv, ensure_server_not_running, central_config_dir

def ensure_server_not_running():
client = ccnet.SyncClient(ccnet_dir)
try:
client.connect_daemon()
except ccnet.NetworkError:
pass
else:
raise Exception('Seafile server is running! You must turn it off before gc!')

def call_seafserv_gc():
args = [
os.path.join(install_path, 'seafile', 'bin', 'seafserv-gc.exe'),
'-c', ccnet_dir,
'-d', seafile_dir,
'-c',
ccnet_dir,
'-d',
seafile_dir,
'-F',
central_config_dir,
]

print 'Starting gc...\n'
Expand All @@ -39,5 +35,6 @@ def main():
print '\nprint ENTER to exit\n'
raw_input()


if __name__ == '__main__':
main()
main()
19 changes: 0 additions & 19 deletions scripts/upgrade/win32/py/upgrade_4.3_4.4.py

This file was deleted.

49 changes: 49 additions & 0 deletions scripts/upgrade/win32/py/upgrade_4.3_5.0.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# coding: UTF-8

import shutil
import os
import traceback
from os.path import abspath, basename, exists, dirname, join
from upgrade_common import (install_path, seafserv_dir, ccnet_dir, seafile_dir,
upgrade_db, run_argv)


def move_all_conf_to_central_config_dir():
central_config_dir = join(seafserv_dir, 'conf')
if not exists(central_config_dir):
os.mkdir(central_config_dir)
files = [
join(ccnet_dir, 'ccnet.conf'),
join(seafile_dir, 'seafile.conf'),
join(seafserv_dir, 'seahub_settings.py'),
]
for fn in files:
if not exists(fn):
raise RuntimeError('file %s does not exist' % fn)
for fn in files:
with open(fn, 'r') as fp:
if 'This file has been moved' in fp.read():
return
dstfile = join(central_config_dir, basename(fn))
shutil.copyfile(fn, dstfile)
with open(fn, 'w') as fp:
content = '# This file has been moved to %s in seafile 5.0.0' % dstfile
fp.write(content)


def main():
try:
upgrade_db('5.0.0')
move_all_conf_to_central_config_dir()
except Exception, e:
traceback.print_exc()
print 'Error:\n', e
else:
print '\ndone\n'
finally:
print '\nprint ENTER to exit\n'
raw_input()


if __name__ == '__main__':
main()
14 changes: 12 additions & 2 deletions scripts/upgrade/win32/py/upgrade_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ccnet
import glob


# Directory layout:
#
# - SeafileProgram/
Expand Down Expand Up @@ -36,6 +37,7 @@
seafserv_dir = ''
ccnet_dir = ''
seafile_dir = ''
central_config_dir = ''

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
Expand Down Expand Up @@ -65,7 +67,7 @@ def error(message):
sys.exit(1)

def read_seafserv_dir():
global seafserv_dir, ccnet_dir, seafile_dir
global seafserv_dir, ccnet_dir, seafile_dir, central_config_dir
seafserv_ini = os.path.join(program_top_dir, 'seafserv.ini')
if not os.path.exists(seafserv_ini):
error('%s not found' % seafserv_ini)
Expand All @@ -75,6 +77,7 @@ def read_seafserv_dir():

ccnet_dir = os.path.join(seafserv_dir, 'ccnet')
seafile_dir = os.path.join(seafserv_dir, 'seafile-data')
central_config_dir = os.path.join(seafserv_dir, 'conf')

def apply_sqls(db_path, sql_path):
with open(sql_path, 'r') as fp:
Expand Down Expand Up @@ -132,8 +135,15 @@ def get_sql(prog):
print ' upgrading seahub databases ...'
apply_sqls(seahub_db, seahub_sql)

def get_current_version():
return os.path.basename(install_path).split('-')[-1]

def ensure_server_not_running():
client = ccnet.SyncClient(ccnet_dir)
if os.path.exists(os.path.join(central_config_dir, 'ccnet.conf')):
client = ccnet.SyncClient(ccnet_dir,
central_config_dir=central_config_dir)
else:
client = ccnet.SyncClient(ccnet_dir)
try:
client.connect_daemon()
except ccnet.NetworkError:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@echo off
cd /d %~dp0
set PYTHONPATH=%PYTHONPATH%;%~dp0\..\seahub\thirdpart
start python py/upgrade_4.3_4.4.py
start python py/upgrade_4.3_5.0.py

0 comments on commit 1d0a480

Please sign in to comment.