installing bittorrent sync

Status
Not open for further replies.

iguana

Cadet
Joined
Jul 23, 2013
Messages
1
Hi everyone,
I finished setting up freenas 8.3.1. , making shares and creating jail. I would like to install bittorrent sync . I have not been able to find a guide . I am a beginner and do not know my way around commands. Is it possible for someone to give me some help with a step by step guide?
Thank you
 

abem3

Cadet
Joined
Dec 6, 2012
Messages
1
This was easy. Just download the btsync binary, copy and run it from within the jail. Then you can see the console from http://jail:8888. The new 1.1.1.48 or whatever has been the most solid yet. Earlier versions ate memory like crazy.
 

taupinfada

Cadet
Joined
May 12, 2013
Messages
3
Hi,

You will find behind a script to install btsync in a jail. You must execute this script in the jail.

Code:
#!/bin/sh
#
cd /tmp
 
bin_btsync=/usr/local/bin/btsync
 
if [ -e $bin_btsync ]; then
    echo "The current version of Bittorrent Sync :"
    echo `btsync --help | grep "BitTorrent Sync"`
    echo "Do you want to update Bittorrent Sync? (y/N): "
    read install_btsync
    else
    echo "Do you want to install Bittorrent Sync? (y/N): "
    read install_btsync
fi
 
if [ $install_btsync = "y" ]; then
    if [ `ps -aux | grep btsync | wc -l` -gt 1 ]; then
        echo "Stopping btsync:"
        service btsync stop
    fi
    echo "User initialzation btsync"
    if [ `more /etc/passwd | grep btsync | wc -l` -gt 0 ]; then
        echo "The btsync user already exists"
    else
        echo "Creating user btsync"
        pw useradd btsync -m -c "Bittorrent Sync User" -s /bin/sh -w yes
    fi
 
    echo "Initialize the directory"
    home_dir="/home/btsync"
    config_dir="$home_dir/.config"
    config_btsync_dir="$config_dir/btsync"
    if [ ! -e $config_dir ]; then
        mkdir $config_dir
    fi
    if [ ! -e $config_btsync_dir ]; then
        mkdir $config_btsync_dir
    fi
    chown -R btsync $home_dir
    chmod -R 744 $home_dir
 
    btsync_archive="btsync_freebsd_x64.tar.gz"
    if [ ! -e $btsync_archive ]; then
        echo "Downloading Bittorrent Sync."
        wget "http://btsync.s3-website-us-east-1.amazonaws.com/btsync_freebsd_x64.tar.gz"
    fi
    if [ -e btsync ]; then
        rm btsync
    fi
    echo "Extracting Bittorrent Sync."
    tar xvfz $btsync_archive
    if [ -e $bin_btsync ]; then
        echo "Updating Bittorrent Sync."
        rm $bin_btsync
    else
        echo "Copying Bittorrent Sync."
    fi
    cp btsync $bin_btsync
    chmod 755 $bin_btsync
 
    daemon_file="/usr/local/etc/rc.d/btsync"
    echo "Create the daemon"
    cat > $daemon_file <<EOF
#!/bin/sh
# btsync service
# PROVIDE: btsync
# REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv
# Take from <https://gist.github.com/MendelGusmao/5398362>
 
. /etc/rc.subr
 
# Replace with linux users you want to run BTSync clients for
BTSYNC_USERS="btsync"
DAEMON=/usr/local/bin/btsync
 
name="btsync"
search_pattern="\${name}"
command="/usr/local/bin/\${name}"
 
pidfile="/var/run/\${name}.pid"
rcvar="\${name}_enable"
command="daemon"
flags=""
 
getpid()
{
ps -aux | grep "\${search_pattern}" | awk -v pid="\${1:-0}" '\$2==pid
{print \$2}'
}
 
start() {
    echo "Starting btsync..."
    for btsuser in \$BTSYNC_USERS; do
        echo " - for \$btsuser"
        HOMEDIR=\`getent passwd \$btsuser | cut -d: -f6\`
        if [ -d \$HOMEDIR/.config ]; then
            su -l \$btsuser -c "/usr/local/bin/btsync --config \$HOMEDIR/.config/btsync/config.json"
        fi
    done
}
 
stop() {
    echo "Stopping btsync..."
    for btsuser in \$BTSYNC_USERS; do
        HOMEDIR=\`getent passwd \$btsuser | cut -d: -f6\`
        if [ -d \$HOMEDIR/.config ]; then
            dbpid=\`pgrep -u $btsuser btsync\`
            if [ -z "\$dbpid" ]; then
                echo "btsync for USER \$btsuser: not running."
            else
                echo "Stopping btsync for USER \$btsuser: running (pid \$dbpid)"
                kill \$dbpid
                until [ -z "\$dbpid" ]
                do
                    dbpid=\`pgrep -u \$btsuser btsync\`
                    echo -n "."
                    sleep 1
                done
                echo ""
            fi
        fi
    done
}
 
status() {
    for btsuser in \$BTSYNC_USERS; do
        dbpid=\`pgrep -u $btsuser btsync\`
        if [ -z "\$dbpid" ]; then
            echo "btsync for USER \$btsuser: not running."
        else
            echo "btsync for USER \$btsuser: running (pid \$dbpid)"
        fi
    done
}
 
start_cmd="start"
stop_cmd="stop"
status_cmd="status"
 
load_rc_config ${name}
run_rc_command "\$1"
EOF
    chmod 755 /usr/local/etc/rc.d/btsync
   
    if [ `more /etc/rc.conf | grep btsync | wc -l` -lt 1 ]; then
        echo "btsync_enable=\"YES\"" >> /etc/rc.conf
    fi
   
    update_config=y
    config_file="$config_btsync_dir/config.json"
    if [ -e $config_file ]; then
        echo "Do you want to modify the user for web interface? (y/N): "
        read update_config
    fi
   
    if [ $update_config = "y" ]; then
        echo "Configure the web interface"
        echo "Username for btsync webui : "
        read user
        echo "Password for btsync webui user : "
        read pwd
        cat > $config_file <<EOF
{
  "device_name": "My NAS",
  "listening_port" : 0,                      // 0 - randomize port
 
/* storage_path dir contains auxilliary app files
  if no storage_path field: .sync dir created in the directory
  where binary is located.
  otherwise user-defined directory will be used
*/
  "storage_path" : "/home/btsync/.config/btsync",
 
// uncomment next line if you want to set location of pid file
// "pid_file" : "/var/run/syncapp/syncapp.pid",
 
 
  "check_for_updates" : true,
  "use_upnp" : true,                              // use UPnP for port mapping
 
 
/* limits in kB/s
  0 - no limit
*/
  "download_limit" : 0,                     
  "upload_limit" : 0,
 
/* remove "listen" field to disable WebUI
  remove "login" and "password" fields to disable credentials check
*/
  "webui" :
  {
    "listen" : "0.0.0.0:8888",
    "login" : "$user",
    "password" : "$pwd"
  }
 
}
EOF
        chown btsync $config_btsync_dir/config.json
        chmod 744 $config_btsync_dir/config.json
    fi
 
    echo "Starting btsync :"
    service btsync start
fi
 
Status
Not open for further replies.
Top