~ubuntuone/filesync-server/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
How to setup Filesync Server and Client
=======================================

These are the general instructions to do all the needed setup to have
a proper file synchronization service up and running.


Before server or client
-----------------------

Create the SSL certificates for client to communicate with server
securely. First, the private key:

    openssl genrsa -out privkey.pem


Then, then self-signed certificate. Note that at some point it will
ask you to write the "Common Name (e.g. server FQDN or YOUR name)", I
found that what you put there needs to match the '--host' parameter
you pass to the client (see below, in the part where the client
is started), so this host name must be such the client machine
can ping it.

    openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095


The just generated 'privkey.pem' and 'cacert.pem' will be used below.


Server setup
------------

Start with a clean Ubuntu Precise environment (for example, in a VPS).

Install tools and dependencies:

    sudo apt-get install bzr make python-transaction protobuf-compiler \
        python-setuptools gcc python-dev python-twisted-web postgresql-9.1 \
        python-yaml python-psycopg2 postgresql-contrib supervisor \
        postgresql-plpython-9.1 python-django python-boto squid \
        python-protobuf python-psutil python-testresources


Branch the project and get into that dir:

    bzr branch lp:filesync-server
    cd filesync-server


Edit the `configs/development.yaml` file and in the `secret` section set
the `api_server_crt` key with the content of `cacert.pem` file, and the
`api_server_key` key with the content of `privkey.pem` file (both files
produced in the "Before server or client" section).

Then, start the server:

    make start-oauth

Note that the server will listen on port 21101, so you need to assure
than the client could reach it (open it in your firewall config, etc).

Finally, create all the users you want:

    dev-scripts/user-mgr.py create testuser John Doe jdoe@gmail.com testpass

(with this script you'll be able to also retrieve and update user data,
and delete users)



Client setup
------------

This is to be repeated in all places that you want the system to run.
Instructions are for an Ubuntu Trusty environment, adapt as needed. It's
assuming you're starting from a clean machine (e.g.: a just installed one,
or an LXC), if you're not you may have some of the needed parts
already installed.

First, install tools and dependencies:

    sudo apt-get install python-twisted-bin python-twisted-core \
        python-dirspec python-pyinotify python-configglue \
        python-twisted-names python-ubuntu-sso-client \
        python-distutils-extra protobuf-compiler python-protobuf


Go to a new directory (anyone you chooses), let's call it $SOMEDIR, and there,
after following the steps below, you'll get the following structure:

    $SOMEDIR/storage-protocol   <-- this is a subproject needed by the client
    $SOMEDIR/client   <-- this is the proper filesync client
    $SOMEDIR/certifs   <-- this is where you'll store the SSL certifs for the client


Just to follow the next instructions, it's easier if you do:

    export SOMEDIR=<the path where you want to put everything>
    mkdir -p $SOMEDIR


So, branch and build the storage protocol:

    cd $SOMEDIR
    bzr branch lp:~facundo/ubuntuone-storage-protocol/opensourcing storage-protocol
    cd storage-protocol
    ./setup.py build


Put the SSL certificate in a separate directory (wherever you want):

    cd $SOMEDIR
    mkdir certif
    cp <path of cacert.pem file created above> certif/


Also branch and build the client:

    cd $SOMEDIR
    bzr branch lp:~facundo/ubuntuone-client/opensourcing client
    cd client/ubuntuone
    ln -s $SOMEDIR/storage-protocol/ubuntuone/storageprotocol .
    cd ..
    ./setup.py build


Finally, start the client

    export $(dbus-launch)  # seems this is needed if you're inside a LXC or VPS
    PYTHONPATH=. SSL_CERTIFICATES_DIR=$SOMEDIR/certif bin/ubuntuone-syncdaemon \
        --auth=testuser:testpass --host=testfsyncserver \
        --port=21101 --logging-level=DEBUG


If you want, check logs to see all went ok

    less $HOME/.cache/ubuntuone/log/syncdaemon.log


There, this line will show that the client started ok:

    ubuntuone.SyncDaemon.Main - NOTE - ---- MARK (state: <State: 'INIT' ...


And this line will show that the client reached the server ok (so no network issues):

    ubuntuone.SyncDaemon.StateManager - DEBUG - received event 'SYS_CONNECTION_MADE'


Finally, this line will show that client authenticated OK to the server
(no username/password issues):

    ubuntuone.SyncDaemon.StateManager - DEBUG - received event 'SYS_AUTH_OK'


Enjoy.