SeedBox su raspberryPI, Odroid etc.

Slider3

 

 

 

 

 

Perchè sprecare tanta energia tenendo acceso un PC quando possiamo usare un
alimentatore 5V da 1200/2000mA in nome dei nostri downloads e ratio su bittorrent?

Ho cominciato con installare un server web preferendo lighttpd :

    pacman -S lighttpd
    systemctl enable lighttpd

il nostro file di configurazione sarà:

    #/etc/lighttpd/lighttpd.conf

    server.modules += ( "mod_scgi" )

    scgi.server = (
    "/RPC2" =>
    ( "127.0.0.1" =>
    (
    "host" => "127.0.0.1",
    "port" => 5050,
    "check-local" => "disable"
    )
    )
    )

    server.port = 31337
    server.username = "http"
    server.groupname = "http"

    #x rutorrent
    #server.document-root = "/srv/http"
    server.document-root = "/usr/share/webapps/rutorrent/"

    #server.errorlog = "/var/log/lighttpd/error.log"
    dir-listing.activate = "enable"
    index-file.names = ( "index.html" )

    #x ruttorent
    #
    #mimetype.assign = (
    # ".html" => "text/html",
    # ".txt" => "text/plain",
    # ".css" => "text/css",
    # ".js" => "application/x-javascript",
    # ".jpg" => "image/jpeg",
    # ".jpeg" => "image/jpeg",
    # ".gif" => "image/gif",
    # ".png" => "image/png",
    # "" => "application/octet-stream"
    # )
    #

    mimetype.assign = (
    ".rpm" => "application/x-rpm",
    ".pdf" => "application/pdf",
    ".sig" => "application/pgp-signature",
    ".spl" => "application/futuresplash",
    ".class" => "application/octet-stream",
    ".ps" => "application/postscript",
    ".torrent" => "application/x-bittorrent",
    ".dvi" => "application/x-dvi",
    ".gz" => "application/x-gzip",
    ".pac" => "application/x-ns-proxy-autoconfig",
    ".swf" => "application/x-shockwave-flash",
    ".tar.gz" => "application/x-tgz",
    ".tgz" => "application/x-tgz",
    ".tar" => "application/x-tar",
    ".zip" => "application/zip",
    ".mp3" => "audio/mpeg",
    ".m3u" => "audio/x-mpegurl",
    ".wma" => "audio/x-ms-wma",
    ".wax" => "audio/x-ms-wax",
    ".ogg" => "application/ogg",
    ".wav" => "audio/x-wav",
    ".gif" => "image/gif",
    ".jar" => "application/x-java-archive",
    ".jpg" => "image/jpeg",
    ".jpeg" => "image/jpeg",
    ".png" => "image/png",
    ".xbm" => "image/x-xbitmap",
    ".xpm" => "image/x-xpixmap",
    ".xwd" => "image/x-xwindowdump",
    ".css" => "text/css",
    ".html" => "text/html",
    ".htm" => "text/html",
    ".js" => "text/javascript",
    ".asc" => "text/plain",
    ".c" => "text/plain",
    ".cpp" => "text/plain",
    ".log" => "text/plain",
    ".conf" => "text/plain",
    ".text" => "text/plain",
    ".txt" => "text/plain",
    ".dtd" => "text/xml",
    ".xml" => "text/xml",
    ".mpeg" => "video/mpeg",
    ".mpg" => "video/mpeg",
    ".mov" => "video/quicktime",
    ".qt" => "video/quicktime",
    ".avi" => "video/x-msvideo",
    ".asf" => "video/x-ms-asf",
    ".asx" => "video/x-ms-asf",
    ".wmv" => "video/x-ms-wmv",
    ".bz2" => "application/x-bzip",
    ".tbz" => "application/x-bzip-compressed-tar",
    ".tar.bz2" => "application/x-bzip-compressed-tar",
    # default mime type
    "" => "application/octet-stream",
    )

    #ssl
    # Server Authentication
    server.modules += ( "mod_auth" )

    auth.debug = 0
    auth.backend = "htdigest"
    #qui sotto il nostro filepasswd, vedremo più avanti come generarlo
    auth.backend.htdigest.userfile = "/etc/lighttpd/.auth"

    auth.require = ( "/" => (
    "method" => "digest",
    "realm" => "Password required",
    "require" => "valid-user"
    ))

    # Necessario per Lighttpd + rutorrent php
    server.modules += ( "mod_fastcgi" )

    fastcgi.server = ( ".php" => ((
    "bin-path" => "/usr/bin/php-cgi",
    "socket" => "/tmp/php.socket"
    )))

    # SSL Encryption
    #$SERVER["socket"] == ":443" {
    ssl.engine = "enable"

    #fix Poodle sslv3 vulne
    ssl.use-sslv2 = "disable"
    ssl.use-sslv3 = "disable"
    #ecco il certificato che creeremo piu avanti
    ssl.pemfile = "/etc/lighttpd/certs/lighttpd.pem"
    #}

Non avviamo lighttpd, perchè funzioni a dovere dovremmo prima
generare i certificati e creare il file passwd per l’utenza/e abilitata/e.

Installiamo adesso il nostro client torrent da linea di comando:

    pacman -S rtorrent
    mkdir /home/utente/.session
    mkdir /home/utente/Torrents

il file di config si trova nella home dell utente:
ma partiamo da quello base copiandolo:

    cp /usr/share/doc/rtorrent/rtorrent.rc /home/utente/.rtorrent.rc

e aggiungiamo quindi quello che ci servirà affinchè rtorrent comunichi
correttamente con il nostro webserver per la gestione del CMS rutorrent:

    # Socket CGI
    scgi_port = 127.0.0.1:5050

commentiamo per risparmiare risorse IO le due righe per il logging

    #log.open_file = "rtorrent", ~/logs/rtorrent.log
    #log.add_output = "debug", "rtorrent"

(ovviamente in caso di problemi le decommenteremo e andremo a leggerci così
i logs generati) specifichiamo i parametri per la connessione, bind, portrange
etc etc ma sopratutto le directory che abbiamo creato su per i torrents

    e per le sessioni:

    directory = /media/USB/Torrents
    session = /home/utente/.session

Per gestire piu praticamente la sessione rtorrent da console installiamo il solito
screen o tmux (io ho preferito tmux):

    pacman -S tmux

creiamo un service per systemd per la nostra sessione
rtorrent/tmux in questa maniera:

    #/etc/systemd/system/rt\@.service

    [Unit]
    Description=rTorrent
    Requires=network.target local-fs.target

    [Service]
    Type=forking
    KillMode=none
    User=%I
    ExecStart=/usr/bin/tmux new-session -s rt -n rtorrent -d rtorrent
    ExecStop=/usr/bin/tmux send-keys -t rt:rtorrent C-q
    WorkingDirectory=/home/%I/
    RestartSec=5
    Restart=on-failure

    [Install]
    WantedBy=multi-user.target

quindi abilitiamo il service con il nostro utente (non root)
owner del client:

    systemctl enable rt@utente.service

adesso tocca al nostro frontend rutorrent:

    pacman -S yaourt fakeroot mod_fastcgi php-cgi
    yaourt -S rutorrent rutorrent-plugins --noconfirm

aggiungiamo sul /etc/php/php.ini la riga come sotto:

    open_basedir = /etc/webapps/rutorrent/conf/:/usr/share/webapps/rutorrent/:/usr/share/webapps/rutorrent/php/:/tmp/rutorrent/:/usr/local/bin:/home/utente/:/usr/local/sbin/:/usr/sbin/

dove /home/utente è la home dell’utenza usata per il client rtorrent.
Settiamo permessi e la temp dir:

    chown -R http /usr/share/webapps/rutorrent
    chown -R http /etc/webapps/rutorrent

    mkdir /home/utente/tmp
    chown utente:utente /home/utente/tmp
    chmod 777 /home/utente/tmp

il file di configurazione di rutorrent lo troviamo in

    /usr/share/webapps/rutorrent/conf/config.php

dobbiamo soltanto modificarlo affinche comunichi con rtorrent aggiungendo:

    $scgi_port = 5050;
    $scgi_host = "127.0.0.1";
    #la temp precedentemente creata
    $tempDirectory = "/home/utente/tmp/rutorrent/";

passiamo adesso alla creazione del file password e del certificato per ssl:

    pacman -S apache

per avere il tool htdigest e generare la password cosi:

    htdigest -c /etc/lighttpd/.auth 'Username_Password_4_Torrent' utente
    (successivamente potremo togliere apache)
    otterremo un file tipo:
    cat /etc/lighttpd/.auth
    utente:Password required:aab07a90d5576d9af90606f13ef33e91

Per generare invece il cert perchè il frontend giri in https:

    pacman -S ca-certificates

e generariamo con:

    openssl req -new -x509 -newkey rsa:2048 -keyout /etc/lighttpd/certs/lighttpd.pem -out /etc/lighttpd/certs/lighttpd.pem -days 730 -nodes

adesso un ultimo dettaglio, in modo che funzionino anche i plugins di rutorrent :
installiamo:

    pacman -S ffmpeg mediainfo unzip unrar

modifichiamo il service di lighttpd cosi:

    #cat /usr/lib/systemd/system/lighttpd.service
    [Unit]
    Description=A secure, fast, compliant and very flexible web-server
    After=syslog.target network.target

    [Service]
    PrivateTmp=false
    ExecStart=/usr/bin/lighttpd-angel -D -f /etc/lighttpd/lighttpd.conf
    ExecReload=/bin/kill -HUP $MAINPID
    KillSignal=SIGINT

    [Install]
    WantedBy=multi-user.target

ed il file

    #cat /usr/share/webapps/rutorrent/conf/plugins.ini
    ;; Plugins' permissions.
    ;; If flag is not found in plugin section, corresponding flag from "default" section is used.
    ;; If flag is not found in "default" section, it is assumed to be "yes".
    ;;
    ;; For setting individual plugin permissions you must write something like that:
    ;;
    ;; [ratio]
    ;; enabled = user-defined ;; also may be "user-defined", in this case user can control plugin's state from UI
    ;; canChangeToolbar = yes
    ;; canChangeMenu = yes
    ;; canChangeOptions = no
    ;; canChangeTabs = yes
    ;; canChangeColumns = yes
    ;; canChangeStatusBar = yes
    ;; canChangeCategory = yes
    ;; canBeShutdowned = yes

    [default]
    enabled = user-defined
    canChangeToolbar = yes
    canChangeMenu = yes
    canChangeOptions = yes
    canChangeTabs = yes
    canChangeColumns = yes
    canChangeStatusBar = yes
    canChangeCategory = yes
    canBeShutdowned = yes

finalmente possiamo far partire il tutto con:

    systemctl --system daemon-reload
    systemctl restart lighttpd

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.