Quantcast
Channel: Amagob IT Blog
Viewing all articles
Browse latest Browse all 13

Media Server (and more) under linux

$
0
0

Been a while since I wanted to change the pc acting as media server under my tv into a linux machine. It was doing quite well as a Windows 7 machine except for the frequent updates and reboots and all the 3rd party software required to get it to work like I wanted. The Acer AspireRevo R3610 Nettop PC was a great option 4 years back, with an Atom 330 processor, and 2 GB ram, its starting to lag in performance and it was time to turn to linux. So my wish list of applications were as follows:

  1. File Sharing
  2. Printer sharing
  3. Remote connexion (VNC or NoMachine)
  4. Prayer time (Islamic)
  5. btsync (backup)
  6. utorrent (just in case :)
  7. Xbmc (will rename Kodi soon)

The real test was to get most of these applications and services running in the background and booting directly into XBMC (Kodi). I surprised myself in having it done in just a couple of hours.

I installed the XUbuntu just to get things going with giving a minimum light interface. First thing was SSH server (of course), samba, updates.

NoMachine is a great option for remote connexion and all tools are freely downloadable for linux on the website. Walking through the installation is straightforward and there’s not much to figure out.. https://www.nomachine.com/download/linux&id=1. However, it does mess with the display resolution on the physical device and I didn’t like it. I went back to the basics and install X11Vnc. X11VNC allows for multiple user connexions and therefore different desktops (if you didn’t know), but I just wanted to get access to the active display of the single user on the desktop. So, i just needed the following command launched at startup (not at user logon).

#! /bin/sh
# /etc/init.d/x11vnc

#x11vnc -display :0

case “$1″ in
start)
echo “starting x11vnc”
x11vnc -display :0
;;
stop)
echo “stopping x11vnc”
killall x11vnc
;;
*)
echo “Usage /etc/init.d/x11vnc {start|stop}”
esac
exit 0

All that was required for that was to create the file /etc/init.d/x11vncs with this line, then run

sudo update-rc.d x11vncs defaults

(To remove the script at startup runlevels use sudo update-rc.d x11vncs remove.)

That also gave be the possibility of starting and stopping the service with sudo service x11vncs start/stop.

SAMBA was next. File configuration was very straightforward and I chose to share my home folder. (There’s no better place than ~ ).

Apart from the global section /etc/samba/smb.conf looks like this.. (pretty straight forward.)

[homes]
comment = Home Directories
browseable = yes
read only = no

[printers]
comment = All Printers
browseable = yes
path = /var/spool/samba
printable = yes
guest ok = yes
read only = no
create mask = 0755
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no

I have a Samsung laserjet ML1670 printer which I got for $20 few years ago. Great printer!! linux drivers available on samsung website. Only bug when installing the printer was a typo in a filename during installation process. Solution was to create a hardlink to the file

cd /usr/lib/cups/filter/
sudo ln -s rastertospl rastertosplc

Other than that, printer worked as a charm and readily available through the network using Linux or Windows Machine. Only hiccup when trying to install the shared printer on my ubuntu  (gnome3 desktop) was the printer installation menu was missing. I had to run

sudo system-config-printer

to get the right menu to add the shared printer.

(Check all your shares with smbclient -L \\192.168.1.X)

BTSync and Utorrent are both launched by a single command. As for X11vnc, just create the files in /etc/init.d/ with commands like ..

start)
echo “Starting utserver ”
cd /opt/utor
./utserver &
;;
stop)
echo “Stopping script utserver”
killall utserver
;;

or just

#! /bin/sh
# /etc/init.d/btsync

/opt/btsync/btsync –config /opt/btsync/btsync.confg

Most of these applications pick the same port as default so you need to change them and remember which is used for what.

Next was for the Prayer Times. I previously used Minbar as the Ubuntu desktop application for prayer time. It worked great. In my case, I was not logging into a gnome desktop so that wouldn’t work. Minbar actually uses a set of cli tools bundles in itools.

itools – Islamic hijri date and prayer time utilities

