User Tools

Site Tools


u7ffsync

Firefox Sync 1.5 on Uberspace 7

This howto describes setting up a Firefox Sync 1.5 server on a Uberspace 7 host. Sqlite will be used as database backend and Mozilla Accounts as authentication provider. Running your own is possible, but will not be covered here. Existing manuals cover older Uberspace versions, so here's an update.

Step 1: Building syncserver

First, you'll need to create a few directories and install virtualenv as a prerequisite.

  • ~/src will be used for building
  • ~/var to contain the database
  • ~/html/ffsync for accessing the service.
$ pip install --user virtualenv
$ mkdir ~/src ~/var ~/html/ffsync
$ cd ~/src
$ git clone https://github.com/mozilla-services/syncserver
$ cd syncserver
$ make build

Step 2: Configuration and first run

You'll need to edit ~/src/syncserver/syncserver.ini to contain:

[server:main]
use = egg:gunicorn
host = 127.0.0.1
port = 62345
workers = 1
timeout = 30
 
[app:main]
use = egg:syncserver
 
[syncserver]
public_url = https://ubernaut.uber.space/ffsync/
sqluri = sqlite:////home/ubernaut/var/syncserver.db
secret = 1234567890abcdef1234567890abcdef12345678
allow_new_users = true
force_wsgi_environ = true

Replace:

  • port with a random port number >= 61000 of your choosing
  • public_url with your domain or uberspace name
  • sqluri with your path to ~/var
  • secret with the output of head -c 20 /dev/urandom | sha1sum

Now, create a .htaccess at ~/html/ffsync/.htaccess with contents:

RewriteEngine On
RewriteRule (.*) http://localhost:62345/$1 [P]

Replace 62345 with the port chosen earlier. This will reverse proxy forward the locally running syncserver and enable outside access.

You should now be able to start the service:

$ cd ~/src/syncserver/
$ ./local/bin/gunicorn --paste syncserver.ini
[2017-11-17 15:32:44 +0000] [27812] [INFO] Starting gunicorn 19.6.0
[2017-11-17 15:32:44 +0000] [27812] [INFO] Listening at: http://127.0.0.1:62345 (23456)
[2017-11-17 15:32:44 +0000] [27812] [INFO] Using worker: sync
[2017-11-17 15:32:44 +0000] [27817] [INFO] Booting worker with pid: 23456

And see it running in your browser:

Stop it with ^C and continue.

Step 3: Supervisor service

Create a startup script in ~/bin/ffsyncd.sh with contents:

#!/bin/bash
cd /home/ubernaut/src/syncserver
./local/bin/gunicorn --paste syncserver.ini

and a service definition in ~/etc/services.d/ffsync.ini:

[program:ffsync]
command=/home/ubernaut/bin/ffsyncd.sh

As usual, replace ubernaut with your equivalent.

Now, register your new service:

$ supervisorctl reread
$ supervisorctl update
$ supervisorctl start ffsync

You should now see it running:

$ supervisorctl status
ffsync                           RUNNING   pid 23456, uptime 0:00:10
$ ps fx
(...)
12345 ?        Ss     0:28 /usr/bin/python2 /usr/bin/supervisord -c /etc/supervisord.conf
12346 ?        S      0:00  \_ /bin/bash /home/ubernaut/bin/ffsyncd.sh
12347 ?        S      0:00      \_ /home/ubernaut/src/syncserver/local/bin/python2 ./local/bin/gunicorn --paste syncserver.ini
12348 ?        S      0:00          \_ /home/ubernaut/src/syncserver/local/bin/python2 ./local/bin/gunicorn --paste syncserver.ini

Step 4: Configuring your Firefox

Open about:config and edit the setting:

identity.sync.tokenserver.uri = https://ubernaut.uber.space/ffsync/token/1.0/sync/1.5

Replace ubernaut.uber.space with your URL and make sure to append /token/1.0/sync/1.5.

Step 5: Finalizing

You're now set up to sync with your own service. Enable syncing in Preferences → Firefox Account and you should see an increase in size in ~/var/syncserver.db.

Once you confirmed syncing, edit your ~/src/syncserver/syncserver.ini and set:

allow_new_users = false

That's it!

Issues

  • At the time of this writing (Nov. 2017), Firefox on iOS does not yet support custom sync URLs. It's likely to appear in a later release.
  • When stopping the service with supervisorctl stop ffsync, the python process remains and needs to be terminated manually. Modifying the startup script to contain directory=… and directly launching gunicorn led to supervisord errors I have yet to find a fix for.

Troubleshooting

If you need to debug the process, there's:

  • A log in ~/logs/supervisord.log, which should contain messages like:
2017-11-17 15:54:44,928 INFO spawned: 'ffsync' with pid 23455
2017-11-17 15:54:45,185 DEBG 'ffsync' stderr output:
[2017-11-17 15:54:45 +0000] [30712] [INFO] Starting gunicorn 19.6.0

2017-11-17 15:54:45,187 DEBG 'ffsync' stderr output:
[2017-11-17 15:54:45 +0000] [30712] [INFO] Listening at: http://127.0.0.1:62345 (23456)
[2017-11-17 15:54:45 +0000] [30712] [INFO] Using worker: sync

2017-11-17 15:54:45,190 DEBG 'ffsync' stderr output:
[2017-11-17 15:54:45 +0000] [30717] [INFO] Booting worker with pid: 23457

2017-11-17 15:54:46,191 INFO success: ffsync entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
  • A client-side error log in about:sync-log:
(...)
1510929440934	Sync.Status	DEBUG	Status.service: success.status_ok => success.status_ok
1510929440935	FirefoxAccounts	DEBUG	already verified
(...)
  • A services.sync.lastSync timestamp containing the last successful sync in about:support:
services.sync.lastSync	Fri Nov 17 2017 17:14:33 GMT+0100 (CET)
  • Also, you can force a sync in Tools → Sync Now.
u7ffsync.txt · Last modified: 17.11.2017 18:45 by root