summaryrefslogtreecommitdiff
path: root/net/py-bittornado/files/bittornado.sh.sample
blob: 22bb4d48b60db76a267a96d8eaf7a79ea9d9f8c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
#Sample startup file for Bittornado sites

#PATH to be used. To be safe
PATH=/usr/local/bin:/bin:/usr/bin
#tracker daemon
DAEMON=/usr/local/bin/bttrack.py
#seed daemon
LAUNCH=/usr/local/bin/btlaunchmany.py
#mate file creator
MAKEMETA=/usr/local/bin/btmakemetafile.py
#state file of the Bittornado tracker (inside TORRENTSDIR)
DFILE=connected.txt
#ports to be used by tracker
PORT=6969
#description strings
DESC1="bittornado tracker"
DESC2="bittornado launcher"
#Owner of the torrent files to be served by web server
TORRENTOWNER="www:www"
#TORRENTSWWWDIR - the directory served by Web server
TORRENTSWWWDIR=/usr/local/www/torrent/
#TORRENTSDIR - the directory where you store served files and torrents
TORRENTSDIR=/home/iso/
#URL of TRACKER
#change it to your server
SERVER=http://6net.niif.hu:${PORT}
#Configuration file where you can store your local changes
CONFIG_FILE=/usr/local/etc/bittornado.conf
#options to be used by the tracker
#if you want experimental IPv6 support add --ipv6_enabled 1
#TRACKEROPTIONS="--dfile ./$DFILE --port $PORT --ipv6_enabled 1"
TRACKEROPTIONS="--dfile ./$DFILE --port $PORT"
#options to be used by seeders
#if you want experimental IPv6 support add --ipv6_enabled 1
#DOWNLOADOPTIONS="--ipv6_enabled 1"
DOWNLOADOPTIONS=""
#log file to be used by tracker and seeder
TORRENTLOG="/tmp/torrent.log"

if [ -s $CONFIG_FILE ]; then
    . $CONFIG_FILE
fi
test -f $DAEMON || exit 0
cd $TORRENTSDIR
set -e

case "$1" in
  make)
  echo "Making torrents: "
    rm -f ${TORRENTSDIR}/*.torrent
    for file in ${TORRENTSDIR}/*
    do
      base=`basename $file`
      if [ "$base" = "." ]; then
        continue;
      fi
      if [ "$base" = "$DFILE" ]; then
        continue;
      fi
      echo $MAKEMETA $SERVER/announce $file
      $MAKEMETA $SERVER/announce $file
    done
    #copy to be able to serve via WWW interface
    cp ${TORRENTSDIR}/*.torrent $TORRENTSWWWDIR
  chown ${TORRENTOWNER} ${TORRENTSWWWDIR}/*
  echo "."
  ;;
 start)
  echo "Starting $DESC1: $DAEMON"
  echo "Starting $DESC1: $DAEMON" >>${TORRENTLOG}
  nohup $DAEMON $TRACKEROPTIONS >> ${TORRENTLOG} &
  echo "Starting $DESC2: $LAUNCH"
  nohup $LAUNCH $TORRENTSDIR $DOWNLOADOPTIONS >> ${TORRENTLOG} &
  echo "."
  ;;
  stop)
  echo "Stopping $DESC1: $DAEMON"
  pkill -f `basename $DAEMON`
  echo "Stopping $DESC1: $LAUNCH"
  pkill -f `basename $LAUNCH`
  echo "."
  ;;
  restart|force-reload)
  echo "Stopping $DESC1: $DAEMON"
  pkill -f `basename $DAEMON`
  echo "Stopping $DESC1: $LAUNCH"
  pkill -f `basename $LAUNCH`
  echo "Starting $DESC1: $DAEMON"
  nohup $DAEMON $TRACKEROPTIONS >> ${TORRENTLOG} &
  echo "Starting $DESC2: $LAUNCH"
  nohup $LAUNCH $TORRENTSDIR $DOWNLOADOPTIONS >> ${TORRENTLOG} &
  echo "."
  ;;
  *)
  echo "Usage: $0 {start|stop|restart|force-reload|make}" >&2
  exit 1
  ;;
esac

exit 0