This gives you a set of commands like ipraytime (list the current pray times) and ireminder (prayer time reminder)To configure your location, you need to have the file .iprayrc with your configuration.

City: Mississauga, Canada
Latitude: 43.605
Longitude: -79.682
AngleMethod: 4
DST: 0

Tip, to get the GPS location of your region, find your city on Google Maps. Right click on the map and click “What’s here?”. The Location will be written on top with the GPS Coordinates just under.

Map Location

 

The command for ireminder for the 5 daily prayers is as follows:

ireminder -skip “imsaak shorooq” -execs “mpg123 /opt/salat/azan.mp3″ &

azan.mp3 is an mp3 of the call to prayer as you may have guessed. I made things a little more interesting I as will document in my wiki (later) and the link will be shared here.

As for the other application I added a script at the initial run levels (startup). The problem here was that when these scripts are ran, the user has not been identified or logged in, so the .iprayrc file (home directory) is not available and scripts call for the default prayer hours which is in Saudi Arabia. For this one, I had to used a script in XBMC to run the script at logon (home drive then available). The script is callback.

Installing XBMC was very easy. Although it is available in the ubuntu package list, it is not the latest stable version which is Gotham (13.2). (see instructions here). This installation comes with XBMC-Standalone. So to log into xbmc directly on boot up, log out physically on the machine and change the logon desktop option to XBMC.

I got to learn a lot about the XBMC environment, its dynamic community and all the free stuff that are available online. I was blown away with addons like MashUP (retired just recently), TVADDONS.org which is a must have. Some great addons also include Navi-X, P2PStream, SportsDevil, SortTV and Radio.

I was also referred to PlexTV as a great sources of media online. There are multiple youtube videos comparing the XBMC and Plex. XBMC is a full desktop application with UPNP and lots and lots of plugins in an open community. Plex offers and web based environment with uPNP and paid apps for you devices. You can actually set up both XBMC and Plex on you media server without complications and have the best of both worlds. It all depends on how you have set up your media server.

As we got further into programming with linux, there came new possibilities. I found gcalcli, which is a command line for google calendar. I use gcalcli to access one of my Google Calendar in which i created reminders in the form of appointments and used the Google TTS, using the this script, to read them out loud. It’s pretty cool, All I had to do was to add something in my calendar, and a cron job would check every 15mins for appointments in the coming hours and tell it out loud.

*/15 * * * * /opt/gcal

#!/bin/bash
cd /usr/bin
gcalcli remind 60 ‘speak %s’ –calendar “Task Reminders”

gnome-voice-control, espeak, and pico2wave were options but the best non-robotic voice was from the online google conversion.

Google recently update the Authentication API. Previously you have to configure a file ~/.gcalclirc with your username, password etc. Now you need to get a authentication token one time and acknowledge the connection; definitely more secure. The problem which I had when this changed sent me into a spiral of errors with python not parsing the date correctly. (Gcalcli with Ubuntu 14.04, parsedatetime) Finally, I found this blog that suggested to go back to python-parsedatetime 1.2 (default packing in ubuntu trusty is 1.4) and it just worked.

 

sudo apt-get install gcalcli
For Ubuntu 14.04 LTS, due to this bug, we need to download & install the latest parsedatetime 1.2 to get gcalcli work.

cd /tmp

wget https://launchpad.net/ubuntu/+archive/primary/+files/python-parsedatetime_1.2-1_all.deb

sudo dpkg -i python-parsedatetime_1.2-1_all.deb

The .gcalclirc file does not seem to work anymore, and since you don’t really need to provide you username and password every time, you don’t really need it. Just set your calendar in the command line as above.

I must say that I am quite happy with the result having everything installed, no-intrusive 3rd party applications, and no constant request for applications and antivirus updates. The only thing I missed was although firefox and chrome (under the xfce/gnome desktop) does support flash, I was not able to view video series online on citytv.ca (brightcove.) and ctv.ca (bmp) which use special coding in their flash videos so you can’t skip advertisements and video controls. Doesn’t work on any of the linux machines I’ve tried although flash videos do work.


Viewing all articles
Browse latest Browse all 13

Trending Articles