Skip to content

Instantly share code, notes, and snippets.

@akgrant43
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akgrant43/10603295 to your computer and use it in GitHub Desktop.
Save akgrant43/10603295 to your computer and use it in GitHub Desktop.
BitTorrent Sync init.d script
#!/bin/sh
# /etc/init.d/btsync
#
. /lib/lsb/init-functions
# Update with correct location and user
DAEMON=/home/alistair/kits/btsync/btsync
BTSYNC_USER=alistair
# Carry out specific functions when asked to by the system
case "$1" in
start)
cd /home/$BTSYNC_USER
sudo -u $BTSYNC_USER $DAEMON
;;
stop)
killall btsync
;;
restart|reload|force-reload)
stop
start
;;
status)
status_of_proc $DAEMON "btsync server for $BTSYNC_USER"
;;
*)
echo "Usage: /etc/init.d/btsync {start|stop|restart|reload|force-reload|status}"
exit 1
;;
esac
exit 0

This script assumes that no config files are being used with btsync, i.e. config is maintained through the web interface, and that only a single user is required. A multi-user version is available at https://gist.github.com/MendelGusmao/5398362.

Thanks also to nicoX at http://askubuntu.com/questions/284683/how-to-run-bittorrent-sync for the original idea.

On Ubuntu:

  1. Save the script to /etc/init.d/
  2. Modify the daemon location and user name as appropriate
  3. $ chmod 755 /etc/init.d/btsync
  4. $ update-rc.d btsync defaults
  5. $ sudo service btsync start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment