Skip to content

Instantly share code, notes, and snippets.

@dmp1ce
Created May 3, 2015 12:18
Show Gist options
  • Select an option

  • Save dmp1ce/6bcb38d1843bac1a25e9 to your computer and use it in GitHub Desktop.

Select an option

Save dmp1ce/6bcb38d1843bac1a25e9 to your computer and use it in GitHub Desktop.

Revisions

  1. dmp1ce created this gist May 3, 2015.
    21 changes: 21 additions & 0 deletions start_transmission_daemon.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/bin/bash

    # Kill transmission-daemon if it is running
    transmission_da_pid=$(pgrep transmission-da)
    if [ $transmission_da_pid ]; then
    killall transmission-daemon && echo "Closing existing tranmission-daemon processes ..." && sleep 8
    fi

    # Get VPN IP to bind to
    bind_address=$(ip addr show tun0 | grep inet | awk '{print $2}')

    # If IP wasn't found then quit
    if [ -z $bind_address ]; then
    echo "VPN doesn't seem to be up. Will not start tranmission-daemon"
    exit
    fi

    # Start transmission-daemon
    transmission-daemon --rpc-bind-address=127.0.0.1 --bind-address-ipv4=$bind_address

    echo "transmission-daemon started and bound to address $bind_address"