Tool to easily encrypt-decrypt your data under GNU/Linux

The following write-up covers the steps I used to set-up my private home media streaming server using Madsonic. I’m using ArchLinux ARM on my Cubieboard2 and a 320GB 3.5′ SATA2 hard drive attached to it holding the whole media stuff.

Tool to easily encrypt-decrypt your data under GNULinux

 

First update the system:

pacman -Syu

Next, install some additional packages required for the set-up:

pacman -S wget curl base-devel bash-completion yajl java-runtime libcups

Once the installation is done build and install cower:

su - d
cd ~/build
wget https://aur.archlinux.org/packages/co/cower/cower.tar.gz
tar zxf cower.tar.gz
rm -f cower.tar.gz
cd cower/

edit the build file:

nano PKGBUILD

and add:

arch=('i686' 'x86_64' 'armv7h')

Save and close the file, and execute the following commands:

makepkg -g >> PKGBUILD
makepkg

using root (as I rarely use sudo) install the package:

pacman -U /home/d/build/cower/cower-10-2-armv7h.pkg.tar.xz

once installed, get madsonic using cower, build and install it on the system:

su -d
cd ~/build
cower -d madsonic
cd madsonic/

edit the build file:

nano PKGBUILD

and add:

arch=('i686' 'x86_64' 'armv7h')

Save and close the file, and execute the following commands:

makepkg -g >> PKGBUILD
makepkg

Next install the madsonic package using pacman:

pacman -U /home/d/build/madsonic/madsonic-5.0.3830-1-armv7h.pkg.tar.xz

configure madsconic by editing /var/madsonic/madsonic.sh:

cp /var/madsonic/madsonic.sh{,.orig}

… edit the file:

nano /var/madsonic/madsonic.sh

and add:

MADSONIC_DEFAULT_MUSIC_FOLDER=/srv/media/music
MADSONIC_DEFAULT_UPLOAD_FOLDER=/srv/media/uploads/music
MADSONIC_DEFAULT_PLAYLIST_IMPORT_FOLDER=/srv/media/playlists
MADSONIC_DEFAULT_PLAYLIST_EXPORT_FOLDER=/srv/media/playlists
MADSONIC_INIT_MEMORY=256
MADSONIC_MAX_MEMORY=384

Save and close the file.
Next, set-up systemd unit file and start madsonic by typing:

cp /usr/lib/systemd/system/madsonic.service /etc/systemd/system/

edit the file:

nano  /etc/systemd/system/madsonic.service

# and set the line like this:

/var/madsonic/madsonic.sh --port=4040

… save and close the file. Run the following commands to reload it and put it in the start up processes:

systemctl daemon-reload
systemctl enable madsonic
systemctl restart madsonic

Ok, so we set-up Madsonic behind Nginx using reverse proxy. Before doing this, make sure you have Nginx set-up on the system. I already installed and set-up LEMP on my ArchLinux ARM, so I created top level domain named as home-media in my pfSense beast and created server block in /etc/nginx/sites-available/home-media containing the following:

nano /etc/nginx/sites-available/home-media

and add:

upstream madsonic {
    server 127.0.0.1:4040;
}
server {
    listen 80;
    server_name home-media;

    access_log /var/log/nginx/home-media-access;
    #access_log off;
    error_log /var/log/nginx/home-media-error error;

    location /style/(.*) {
        alias /var/madsonic/jetty/3830/webapp/style/$1;
    }
    location /icons/madsonic_sunny/favicon.ico {
        alias /var/madsonic/jetty/3830/webapp/icons/default/favicon.ico;
    }
    location /icons/(.*)/(.*) {
        alias /var/madsonic/jetty/3830/webapp/icons/$1/$2;
    }

    # proxy to madsonic app
    location / {
        proxy_pass http://madsonic;
        proxy_redirect off;
        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_set_header X-Forwarded-Host $server_name;
    }
}

Save and close the file. With the newly created nginx server block in place, I enabled it and reloaded Nginx for the changes to take effect:

cd /etc/nginx/sites-enabled
ln -s /etc/nginx/sites-available/home-media
nginx -t
systemctl restart nginx

and that’s that, Madsonic is now available to everyone within my place at http://home-media . Cool!

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>