-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
47 lines (37 loc) · 1.21 KB
/
Rakefile
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
@dtach_session = File.expand_path("tmp/session.dtach")
@rtorrent_session = File.expand_path("tmp/rtorrent.session")
@files_dir = File.expand_path("files")
@files_server = "opensourcebridge.org"
task :default => :help
task :help do
puts "Tasks for Open Source Bridge's Bittorent server:"
system "rake --silent -T"
end
desc "Start torrent server in the background"
task :start do
sh "dtach -n #{@dtach_session} rake _serve"
end
desc "Stop torrent server"
task :stop do
sh "expect bin/stop.expect"
end
desc "Restart torrent server"
task :restart => [:stop, :start]
desc "Attach to torrent server's console"
task :attach do
puts '* Attaching to running session: CTRL-t to detach, CTRL-q to stop'
exec %{tput smkx; dtach -a #{@dtach_session} -e "^T"; tput rmkx}
end
task :connect => :attach
task :_serve do
mkdir_p @rtorrent_session
exec "rtorrent -s #{@rtorrent_session} -o cwd=#{@files_dir},upload_rate=768,port_range=14305-14399"
end
desc "Pull torrent files from opensourcebridge.org to here"
task :pull do
sh "rsync -vax --partial --stats --progress #{@files_server}:#{@files_dir} ."
end
desc "Update cron to start server on boot"
task :cron do
sh "echo '@reboot cd #{Dir.pwd} && rake start' | crontab -"
end