![]() |
ubuntu.com - launchpad.net - ubuntu help
|
|
|||||||
|
Tutorials & Tips The place to find Ubuntu related Tips & Tricks. |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
A Carafe of Ubuntu
![]() |
Synopsis:
Guide to setting up a media server which streams to most media capable hardware (including PS3 and Xbox 360) with automatic Podcast downloading and scheduled BitTorrenting. This creates a perfect setup where you can get to all your media via any computer on your network, start torrents from any computer on the network and use all your untapped bandwidth during the night! Equipment List:
Pre-face: I do not take any responsibility for any damages to hardware made by this guide! All software used is open-source and free with the exception of TwonkyMedia server. This is a proprietary piece of Linux software which I could not find such a feature rich, open-source alternative. TwonkyMedia can be installed as a free 30 day trial, which at the end of you, can purchase via their website for only $30. Its worth it! All code in this guide has been fully tested to be working with Ubuntu server 8.04 32bit LTS (Aka. Hardy Heron). This may not be the best way to do any of this, but its the way I know works! If you have any suggestions of changes, please let me know by PM'ing me or reply to this post. If you do not have a second computer at home and wish to do all this on the server as a client machine, or perform this guide on a desktop installation (Untested), just ignore all the parts about logging in via SSH, and just login locally and follow the exact same steps. This guide only works with the 32bit version of Ubuntu Server 8.04 because there are no versions of TwonkyMedia in 64bit. The rest of the guide will in 64bit work absolutely fine except steps 7 and 8. So, if you do not need media streaming, are using the 64bit version of Ubuntu Server and only wish for the automated downloads part of this guide, read on! Step One: Installing Ubuntu-Server 8.04 from CD. Notes: This is by no means a comprehensive guide to installing Ubuntu-Server 8.04. For full instructions please visit Ubuntu.com Ill assume at this point you already know how to download the Ubuntu-Server 8.04 ISO file and have burnt it to a blank CD-R – or you have used Ubuntu's handy “Ship-It” service and have had a disk sent to you. If not, there are plenty of guides on Ubuntu.com about how to do this. Drop the disk into the drive of the server and see if it boots into the Ubuntu install screen. If it doesn't you may have to change the boot order of your BIOS to make it do so. This varies from motherboard to motherboard so I cannot help too much here. Once you have booted into the the menu, choose your language of choice and hit “Install”. Follow all of the instructions on the screen. The trickiest part is how to partition your drive. If you are unsure when you get to the partition section, just choose “Completely remove partitions and use all available space”. When the installer asks you for a hostname, type “media-server” or a name for your computer on the network. This will appear to any computer viewing this server remotely. When it asks you for a username, I used “sysadmin”. I shall assume you have done the same for this entire guide and as the configuration files included in this guide use this username inside them, I suggest you do the same too. If for any reason you decide not to use “sysadmin”, please substitute it inside all of the configuration files where ever you may see it. Give this username any password you wish! When you get near the end of the installation it will ask you what packages you wish to install. I only choose the OpenSSHd server option. This will allow you to access the server remotely via SSH once you have setup the network address on the server. Once all this is complete, remove the CD, flip it over and put it back in your CD-Drive for safe keeping (or put it somewhere safe) and reboot the server. If it starts up ok, then onto step two! If not, you may wish to check out “Ubuntu.Com” for a full fledged guide on installing the Server Edition. Step Two: Updating Software and Setting Up The Network Address On The Server Before you remove the monitor and keyboard from the server, your going to want to update all the packages on the server and give it a static IP address. Firstly login by typing your username (“sysadmin” if you following this guide exactly) and type your chosen password. Once logged in, run the following commands and type your password when you get asked for it. Code:
sudo apt-get update sudo apt-get upgrade sudo apt-get install ntp Once this is finished, its time to setup the network address of this machine. All network card settings are stored inside a simple text file in Linux, which can be edited with your favorite Linux text editor. I use 'nano' as its a little simpler, but you can use 'vim' if you prefer. Code:
sudo nano /etc/network/interfaces Code:
# The primary network interface auto eth0 iface eth0 inet static address 192.168.1.2 gateway 192.168.1.2 netmask 255.255.255.0 Once saved, type this command at the terminal to restart the network. Code:
sudo /etc/init.d/networking restart Step Three: Logging In Remotely One of the luscious things about Linux is the ability to administrate everything remotely from any SSH terminal, which thankfully, Linux has built in and Windows has the awesome Putty software. In this guide I will assume you have a Linux variant installed on a client machine somewhere else on the network. If you are running Windows of some variety, then download Putty and perform all the commands using that. In a Linux terminal, type the following to login remotely to your server: Code:
ssh sysadmin@192.168.1.2 The default folder you are now in we will only use to download a few installable files and keep our configuration files. All data will be stored in some new folders we shall make in the next steps. Step Four: Create Media and Storage Directories and Share Them Via Samba Now were going to create some folders to put all your music, videos and torrents inside. Then were going to share them via Samba so Windows, Mac and Linux clients can see them on the network. Firstly, you need to create the directories to put all your new data into. You can change these locations, but I chose the following setup as its clean and tidy. Login via SSH (or perform this locally), then do the following. Code:
cd / sudo mkdir mediaserver cd mediaserver sudo mkdir -m 777 music sudo mkdir -m 777 video sudo mkdir -m 777 torrents cd torrents sudo mkdir -m 777 Finished sudo mkdir -m 777 Unfinished sudo mkdir -m 777 Torrents sudo mkdir -m 777 Session /mediaserverThe reason for the “-m 777” is so that Samba can read and write to these folders, which is necessary for copying files to these folders over a network. You don't need the original “/mediaserver” folder to have this access though, as you wont be sharing that folder explicitly./music Now you have this tree in place, you can install Samba and set it up to share these folders. Code:
sudo apt-get install samba smbfs Code:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup sudo nano /etc/samba/smb.conf Code:
... ; security = user ... Code:
security = share Code:
[music] comment = Music Folder path = /mediaserver/music public = yes writable = yes create mask = 0777 directory mask = 0777 force user = nobody force group = nogroup [video] comment = Video Folder path = /mediaserver/video public = yes writable = yes create mask = 0777 directory mask = 0777 force user = nobody force group = nogroup [torrents] comment = BitTorrent Folder (Put .torrent files inside the 'Torrents' folder) path = /mediaserver/torrents public = yes writable = yes create mask = 0777 directory mask = 0777 force user = nobody force group = nogroup Code:
sudo testparm sudo /etc/init.d/samba restart Step Five: Installing and Configuring Podget for Automatic Podcast Downloading Install Podget via: Code:
sudo apt-get install podget Code:
sudo nano /home/sysadmin/.podget/podgetrc Code:
# Name of Server List configuration file
config_serverlist=serverlist
# Directory where to store downloaded files
dir_library=/mediaserver
# Directory to store logs in
dir_log=/home/sysadmin/.podget
# Set logging files
log_fail=errors
log_comp=done
# Wget base options
wget_baseopts=-c -nH
# Most Recent
# 0 == download all new items.
# 1+ == download only the <count> most recent
most_recent=0
# Force
# 0 == Only download new material.
# 1 == Force download all items even those you've downloaded before.
force=0
# Autocleanup.
# 0 == disabled
# 1 == delete any old content
cleanup=0
# Number of days to keep files. Cleanup will remove anything
# older than this.
cleanup_days=14
# Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956)
# Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/
# filename_badchars=!#$^&=+{}[]:;"'<>?|\
# Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956)
# Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/
# filename_badchars=!#$^&=+{}[]:;"'<>?|\
# Filename Replace Character: Character to use to replace any/all
# bad characters found.
filename_replacechar=_
# Filename Cleanup 2: Some RSS Feeds (like the BBC World News Bulletin) download files with names like filename.mp3?1234567.
# Enable this mode to fix the format to filename1234567.mp3.
# 0 == disabled
# 1 == enabled (default)
filename_formatfix=1
# Stop downloading if available space on the partition drops below value (in KB)
# default: 1843200 (1800MB)
min_space=1843200
# ASX Playlists for Windows Media Player
# 0 == do not create
# 1 == create
asx_playlist=0
Now lets configure some servers. Code:
sudo nano /home/sysadmin/.podget/serverlist Code:
# Default Server List for podget # FORMAT: <url> <category> <name> # NOTES: # 1. The Category must be one word without spaces. You may use underscores. # 2. Any spaces in the urls needs to be converted to %20 # 3. Disable the downloading of any feed by commenting it out with a #. # 4. If you are creating ASX playlists, make sure the feed name does not # have any spaces in it. # Find more servers at: http://www.ipodder.org/directory/4/podcasts http://feeds.ziffdavis.com/ziffdavis/dltvwmvvideo video DL.TV http://feeds.feedburner.com/TrailercastHd720p?format=xml video HD Film Trailers http://feeds.feedburner.com/MajorNelsonblogcast music Xbox Live Podcast http://www.linuxbasement.com/mp3-full/feed music Linux Basement Podcasts Code:
http://feeds.feedburner.com/TrailercastHd720p?format=xml video HD Film Trailers Digital Podcast Download Radio IndiePodder.org Podcast.net Podcast Alley The Podcast Bunker The Podcast Network Podcasting News Podcast Directory The bit in blue is the folder name to put the content into. If your feed contains video, type “video”, if its music, type “music”. These names are the folders you created earlier inside /mediaserver. If you called them anything different, make the changes here. The part in red is the folder name to create to put the content inside from that feed. So, for the example above. Because its a feed containing HD Movie Trailers, ive put it inside the Video directory inside its own folder called HD Film Trailers. Simple as that! Tailor this list to your needs! Now the fun part! You can make 'Podget' run by simply typing “Podget” at the terminal. Its not a bad idea to run it quickly to make sure your servers are working correctly and its all setup properly. However, what you really want is for it to run in the night or at a time you arn't using your connection very much. To do this you want to setup a “cron job”. This is done via the following command. Code:
crontab -e Code:
# m h dom mon dow command 0 3 * * * /usr/bin/podget -s Step Six: Install Rtorrent and Schedule It For Overnight Downloads 'Rtorrent' is a command line based BitTorrent client. Its nice and small and has some neat features, such as folder watching so you can start and stop torrents by simply dropping .torrent files into a folder of your choosing. If you made the directory tree as suggested in step 3, those folders should now become apparent in their usage! Firstly, install Rtorrent via this command: Code:
sudo apt-get install rtorrent Code:
sudo nano /home/sysadmin/.rtorrent.rc Code:
# Default directory to save the downloaded torrents. directory = /mediaserver/torrents/Unfinished # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? session = /mediaserver/torrents/Session # Watch a directory for new torrents, and stop those that have been deleted schedule = watch_directory,10,10,load_start=/mediaserver/torrents/Torrents/*.torrent schedule = tied_directory,10,10,start_tied= schedule = untied_directory,10,10,close_untied= # Move completed downloads on_finished = rm_torrent,"execute=rm,$d.get_tied_to_file=" on_finished = move_complete,"execute=mv,-u,$d.get_base_path=,/mediaserver/torrents/Finished/ ;d.set_directory=/mediaserver/torrents/Finished/" # Close torrents when diskspace is low. schedule = low_diskspace,5,60,close_low_diskspace=1024M # Stop torrents when reaching upload ratio in percent. schedule = ratio,60,60,"stop_on_ratio=100" # Check hash for finished torrents. check_hash = yes # Encryption options. This can be useful when using an ISP that uses traffic shaping. encryption=allow_incoming,try_outgoing,enable_retry All currently downloading torrents can be found inside the “Unfinished” folder. Generally you want to leave everything alone except the “Torrents” folder which should only contain .torrent files and the Finished folder, which you can copy your finished torrents from when they are complete. Now, to make this only run at certain times you will need to install Screen. I wont go into what this does, but its a useful app for running this sort of program without you being there (as 'Rtorrent' uses a front-end inside a CLI, it inst appropriate to run as a 'cron job' by itself, this is what Screen is for!). Code:
sudo apt-get install screen Code:
crontab -e Code:
# Start rtorrent at 4am every day 0 4 * * * screen -d -m rtorrent # Stop rtorrent at 4pm every day 0 16 * * * screen -r -X quit Step Seven: Install TwonkyMedia to Stream Media to Various Devices Now lets go ahead and install TwonkyMedia. TwonkyMedia server is the software that allows you to share various folders containing music, videos and pictures and have them stream to different media enabled devices. Specifically I use it to stream music and video to my Xbox 360 on the network. To download it, make sure your in the default directory that you started in after logging in via SSH then type the following command. Code:
wget http://www.twonkymedia.com/Download/4.4/twonkymedia-i386-glibc-2.2.5.sh Now to install the server itself. Code:
sudo chmod 777 twonkymedia-i386-glibc-2.2.5.sh sudo ./twonkymedia-i386-glibc-2.2.5.sh Code:
cd /etc/init.d/ sudo chmod 755 twonkyserver sudo nano twonkyserver Code:
echo -n "Starting $TWONKYSRV ... "
$TWONKYSRV -D -inifile "${INIFILE}"
rc_status -v
Code:
echo -n "Starting $TWONKYSRV ... "
$TWONKYSRV -D -ip 192.168.1.2 -inifile "${INIFILE}"
rc_status -v
Then you need to run the following command. Code:
sudo update-rc.d twonkyserver defaults Code:
sudo reboot Step Eight: Configure TwonkyMedia Server Now we can finally configure TwonkyMedia to periodically scan your newly made media directories full of automatically downloaded podcasts so you can stream it all to media devices like the Xbox 360 and PS3. In an internet browser, on a machine on your network, go to: http://192.168.1.2:9000/config Now click on “First Steps”. Rename the media server to anything you want to. This will be the name displayed on your media devices. Now click on “Sharing”. From here you can setup any shares you like. The top one I set as: Code:
/mediaserver/music Code:
“Audio Only” Code:
/mediaserver/video Code:
“Video Only” You can also setup “Internet Radio” streams. Just follow the links on the right and enjoy tweaking it to your desire. As I say in my notes at the top of this guide though, this is only a trail version of the software and purchasing it after the 30 day trial is a must if you wish to keep using it. Every things now setup! Go ahead and test everything just incase, but it should all work smoothly! Let me know if you have any problems or if you would like more information on any of the software used above. HornedBeast Note: I have also attached a .zip to this post with the guide in a nice PDF format for easy printing and reading. Its difficult setting up a server whilst looking at this forum sometimes, so, printing this guide could be useful to some. Hope it helps! Last edited by HornedBeast; April 30th, 2008 at 01:16 PM.. Reason: Tiny Amendments |
|
|
|
|
|
#2 |
|
A Carafe of Ubuntu
![]() |
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Thank you so much for this tutorial. I used it a month ago to setup twonky. I had been looking for a way to stream video to our xbox. Other solutions did not work as well as twonky out of the box (with your config)
I have a question about rtorrent. I have been using ktorrent but it is a memory HOG! How is rtorrent in this regard? thanks again. Bill B |
|
|
|
|
|
#3 |
|
A Carafe of Ubuntu
![]() |
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Hi!
No worries about the guide! I plan on updating it soon to use TransmissionCLI instead of RTorrent. However, I can vouch for RTorrent being awesome. Its really solid and doesn't take up much resource at all! Just wish it had UPnP support really (please devs make it happen!) You should be fine on Rtorrent! Hope that helps. HB |
|
|
|
|
|
#4 |
|
Way Too Much Ubuntu
![]() |
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Thanks HornedBeast for the tutorial.
I'm about 80% finished, I got stuck at the Twonky install since the wget link in your tutorial wasn't any good so I tried to get around it by downloading the file from the website to my desktop (not my server) but now I can't copy it over to my server since ssh freaks out since it's "not a regular file". I'm researching how to move directories using ssh or whatever it is you need to do it. Oh and the host name being media-server (with a hypen) and the directory storing the files called mediaserver (no hypen) was a bit confusing, I can see you were trying to use generic names but they are a bit too similar. I'm using my own host name but use your directory naming structure. Although I had to really watch it using your config files and use the path on my server and with mediaserver (the directory) and not media-server. A bit confusing but once I saw what was going on I was OK...or I'll see when I get Twonky downloaded and set up.
__________________
Hardware: Intel Core 2 Quad 2.4GHz/ 4GB DDR2 800MHz RAM/ nVidia 9600GT 512MB/ Gigabyte GA-P35-S3G That fuzzy feeling in your head is your brain working, thanks to Linux! |
|
|
|
|
|
#5 |
|
5 Cups of Ubuntu
![]() |
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Thanks for the tutorial, worked great for me. I'm using Twonky 5 beta 1 now (just for kicks). Looks like to get my Xbox to stream my H.264's correctly I need to rename all the mp4's to m4v's. Otherwise, working perfectly! It's great to have all the load of streaming off of my PC and onto another machine.
|
|
|
|
|
|
#6 |
|
A Carafe of Ubuntu
![]() |
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Re: dhughes
Yea, I thought of that after I posted the tutorial - it is a little confusing. I'm currently re-writing the tutorial with a few changes and have decided I will change the hostname and other various things. Re: Twiggy794 No problem at all - Twonky usually gets a fair few updates a year, so its worth checking back. Its also worth purchasing if you use it alot as the open-source alternatives seem a little lacking right now. If I can get the same functionality out of an OSS peice of software I shall update my guide with that! Cheers for all the useful replies! Keep checking back! Regards, HB! |
|
|
|
|
|
#7 |
|
Just Give Me the Beans!
![]() Join Date: May 2008
Beans: 77
|
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
Im having problems with the rtorrent setup. I followed the directions, and rtorrent will not move any completed torrent to the specified directory. Nothing is ever removed from the unfinished directory. Ive checked the syntax of the .rc file, and made sure there are no permissions issues.
Has anyone had any issues like this? Any recommendations on what to check? |
|
|
|
|
|
#8 |
|
First Cup of Ubuntu
![]() Join Date: Jun 2008
Beans: 1
|
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
hey,
i'm really new to the whole linux thing and i've got a pure noob situation here. once i input the following: # Name of Server List configuration file config_serverlist=serverlist # Directory where to store downloaded files dir_library=/mediaserver # Directory to store logs in dir_log=/home/sysadmin/.podget # Set logging files log_fail=errors log_comp=done # Wget base options wget_baseopts=-c -nH # Most Recent # 0 == download all new items. # 1+ == download only the <count> most recent most_recent=0 # Force # 0 == Only download new material. # 1 == Force download all items even those you've downloaded before. force=0 # Autocleanup. # 0 == disabled # 1 == delete any old content cleanup=0 # Number of days to keep files. Cleanup will remove anything # older than this. cleanup_days=14 # Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956) # Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/ # filename_badchars=!#$^&=+{}[]:;"'<>?|\ # Filename Cleanup: For FAT32 filename compatability (Feature Request #1378956) # Tested with the following characters: !@#$%^&*()_-+=||{[}]:;"'<,>.?/ # filename_badchars=!#$^&=+{}[]:;"'<>?|\ # Filename Replace Character: Character to use to replace any/all # bad characters found. filename_replacechar=_ # Filename Cleanup 2: Some RSS Feeds (like the BBC World News Bulletin) download files with names like filename.mp3?1234567. # Enable this mode to fix the format to filename1234567.mp3. # 0 == disabled # 1 == enabled (default) filename_formatfix=1 # Stop downloading if available space on the partition drops below value (in KB) # default: 1843200 (1800MB) min_space=1843200 # ASX Playlists for Windows Media Player # 0 == do not create # 1 == create asx_playlist=0 and try to save it in nano, i get an error message saying that there is no such file or directory. tips? |
|
|
|
|
|
#9 |
|
A Carafe of Ubuntu
![]() Join Date: Jun 2007
Beans: 96
|
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
have you tried mediatomb? i haven't tried twonky, so i'll see if it's worth the $30. but i prefer mediatomb, it's GPL...
|
|
|
|
|
|
#10 |
|
First Cup of Ubuntu
![]() Join Date: Jul 2008
Beans: 1
|
Re: How-To: Media-Server with Streaming to Xbox 360 (Includes Torrents and Podcasts)
I've got an old pc that is just gathering dust, its a celeron 733, with 515mb of ram.
Would that be sufficient to stream movies through the 360? I have speed issues running on p4 2.8 in XP so I'm curious to know if the above will cut it. Also is it possible to use an external usb drive for storage of movies on the server? thanks |
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|