Skip to content

Instantly share code, notes, and snippets.

@mitsutaka
Created July 7, 2013 07:44
Show Gist options
  • Save mitsutaka/5942713 to your computer and use it in GitHub Desktop.
Save mitsutaka/5942713 to your computer and use it in GitHub Desktop.
BitTorrent Sync init script for FreeNAS Jail
#!/bin/sh
#
# PROVIDE: btsync
# REQUIRE: LOGIN DAEMON NETWORKING
# KEYWORD: shutdown
#
# To enable BTSync, add this line to your /etc/rc.conf:
#
# btsync_enable="YES"
#
# And optionally these line:
#
# btsync_user="username" # Default is "root"
# btsync_bin="/path/to/btsync" # Default is "/usr/local/sbin/btsync"
. /etc/rc.subr
name="btsync"
rcvar="btsync_enable"
load_rc_config $name
required_files=$btsync_bin
: ${btsync_enable="NO"}
: ${btsync_user="root"}
: ${btsync_bin="/usr/local/bin/${name}"}
HOMEDIR=`getent passwd $btsync_user | cut -d: -f6`
echo $HOMEDIR
if [ -d $HOMEDIR/.config ]; then
command="su -l $btsync_user -c \"$btsync_bin --config $HOMEDIR/.config/btsync/config.json\""
fi
echo $command
run_rc_command "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment