Comment Installer Cakebox-light
note : rapportez les bugs dans ce topic : http://mondedie.fr/d/5776/1
Changelog:
- ajout de la partie donner les droits d'écriture à cakebox pour archiver des dossiers et supprimer des fichiers le 12/10/14
- retourne désormais un code http 403 pour cakebox via le port 81 le 24/09/14
- ajout d'un dépôt pour nodejs (dépôt de confiance) le 21/09/14
- correction du bug erreur 401 (pour vlc et divx) le 11/09/14
- mise à jour cakebox-light 1.7.0 le 2/09/14
- mise à jour cakebox-light 1.6.1 le 19/08/14
- possibilité de configurer nginx dans une uri le 19/08/14
image...
Pour suivre ce tuto il nous faut trois prérequis:
- savoir lire

- avoir un minimum de volonté (du genre j’abandonne pas au premier problème)

- avoir suivi ce génialissime tuto :
http://mondedie.fr/d/5302
Installation des essentiels
Installation de composer (gestionnaire de paquet php)
cd /tmp/
curl -s http://getcomposer.org/installer | php
mv /tmp/composer.phar /usr/bin/composer
chmod +x /usr/bin/composer
Installation de nodejs, suivre ce tuto :
http://mondedie.fr/d/7160
Installation de bower : gestionnaire de paquet destiné au web (dépendant de nodejs)
npm install -g bower
Upload des fichiers cakebox via git (on utilise le tag latest mais à vous de voir)
cd /var/www
git clone https://github.com/Cakebox/cakebox.git
cd cakebox
composer install
bower install --allow-root
Configuration de l'interface
cp /var/www/cakebox/config/default.php.dist /var/www/cakebox/config/<username1>.php
note : le fichier de config d'un user doit porter son nom ex : magicalex -> magicalex.php
à faire pour chaque utilisateur
édition du fichier
nano /var/www/cakebox/config/<username1>.php
Configuration du fichier utilisateur
<?php
/*
General configuration of Cakebox
*/
$app["cakebox.root"] = "/home/<username1>/torrents/"; // Root directory Cakebox have to scan
$app["cakebox.access"] = "/cakebox/<username1>/"; // Alias used in web server for direct access
$app["cakebox.language"] = "fr"; //Language of Cakebox. Could be : fr, en
/*
Directory settings
*/
$app["directory.ignoreDotFiles"] = false;
$app["directory.ignore"] = "//"; // Regex for files exclusion. For exemple : "/(\.nfo|\.test)$/"
/*
Web player settings
*/
$app["player.default_type"] = "html5"; // html5 or divx or vlc
$app["player.auto_play"] = "false";
/*
Betaseries account
NB: Ask API key here http://www.betaseries.com/api/
*/
$app["bs.login"] = "";
$app["bs.passwd"] = "";
$app["bs.apikey"] = "";
$app["rights.canPlayMedia"] = true;
$app["rights.canDownloadFile"] = true;
$app["rights.canArchiveDirectory"] = true;
$app["rights.canDelete"] = true;
Création d'un serveur cakebox sur le port 81
nano /etc/nginx/sites-enabled/cakebox.conf
puis coller/copier
server {
listen 81;
server_name _;
root /var/www/cakebox/public;
index index.php;
allow 127.0.0.1; # only the proxy
deny all;
charset utf-8;
include /etc/nginx/conf.d/cache.conf;
access_log /var/log/nginx/cakebox-access.log;
error_log /var/log/nginx/cakebox-error.log;
location = / {
try_files @site @site;
}
location / {
try_files $uri $uri/ @site;
}
location ~ \.php$ {
return 404;
}
location @site {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_param APPLICATION_ENV production;
## uncomment when running via https
## fastcgi_param HTTPS on;
}
}
On configure cakebox dans une uri comme /cakebox/
nano /etc/nginx/sites-enabled/rutorrent.conf
ajouter ce code entre les balises server{}
server {
...
## debut config cakebox-light ##
location /cakebox/ {
rewrite ^/cakebox(/.*)$ $1 break;
proxy_pass http://127.0.0.1:81;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
}
location /cakebox/<username1>/ {
alias /home/<username1>/torrents/;
add_header Content-Disposition "attachment";
satisfy any;
allow all;
}
location /cakebox/<username2>/ {
alias /home/<user2>/torrents/;
add_header Content-Disposition "attachment";
satisfy any;
allow all;
}
## etc si d'autre utilisateur ##
## fin config cakebox-light ##
...
}
On redémarre nginx
service nginx restart
Donner les droits d'écriture à cakebox pour archiver des dossiers et supprimer des fichiers
Pour cela on va ruser avec les groupes utilisateurs et avec les événements rtorrent
Voir le tuto ici
Création du groupe web.
groupadd web
Ajout du groupe web aux users <username1> (<username2> si multi-user) et www-data
usermod -aG web <username1>
usermod -aG web www-data
Ensuite il faut modifier le groupe des fichiers et le chmod
chown -R <username1>:web /home/<username1>/torrents/
find /home/<username1>/torrents/ -type f -exec chmod 664 {} \;
find /home/<username1>/torrents/ -type d -exec chmod 775 {} \;
Petite difficulté, par défaut les fichiers téléchargés se créent sous le groupe <username1> et avec le chmod 644 pour les fichiers et 755 pour les dossiers.
Donc à chaque nouveau téléchargement il faudra mettre à jour les bon droits.
On ajoute une ligne dans notre rtorrent.rc:
echo "system.method.set_key = event.download.finished,update_file,\"execute=/home/<username1>/.session/file_torrent.sh\"" >> /home/<username1>/.rtorrent.rc
et on créer un script pour mettre à jour les fichiers.
nano /home/<username1>/.session/file_torrent.sh
et coller le code dans le fichier
#!/bin/bash
# mise à jour des chmod et du groupe.
# chmod 775 pour les dossiers et chmod 664 pour les fichiers (obligatoire)
find /home/$USER/torrents ! -group web -type f -exec chmod 664 {} \;
find /home/$USER/torrents ! -group web -type d -exec chmod 775 {} \;
find /home/$USER/torrents ! -group web -exec chown $USER:web {} \;
exit 0
on rend de script exécutable:
chmod +x /home/<username1>/.session/file_torrent.sh
Pour finir il faut redémarrer rtorrent pour prendre en compte les dernières modifications.
Via le seedbox-manager ou via cette commande
service <username1>-rtorrent restart
Mettre à jour cakebox-light
Parfois une petite notification peut apparaître vous indiquant qu'une nouvelle version est disponible.
Pour mettre à jour il faut lancer ses deux commandes.
cd /var/www/cakebox/
git pull origin master
bower update --allow-root
Installer le plugin linkcakebox pour ruTorrent
j'ai développé un plugin pour rutorrent qui crée un lien vers cakebox. Au clic sur le bouton de la toolbar un nouvel onglet s’ouvre vers la page index de cakebox. Un autre lien est présent dans l’onglet fichier qui redirige vers la page play du fichier sélectionné. Le thème Oblivion est pris en charge.
Installation
cd /var/www/rutorrent/plugins
git clone https://github.com/Cakebox/linkcakebox.git linkcakebox
chown -R www-data:www-data linkcakebox/
Configuration
nano /var/www/rutorrent/plugins/linkcakebox/conf.php
Et modifier pour arriver à ça
<?php
$url = 'http://'.$host.'/cakebox/'; //force le http
$dirpath = '/home/'.$user.'/torrents/';
$onglet = true; //ou false
La variable $onglet est une option pour choisir d’ouvrir cakebox dans un autre onglet ou pas : true pour ouvrir un autre onglet et false pour ne pas ouvrir un autre onglet.
C’est terminé ! Rendez-vous sur
http://xx.xx.xx.xx/cakebox/ pour profitez de Cakebox-light.
Le mot de passe que votre navigateur vous demandera est le même que celui pour rutorrent.