Skip to content

Instantly share code, notes, and snippets.

@stigkj
Forked from mitsutaka/btsync.freenas
Created September 14, 2013 21:25
Show Gist options
  • Select an option

  • Save stigkj/6565785 to your computer and use it in GitHub Desktop.

Select an option

Save stigkj/6565785 to your computer and use it in GitHub Desktop.

Revisions

  1. @mitsutaka mitsutaka created this gist Jul 7, 2013.
    36 changes: 36 additions & 0 deletions btsync.freenas
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    #!/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"