Chymeric Tutorials

Do awesome stuff - awesomely.

Btsync With Systemd (on Gentoo)

| Comments | Edit

What is Btsync?

Btsync is a peer-to-peer (p2p) file sharing client. Btsync uses the BitTorrent protocol, and is formally named “BitTorrent Sync”. The p2p file sharing protocol allows users to keep folders in sync without actually having to upload data into the cloud (meaning without having to depend on servers - which may not be theirs - for storage). This is highly beneficial as it allows for better security, more privacy (should you care), and - possibly most importantly - very fast sync over local networks.

Some users have voiced concerns over the fact that Btsync is closed source. While this is regrettable, we have not come across any actual instances of negative repercussions.

Btsync and Gentoo

Here we present an ebuild and associated files which enables you to easily get Btsync up and running on your Gentoo system. (Please pay attention to the einfo message printed after emerge). Our ebuild is currently mainly optimized to run with systemd, though we provide some (untested) initd and confd scripts We are currently trying to get it Btsync into the portage main tree (see our feature request), but need udev/init.d testers.

You can check whether or not you are using sytsmed with eix -I systemd - if anything comes out, you most probably are.

Get the Ebuild!

You can get the ebuild from our very compact chymeric overlay. To enable the overlay we suggest you follow the “Manually setting overlay locations” instructions from the Gentoo overlay guide. In short, the procedure is:

  1. Add PORTDIR_OVERLAY="/usr/local/portage/chymeric" (or whatever directory you prefer) to your /etc/portage/make.conf file.
  2. Run git clone https://github.com/TheChymera/chymeric.git /usr/local/portage/chymeric (or whatever other directory you previously chose).

Emerge

Simply go ahead and run emerge btsync as root from your terminal.

There - wasn’t that easy?

Btsync and Systemd

Based on suggestions found mostly on Arch Linux wiki or forum pages (such as these instructions), we have put together a Btsync unit to let you run Btsync as your user. You may see our btsync_at.service file here.

This script affords you the following functionalities:

Start the btsync daemon as your user:
1
# systemctl start btsync@your_user.service
Have the btsync daemon start at startup as your user:
1
# systemctl enable btsync@your_user.service

Permissions Management

With this set-up your files will be written to your synced directory by your user (not by root or btsync as you may see elsewhere). The main benefit of this is that permissions will never change within your synced directory, and you will always have read, write, and execute access to your files.

Which users are allowed to run btsync is managed by the btsync group (which our ebuild automatically creates). Without belonging to that group users will be unable to write to the PID file (meaning the service cannot be launched), and unable to write to the storage path (meaning -independently - that the web-GUI cannot be viewed).

Directory Structure

The Btsync binary blob is installed to /opt/btsync. The config, systemd, and init.d files are located in the respective system directories. The btsync.pid and btsync.conf files as well as the storage path are located either under the relevant system directories, or under ~/.btsync/ if you run Btsync as user (see the exact locations in the setup file).

Config File

Btsync can be used with or without a config file. A sample config file (containing the default settings) can be generated by running

1
2
# cd /opt/btsync
# ./btsync --dump-sample-config

Our ebuild uses a custom config file, which is edited to remove the "login" and "password" fields of the webUI, and to make some other modifications (see the respective setup file).

Credits

the ebuilds are brought to you by Robert Walker and Horea Christian.

Comments