diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-04-12 17:12:52 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-04-12 17:12:52 -0300 |
commit | 5ab9c19c8e45a067ee0880e4148b2f1492e152f7 (patch) | |
tree | 0cfaccff0a5bed4f6ece09e4ad601bbca32ac1c9 /files | |
download | puppet-pyroscope-5ab9c19c8e45a067ee0880e4148b2f1492e152f7.tar.gz puppet-pyroscope-5ab9c19c8e45a067ee0880e4148b2f1492e152f7.tar.bz2 |
Initial import
Diffstat (limited to 'files')
-rw-r--r-- | files/bashrc.sh | 104 | ||||
-rw-r--r-- | files/profile.sh | 21 | ||||
-rw-r--r-- | files/rtcron.sh | 24 | ||||
-rw-r--r-- | files/rtorrent.rc | 159 | ||||
-rw-r--r-- | files/start.sh | 20 | ||||
-rw-r--r-- | files/torque.ini | 68 |
6 files changed, 396 insertions, 0 deletions
diff --git a/files/bashrc.sh b/files/bashrc.sh new file mode 100644 index 0000000..2672cc3 --- /dev/null +++ b/files/bashrc.sh @@ -0,0 +1,104 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +[ -z "$PS1" ] && return + +# don't put duplicate lines in the history. See bash(1) for more options +# don't overwrite GNU Midnight Commander's setting of `ignorespace'. +HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}ignoredups +# ... or force ignoredups and ignorespace +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# make less more friendly for non-text input files, see lesspipe(1) +#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + #alias grep='grep --color=auto' + #alias fgrep='fgrep --color=auto' + #alias egrep='egrep --color=auto' +fi + +# some more ls aliases +#alias ll='ls -l' +#alias la='ls -A' +#alias l='ls -CF' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if [ -f /etc/bash_completion ] && ! shopt -oq posix; then + . /etc/bash_completion +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + export PATH="$HOME/bin:$HOME/rtorrent:$PATH" +fi diff --git a/files/profile.sh b/files/profile.sh new file mode 100644 index 0000000..751617b --- /dev/null +++ b/files/profile.sh @@ -0,0 +1,21 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# Start rtorrent +cd +$HOME/rtorrent/start diff --git a/files/rtcron.sh b/files/rtcron.sh new file mode 100644 index 0000000..7427b9f --- /dev/null +++ b/files/rtcron.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# https://code.google.com/p/pyroscope/wiki/RtControlExamples +# + +# Socket +RT_SOCKET=/var/cache/torrent/rtorrent/.scgi_local + +# Control app +rtcontrol=/var/cache/torrent/bin/rtcontrol + +# Ratio Management +$rtcontrol is_complete=yes is_open=yes [ ratio=+1.1 OR seedtime=+1w ] --stop + +# Move on Completion +#$rtcontrol --from-view complete 'realpath=*/work/*' -qo '~/bin/rtmv "$(path)s" /var/cache/media/seeding --cron' | bash + +# Move on Done +$rtcontrol --from-view complete [ 'realpath=*/work/*' OR 'realpath=*/seeding/*' ] is_open=n -qo '~/bin/rtmv "$(path)s" /var/cache/media/incoming --cron' | bash + +# Automatic stop of torrents having problems +# Stops any torrent that isn't known by the tracker anymore, +# or has other authorization problems, or lost its data +test -S $RT_SOCKET && $rtcontrol --from-view started 'message=*not?registered*,*unregistered*,*not?authorized*' OR is_complete=yes is_ghost=yes --stop --cron diff --git a/files/rtorrent.rc b/files/rtorrent.rc new file mode 100644 index 0000000..d4d2acc --- /dev/null +++ b/files/rtorrent.rc @@ -0,0 +1,159 @@ +### rtorrent settings ####################################################### + +# +# OPTIONAL settings (check these) +# + +# general +throttle.global_up.max_rate.set_kb = 12000 +throttle.global_down.max_rate.set_kb = 12000 +throttle.max_uploads.set = 100 +throttle.max_uploads.global.set = 250 +network.http.max_open.set = 99 +network.max_open_files.set = 600 +network.max_open_sockets.set = 300 +protocol.encryption.set = allow_incoming,try_outgoing,enable_retry +system.umask.set = 0027 +keys.layout.set = qwertz +pieces.hash.on_completion.set = no + +# rTorrent 0.8.9 and older only +# default is 2 ms and 5 tries +#hash_interval = 50 +#hash_max_tries = 2 + +# range for listening port +#network.port_range.set = 64000-64042 +network.port_range.set = 6881-6999 +network.port_random.set = no + +# tracker-less torrent support +#dht.mode.set = enable +protocol.pex.set = no +trackers.use_udp.set = no + +# peer settings +throttle.min_peers.normal.set = 20 +throttle.max_peers.normal.set = 60 +throttle.min_peers.seed.set = 30 +throttle.max_peers.seed.set = 80 + +# resource usage +pieces.memory.max.set = 1800M +network.xmlrpc.size_limit.set = 2M + + +# +# CORE settings (keep these) +# +network.http.capath.set = /etc/ssl/certs +encoding.add = utf8 + +directory.default.set = /var/cache/media/seeding +session.path.set = /var/cache/torrent/rtorrent/.session +network.scgi.open_local = /var/cache/torrent/rtorrent/.scgi_local +##scgi_port = localhost:5099 +log.execute = /var/cache/torrent/rtorrent/log/execute.log + +# SCHEDULE: Make SCGI socket group-writable +schedule = scgi_permission,0,0,"execute.nothrow=chmod,g+w,/var/cache/torrent/rtorrent/.scgi_local" + +# SCHEDULE: Watch directories (if you use "pyrotorque", you can/should comment out the watches) +#schedule = watch_start_directory,10,10,load.start=/var/cache/torrent/rtorrent/watch/start/*.torrent +#schedule = watch_load_directory,15,20,load.normal=/var/cache/torrent/rtorrent/watch/load/*.torrent +#schedule = untied_closing,30,30,close_untied= + +# SCHEDULE: Watch disk space +schedule = low_diskspace,15,60,close_low_diskspace=1000M + +# EVENTS: Logging (don't log "opened", or you get swamped at startup) +method.set_key = event.download.inserted_new,log,"print=\"LOADED \",$d.name=,\" [\",$convert.date=$system.time=,\"]\"" +method.set_key = event.download.finished,log,"print=\"COMPLETED \",$d.name=,\" [R=\",$d.ratio=,\", \",$convert.date=$system.time=,\"]\"" +method.set_key = event.download.closed,log,"print=\"CLOSED \",$d.name=,\" [R=\",$d.ratio=,\", \",$convert.date=$system.time=,\"]\"" + +# UI/VIEW: Sort "seeding" by ratio +view.sort_current = seeding,greater=d.ratio= + + +# +# PyroScope SETTINGS +# + +# Set "pyro.extended" to 1 to activate rTorrent-PS features! +method.insert = pyro.extended, value|const, 1 + +# Set "pyro.bin_dir" to the "bin" directory where you installed the pyrocore tools! +# Make sure you end it with a "/"; if this is left empty, then the shell's path is searched. +method.insert = pyro.bin_dir, string|const, ~/bin/ + +# Remove the ".default" if you want to change something (else your +# changes get over-written on update). +method.insert = pyro.rc_dialect, string|const|simple, "execute.capture=bash,-c,\"test $1 = 0.8.6 && echo -n 0.8.6 || echo -n 0.8.9\",dialect,$system.client_version=" +#method.insert = pyro.rtorrent_rc, string|const|private, "$cat=~/.pyroscope/rtorrent-,\"$pyro.rc_dialect=\",.rc.default" +method.insert = pyro.rtorrent_rc, string|const|private, "$cat=~/.pyroscope/rtorrent-,\"$pyro.rc_dialect=\",.rc" +import = $pyro.rtorrent_rc= + +# TORQUE: Daemon watchdog schedule +# Must be activated by touching the "~/.pyroscope/run/pyrotorque" file! +# Set the second argument to "-v" or "-q" to change log verbosity. +schedule = pyro_watchdog,30,300,"pyro.watchdog=~/.pyroscope," + +# CURL options +branch=pyro.extended=,"network.http.ssl_verify_peer.set=0" +branch=pyro.extended=,"network.http.dns_cache_timeout.set=25" + +# The following view changes rely on additional fields available with PyroScope added, +# but are a matter of preference, so you may comment them out + +# UI/VIEW: Sort incomplete by date added +view.sort_current = incomplete,greater=d.custom=tm_loaded +view.sort_new = incomplete,greater=d.custom=tm_loaded + +# UI/VIEW: Show recently completed top-most in "main" +view.sort_current = main,greater=d.custom=tm_completed +view.filter_on = main,event.download.finished + +# UI/VIEW: Show active and incomplete torrents (in view #0) and update every 20 seconds +# Items are grouped into complete, incomplete, and queued, in that order (rT-PS only). +# Within each group, they're sorted by download and then upload speed. +branch=pyro.extended=,false=,"view.sort_current = active,greater=d.up.rate=" +branch=pyro.extended=,"view.sort_current = active,\"compare=----,d.is_open=,d.complete=,d.down.rate=,d.up.rate=\"" +schedule = filter_active,12,20,"view.filter = active,\"or={d.up.rate=,d.down.rate=,not=$d.complete=}\" ;view.sort=active" + + +# +# LOCAL settings +# + +# Add anything of your own here... + +# Transfer rates +upload_rate = 25 +download_rate = 50 + +# Encryption +encryption = allow_incoming, try_outgoing, enable_retry + +# Collapsible display +#schedule = bind_collapse,0,0,"ui.bind_key=download_list,*,view.collapsed.toggle=" +view.collapsed.toggle = main + +# Show traffic of the last hour +network.history.depth.set = 112 +schedule = network_history_sampling,1,32, network.history.sample= +method.insert = network.history.auto_scale.toggle, simple|private, "branch=network.history.auto_scale=,\"network.history.auto_scale.set=0\",\"network.history.auto_scale.set=1\"" +method.insert = network.history.auto_scale.ui_toggle, simple|private, "network.history.auto_scale.toggle= ;network.history.refresh=" +branch=pyro.extended=,"schedule = bind_auto_scale,0,0,\"ui.bind_key=download_list,=,network.history.auto_scale.ui_toggle=\"" + +# Enable DHT support for trackerless torrents or when all trackers are down. +# May be set to "disable" (completely disable DHT), "off" (do not start DHT), +# "auto" (start and stop DHT as needed), or "on" (start DHT immediately). +# The default is "off". For DHT to work, a session directory must be defined. +# +dht = on + +# UDP port to use for DHT. +# +dht_port = 6881 + +### END rtorrent.rc ######################################################### diff --git a/files/start.sh b/files/start.sh new file mode 100644 index 0000000..249d393 --- /dev/null +++ b/files/start.sh @@ -0,0 +1,20 @@ +#! /bin/bash +if [ "$TERM" = "${TERM%-256color}" ]; then + export TERM="$TERM-256color" +fi +export LANG=en_US.UTF-8 +umask 0027 +cd $(dirname $0) +export RT_SOCKET=$PWD/.scgi_local +test -S $RT_SOCKET && lsof $RT_SOCKET >/dev/null && { echo "rTorrent already running"; exit 1; } +test ! -e $RT_SOCKET || rm $RT_SOCKET + +_at_exit() { + test -z "$TMUX" || tmux set-w automatic-rename on >/dev/null + stty sane + test ! -e $RT_SOCKET || rm $RT_SOCKET +} +trap _at_exit INT TERM EXIT +test -z "$TMUX" || tmux rename-w rT-PS + +rtorrent -n -o import=$PWD/rtorrent.rc diff --git a/files/torque.ini b/files/torque.ini new file mode 100644 index 0000000..728bd64 --- /dev/null +++ b/files/torque.ini @@ -0,0 +1,68 @@ +# The default "pyrotorque" configuration file +# +# For details, see http://code.google.com/p/pyroscope/wiki/QueueManager#Configuration +# + +[TORQUE] +# Job scheduler config, see +# http://readthedocs.org/docs/apscheduler/en/latest/#scheduler-configuration-options + +; Maximum number of persistent threads in the pool +apscheduler.threadpool.core_threads = 1 + +; Maximum number of total threads in the pool +apscheduler.threadpool.max_threads = 1 + +; Seconds to keep non-core worker threads waiting for new tasks +apscheduler.threadpool.keepalive = 20 + +; Maximum time in seconds for the job execution to be allowed to delay before it is considered a misfire +apscheduler.misfire_grace_time = 7 + +; Roll several pending executions of jobs into one +apscheduler.coalesce = True + + +# For job handler documentation, see +# http://code.google.com/p/pyroscope/wiki/QueueManager#Configuration +# +# For details on the schedule syntax, see +# http://readthedocs.org/docs/apscheduler/en/latest/cronschedule.html + +# Queue manager job +job.queue.handler = pyrocore.torrent.queue:QueueManager +job.queue.schedule = second=*/15 +job.queue.active = True +job.queue.dry_run = False +job.queue.quiet = False + +; Minimum number of items in 'downloading' state (trumps 'start_at_once') +job.queue.downloading_min = 1 +; Maximum number of items in 'downloading' state (also counts items that ignore commands) +job.queue.downloading_max = 2 +; Maximum number of items to start in one run +job.queue.start_at_once = 1 +; Filter for startable items ("is_open=no is_active=no is_complete=no" is implied) +job.queue.startable = is_ignored=0 message= prio>0 +; Filter for downloading item count ("is_active=yes is_complete=no" is implied) +;job.queue.downloading = down>0 + +# Connection statistics +job.connstats.handler = pyrocore.torrent.jobs:EngineStats +job.connstats.schedule = minute=* +job.connstats.active = True + +# Tree watch +job.treewatch.handler = pyrocore.torrent.watch:TreeWatch +job.treewatch.schedule = hour=* +job.treewatch.active = False +job.treewatch.dry_run = False +job.treewatch.quiet = False + +; Path or list of paths (MUST be set when active=True) +job.treewatch.path = +; "start" to load items as startable (in queue mode) or started +job.treewatch.load_mode = normal +; Queue mode means "start" items keep their normal prio +; (it's NOT set to "off", but they're also not immediately started) +job.treewatch.queued = False |