BTSync fedora at startup and working start stop service


g2nightmare

Recommended Posts

Has anybody gotten this to work on Fedora 18/19?

 

I ended up using a script very similar to this: https://gist.github.com/ricco386/5467477

 

And added it to chkconfig using this: http://unix.stackexchange.com/questions/20357/how-can-i-make-a-script-in-etc-init-d-start-at-boot

 

At startup, it appears to work. The problem is that 50% of the time, sync never gets forced, so I need to find a way to restart the service. Doing: service btsync stop says that it occurs, but upon checking "top," the process still runs and the service is never killed. It seems to me that killproc never actually reads the pid file (yes I pointed it to the right directory) and never actually kills anything.

 

Does anybody have a working script?

Link to comment
Share on other sites

You're much better off creating a native systemd unit file.  Put the following into a file called /etc/systemd/system/btsync@.service

[Unit]Description=BitTorrent Sync for %i[Service]Type=simpleUser=%iExecStart=/usr/local/bin/btsync --nodaemon --config %h/.sync/sync.confWorkingDirectory=%h[Install]WantedBy=multi-user.target

Copy the btsync binary to /usr/local/bin.

$ mkdir ~/.sync$ btsync --dump-sample-config > ~/.sync/sync.conf

Edit ~/.sync/sync.conf and change the storage_path config entry so that it's pointing to the right directory.  You can then start up btsync by running the following command as root:

# systemctl start btsync@username.service

If you want btsync to start up at boot run the following command as root:

# systemctl enable btsync@username.service

Other useful commands:

# systemctl status btsync@username.service btsync@username.service - BitTorrent Sync for username   Loaded: loaded (/etc/systemd/system/btsync@.service; disabled)   Active: active (running) since Fri 2013-09-27 11:23:38 CDT; 1min 15s ago Main PID: 23277 (btsync)   CGroup: /system.slice/system-btsync.slice/btsync@username.service           └─23277 /usr/local/bin/btsync --nodaemon --config /home/username/.sync/sync.confSep 27 11:23:38 localhost systemd[1]: Starting BitTorrent Sync for username...Sep 27 11:23:38 localhost systemd[1]: Started BitTorrent Sync for username.

And to restart btsync:

# systemctl restart btsync@username.service

If multiple users want to run BitTorrent Sync on the same system they'll need to make sure that the web UI listens on a unique port.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Jcollie,

            Your instructions seem geared towards having the sync start "for this user" when this user logs in... is that right? If that is how your scripts are intended to be used, thats great... but that is not an appropriate configuration for a backup server which should have the bittorrent sync service start upon a hard reboot, even if a given user does not login.

 

             I find the new "non-init.d" services on Fedora pretty confusing... and I do not understand why this problem has not been solved by the bittorrent sync developers... since it seems pretty fundemental to adoption to have reliable rpm/deb files... (*sigh*)

 

-FT

Link to comment
Share on other sites

  • 1 month later...

Jcollie,

            Your instructions seem geared towards having the sync start "for this user" when this user logs in... is that right? If that is how your scripts are intended to be used, thats great... but that is not an appropriate configuration for a backup server which should have the bittorrent sync service start upon a hard reboot, even if a given user does not login.

 

             I find the new "non-init.d" services on Fedora pretty confusing... and I do not understand why this problem has not been solved by the bittorrent sync developers... since it seems pretty fundemental to adoption to have reliable rpm/deb files... (*sigh*)

 

-FT

 

No.  It does not mean that the user has to log in, systemd will start the btsync service as that user on boot.  HIs setup here enables the flexibility for multiple users to have btsync running a a service controlled by systemd on boot, as long as they enabled it    It does not have to be done this way, you can "hard code" it to one user if so desired.  

 

example: 

 

 [unit]

Description=BitTorrent Sync
 
[service]
Type=simple
User=user
ExecStart=/usr/bin/btsync --nodaemon --config /home/user/.config/btsync/btsync.conf
 
 [install]
WantedBy=multi-user.target
 
then systemctl enable btsync
 
kp
Edited by nocturnal
Link to comment
Share on other sites

  • 1 month later...

jcollie 

 

Tried your method and got the following error.  Any ideas?

 

[thor@localhost .sync]$ sudo systemctl start btsync@Thor.service
[thor@localhost .sync]$ sudo systemctl status -l btsync@Thor.service
btsync@Thor.service - BitTorrent Sync for Thor
   Loaded: loaded (/etc/systemd/system/btsync@Thor.service; disabled)
   Active: failed (Result: exit-code) since Sun 2014-02-16 15:49:40 EST; 5s ago
  Process: 8028 ExecStart=/usr/local/bin/btsync --nodaemon --config home/Thor/.sync/sync.conf (code=exited, status=217/USER)
 Main PID: 8028 (code=exited, status=217/USER)
 
Feb 16 15:49:40 localhost.localdomain systemd[1]: Started BitTorrent Sync for Thor.
Feb 16 15:49:40 localhost.localdomain systemd[1]: btsync@Thor.service: main process exited, code=exited, status=217/USER
Feb 16 15:49:40 localhost.localdomain systemd[1]: Unit btsync@Thor.service entered failed state.
Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.