lundi 9 janvier 2012

My media server



The goal of this article is to describe how to have a central computer (PC 1) as a media center to:
- watch movie, listen to music, browse the web
- share content (movies, music ...) with Windows, Apple or Android devices on the wifi network.




First, install ubuntu on PC 1 (i use an old Intel Pentium 4 with an 160GB hard drive and a powerpoint mouse as the remote control).

After installation, lauch konsole (Alt+F2) and install more packages with this command :
sudo apt-get update ; sudo apt-get firefox openssh-server amule-daemon amule-utils samba apache2 kubuntu-restricted-extras vim vlc


Use Windows protocol to access PC 1

Configure samba server on PC 1 to share movies and downloaded files.

Edit the samba configuration file:
sudo nano /etc/samba/smb.conf
Make sure you have the following configuration at the end:
[Videos]
    comment = Videos
    path = /home/YOUR_USER/Videos
    browsable = yes
    guest ok = yes
    read only = yes
    create mask = 0755

[aMule]
    comment = aMule incoming files
    path = /home/YOUR_USER/.aMule/Incoming
    browsable = yes
    guest ok = yes
    read only = yes
    create mask = 0755
then restart the services:
sudo restart smbd ; sudo restart nmbd

You can now see what PC 1 has to share.

To see it from Windows, go on "Microsoft Windows Networks" in the file browser.

To see it from KDE, enter the following address on the url bar (you can access the url bar by typing Ctrl+l on Dolphin)
smb://192.168.1.105

To see it from Gnome, enter the following address on the url bar (you can access the url bar by typing Ctrl+l on Nautilus)
smb://192.168.1.105

Note: you can watch videos directly from a smb source using VLC.

Note: make sure the directory you are sharing have the right to be read by all unix users (chmod 755).


Use SSH protocol to access PC 1

To access PC 1 from linux (PC 2) through SSH with the command line, enter the following command
ssh -X YOUR_USER@192.168.1.105
You can now launch any program from PC 1 on PC 2 (for example, type "amule").

It's possible to bypass the password by installing a private/public key. Generate the key on both PC1 and PC2 :
ssh-keygen -t dsa

Copy the public key (.ssh/id_dsa.pub) from PC2 in .ssh/authorized_keys of PC1

To access PC 1 from KDE , enter the following url in Dolphin (Ctrl+l):
fish://YOUR_USER@192.168.1.105/home/YOUR_USER/.aMule/Incoming/

To access PC 1 from Gnome, enter the following url in Nautilus (Ctrl+l):
ssh://YOUR_USER@192.168.1.105/home/YOUR_USER/.aMule/Incoming/


Use http protocol to access PC 1

We are going to configure Apache on PC 1 to share movies through the WIFI network.

Edit Apache configuration file from the command line:
sudo nano /etc/apache2/sites-available/default
and replace the default directory /var/www by the one you want (/home/YOUR_USER/.aMule/Incoming/ in my case).

Then restart Apache via:
sudo /etc/init.d/apache2 restart

You can now download any content from PC 1 by typing http://192.168.1.105/ on your favorite browser.

It's a very convenient way to download movies on an Android device.

Note : you can make sure amuled starts at every startup by adding this line to /etc/rc.local
su -l YOUR_USER -c amuled


Useful links :
http://wiki.amule.org/index.php/Firewall
http://wiki.amule.org/index.php/FAQ_amulecmd

1 commentaire: