Creating a Linux Backup Solution on Ubuntu

Before today, my backup solution for my Ubuntu servers was pretty simple – two tar files; one for the web page folders and another for mailbox backups.  This was done by the following command:

rm /<location>/daily-www-backup.tgz > /dev/null
rm /<location>/daily-mailbox-backup.tgz > /dev/null
tar pzcf /<location>/daily-www-backup.tgz /<location-to-backup> > /dev/null
tar pzcf /<location>/daily-mailbox-backup.tgz /<location-to-backup> > /dev/null

However, there is a problem with this situation.  The above will basically first delete the backup files and then re-create them each day.  This is in essence a “full backup” technique every day.  But, what happens if a file is overwritten and it isn’t noticed until a few days later?  Woops!  Too late now.

So I began doing a little research on how to perform differential backups in Ubuntu.  I came across “dar” – a program that will do both a full backup and a differential backup based upon the full backup.

I also installed Kdar on the server – which is a GUI front-end of dar from KDE.  It seems that this was no longer supported in the archives after the Ubuntu dapper release, so in order to get Kdar on my current systems, I had to put the following line in the bottom of the /etc/apt/sources.list file:

deb http://gb.archive.ubuntu.com/ubuntu dapper universe

I then performed the update so this new location was cataloged:

sudo apt-get update

Then I installed kdar and dar:

sudo apt-get install kdar dar

Afterwards, I then opened up kdar (had to run as root as well to backup files that my user account didn’t have) and setup a backup job.  It gave me the option to Export the dar command to a shell script, which looked like the following:

dar -c “/<location>/SundayFullBackup” -R “/home/” -w -D -y -m 150 -P “Folder1” -P “Folder2” -P “Folder3” -P “Folder4”

Here is how the command works:

-c – This option tells dar the name of the file that will contain the backup
-R – This option tells dar the location that should be backed up
-w – This option tells dar not to warn when overwriting files
-D – This option tells dar to store excluded directories as empty directories in the backup file (see -P for excluded directories)
-y – This option tells dar to use the bzip2 compression technique (instead of -z which uses gzip; bzip compresses more)
-m 150 – This option tells dar not to compress files less than 150 bytes in size
-P – This option tells dar to exclude a directory from the archive.  In my case above (which I’ve changed the folder names), there are four folders that I’ve excluded from the backup

By using the -P command, this allowed me to backup both the mailboxes and web data at once instead of having two backup files and two separate processes.

With this command alone over the tar command, it saved about 17 megabytes of space.  Tar uses the gzip compression technique with using the “z” option.  So the two combined files using tar was 880 megabytes.  The one file made by dar is 863 megabytes.  While this isn’t much of a savings, it still is an improvement over tar.

Another improvement over tar (and the main reason I installed the Kdar GUI) is that you can extract specific files and folders from a dar backup file.  Tar requires you to unpack and unzip the entire archive to a directory and then pick and choose what needs restored.

Now, how is it that you create a differential backup?  Let me know show you the command that Kdar made to create a differential backup:

 dar -v -c “/<location>/MondayDiffBackup” -R “/home/” -A “/<location>/SundayFullBackup” -w -D -y -m 150 -P “Folder1” -P “Folder2” -P “Folder3” -P “Folder4”

While the command looks quite similar to the full backup command, there are a few extra options on this that I’ll go over here.

-v – Verbose output – This will output a list each day the differential is run to show what files have changed since the last full backup.
-A – This option tells dar the location of the full backup that the differential should be based on.  This is how dar can tell what files have been changed/modified and need to be backed up to the newest copy.

That is all there is to it!  However, I had a problem when trying to run a differential.  Since I am going to set these all up as cron jobs, I needed them to run without any intervention.  The full backup worked fine when I ran the shell script, but unfortunately the differential backups would not.  I kept getting this message when I would try the differential backup:

Warning, SundayFullBackup.1.dar seems more to be a slice name than a base name. Do you want to replace it by SundayFullBackup ? [return = OK | Esc = cancel]

I searched online and could not find a solution to the problem.

Originally, I created the full backup using Kdar.  So I pondered if maybe Kdar did something different with backing up the original file.  Therefore, the original full backup file was deleted and then I re-created it using the shell script that Kdar.  When I then run the differential backup – poof!  It worked without any intervention required and it worked well.

So, a good solution for performing differential backups in Linux would be to use a combination of dar and Kdar.  Kdar is best used only as the restore program so you can pick and choose what files you want to restore – and dar is needed as the command-line program so you can create a cron job and have these run.

How to Get Page Title in Joomla 1.0.x

Search terms:
How to get the page title in Joomla 1.0.x
How to get the content title in Joomla 1.0.x
How to get the article title in Joomla 1.0.x
How to show the page title in Joomla 1.0.x
How to show the content title in Joomla 1.0.x
How to show the article title in Joomla 1.0.x

After several long hours of trying many methods of obtaining the page title of a content item, I finally stumbled across the solution.

 In my blogs, I wanted to have the pagination and the results of additional blog entries at the bottom of the page (as you can see on this page where it allows you to click next/previous/etc).  If I turned off pagination, the actual title of the content item would appear in the title.  However, if I turn on pagination, it does not do so IF you follow the links using the pagination below.  You can try this yourself – if you click on “next” below, you will see the title of the page at the top of your browser say “BsnTech Networks – BsnTech Blog – Computers” instead of the actual name of the content item.

Why do I want the content item title so bad?  Well, I use a tracker on my site to see what pages visitors are viewing.  If I can’t get the correct title, every Computer blog entry (or any other Blog I have) will show as the very same page – because the actual title never changes!

So I FINALLY found a solution that will allow me to keep the pagination feature on and to log the REAL content item title that each visitor views.

I tried many methods and none worked.  I tried to get the Itemid, id, Contentid, and many other options.  With the pagination feature on, none of the IDs returned were the actual ID of the content item in question – it was some other ID.  I was going to couple this with a database query to pull the title from the content table where the id equaled the page’s ID.  No-Go.

I then tried to use the mosMainBody() feature and store it to a PHP variable – where I would then get the string after the “contentheading” TD Class.  When I tried this, the whole mosMainBody actually appeared on the webpage and this wasn’t succesful either!

So, alas, I have the solution to finally allow you to get your page title in Joomla 1.0.x and store it to a PHP variable.  Here’s the trick:

You need to open up the content.html.php file in the components/com_content directory.  You then need to go down to around line 624 – I cannot tell exactly what line yours may say because I’ve done other tweaking to this file, but the line will look like this:

function Title( &$row,  &$params, &$access ) {

Just under this line, I added the following lines.  The following lines will basically take the page title and store it in a GLOBAL PHP variable called “myTitle”.  It has to be a GLOBAL variable so that it can be accessed in your template.

//below are two lines added to get the page title and store it in myTitle
global $myTitle;
$myTitle = $row->title;

Now, go into your template index.php file and you can use the $myTitle variable anywhere that you want the actual title of the content item to show up.

So now I have the both of best worlds on my blogging sites – I can allow my visitors to use the pagination features at the bottom of the blog pages to follow my blog entries in order, list the blog entries on the right-hand side so visitors can click specifically on an entry that interests them (this was other PHP code I wrote to pull the data from the database and construct the link – which actually does show the correct title in the browser’s title bar), and also see what pages visitors view on my statistics information pages.

 

New Program Creation – The Wootamator

Introducing a new program that was just created by BsnTech Networks – “The Wootamator”.

The Wootamator is a Woot Bot that will automatically pull the item name, item price, and a picture of the item and display it on your desktop.  This automatic Woot program will also display pop-up boxes during a Woot-Off that will indicate when the item has sold out and when a new item is posted to the site.

The program will not buy you a Bag of Crap – or “Random Crap” as it is listed on the Woot! site.  However, it will alert you when the Bag of Crap appears and the button in the main page will allow you to go to Woot! quickly.

Here is a screen shot of the main program showing a 1 GB Sansa Clip:

Wootamator

A version was made for Windows and a version was also made for Linux OS systems.

You can download the Wootamator here.

 

Why I Prefer Linux…

Today I discovered yet another reason why I prefer running Linux servers instead of Windows servers…

Hardware Failures

I noticed over the course of the past week, the Decatur server seemed to have been rebooting for no reason at least once and sometimes twice a day.  My first thought was the power supply.

I changed out the power supply with a new one – and the server rebooted again for no reason.

Next I checked the memory using the memtest86+ Linux utility.  The server has 2 pieces of GSkill 2 GB DDR2-800 memory and the motherboard has two banks.  I ran the test and it got to about 2% (took about five minutes) and the server rebooted again!

So I thought it was possibly the memory.  I took out one of the memory modules, ran memtest86+ again, and the test fully completed an hour later.

The server was shut down again and the other memory was added back to bank 2.  I re-ran the test – just thinking maybe it was a fluke of chance the server rebooted during the process, and again – about 2% it restarted again.

This time I took the memory out of bank 1 – the one that previously tested just fine.  So only the previously untested memory was in bank 2.  Turned the server on – and it wouldn't even post.

Oh boy I thought – I've got some bad memory.  So I turned the server off and put the memory in bank 2 into bank 1 – this time figuring I would check the memory controller on the motherboard.  Turned the server on – and again, wouldn't even post.

I put the original tested memory back into bank 1 and took the other memory out of bank 1 and put it off to the side.  This previously worked – and again, the server wouldn't post yet again.

Luckily a few months back, I upgraded our home computer and had a full motherboard/processor/memory combo in storage.  I took it out, got it all setup, hooked in the server's hard drive and CD-ROM and poof.. off and running.  Before I booted onto the server hard drive, I booted off the CD and did a full image of the server hard drive – just in case the new motherboard/processor/memory combo caused problems.

Rebooted after making the image – and viola!  The Linux server kicked right off – and needing no additional drivers or loading anything!  I did have to go in and change the MAC address for the network card – otherwise it was showing up as eth1 with no configuration.  Easily done – I just opened up the /etc/udev/rules.d/70-persistent-net.rules and removed the line for the old network card – then changed the "eth1" to "eth0" on the end of the new card.

Much easier than a Windows server where you would have possibly had re-activation, new drivers to download and configure, and who knows what other potential problems.

The Decatur server's motherboard is only about 1.5 years old – I am appalled that the memory controller has gone bad.  I did notice there was one capacitor that was raised and looked like it was just beginning to leak – so I wonder if it is the culprit.  The original board was an ECS AMD69GM-M2.  I just ordered a new JetWay JM26GT4-LF motherboard today.  I got it for a steal of $35 including shipping.  Otherwise, I was contemplating leaving the system as-is with the AMD XP3200+ 64-bit processor and 1 GB of memory.  The other processor/memory was an ADM 64 X2 2.2 GHz and 4 GB of memory.

How To Setup Automatic Shutdown and Automatic Wakeup in Ubuntu 9.10 Karmic MythTV

If you are interested in helping your power bill by a small amount, then this How To will assist you in setting up your MythTV computer to automatically shutdown between recordings and automatically wake back up using the BIOS real-time clock wakeup technique.

It took me a few days to finally get this working for me, but this may work for several other motherboards.  This was specifically tested on an ECS GF8200A motherboard.

The first step is to ensure you go into your BIOS and change a setting under the “Power Management Setup” entry.  In there, another entry which says “Resume on RTC Alarm” whould be DISABLED.  Although this seems like backward logic, this is the correct way to setup the entry to allow Ubuntu to write to the ACPI RTC “file”.

OK, now that the BIOS setting is done, it is time to boot into Linux.  One file needs to be modified just a bit.  Open the /etc/default/rcS file with a text editor (vi, gedit, mc – whichever you prefer).

sudo vi /etc/default/rcS

Now, you need to check one setting.  One says “UTC=…”  Make sure this setting says:

UTC=yes

After that, you will most likely need to add a line to the end of the file:

HWCLOCKACCESS=no

Now reboot one more time to ensure that these settings will take affect correctly.

After rebooting, it is now time to check the actual ACPI wake-up technique on your PC.

To do so, issue this one command.  This command will set the clock to turn your computer on five minutes from the time you issue the command:

sudo sh -c “echo `date ‘+%s’ -d ‘+ 5 minutes’` > /sys/class/rtc/rtc0/wakealarm”

To check to ensure the setting took, enter:

cat /sys/class/rtc/rtc0/wakealarm

It should give you a large group of numbers to indicate the alarm has been set successfully.

Now, shudown your computer (not just a restart).  Hopefully your computer will turn back on automatically.

If your  computer turns back on in five minutes, then you’ve confirmed that your BIOS will automatically turn back on – and all of your settings for this feature are correct!

Now it is time to get the capability built within MythTV.  For this, there are a few scripts that need to be created.  This first script is a simple one that will check to see if a user is logged in.  This is a custom script that I made and simply checks to see if certain programs are running.  If they are running, the computer will be prevented from being shutdown.  You will see that I’ve made entries for things like firefox, audacious, mythfrontend, boxee, checking to see if someone has an ssh connection open, and some others.  You can modify this to meet your needs.  Save it in your home folder as checklogin.sh:

# Check to see if anyone is currently logged in. Return zero if not and 1 if so.
# Echoed text appears in log file. It can be removed and –quiet added to the
# grep command once you are satisfied that mythTV is working properly

if
  w | grep “pts”
  then
     exit 1
fi
if
  ps -A | grep “boxee”
  then
    echo Someone is still logged in, don\’t shut down!
    exit 1
fi
if
  ps -A | grep “mythfrontend”
  then
    echo Someone is still logged in, don\’t shut down!
    exit 1
fi
if
  ps -A | grep “audacious”
  then
    echo Someone is still logged in, don\’t shut down!
    exit 1
fi
if
  ps -A | grep “firefox”
  then
    echo Someone is still logged in, don\’t shut down!
    exit 1
fi
if
  ps -A | grep “mythcommflag”
  then
    echo Someone is still logged in, don\’t shut down!
    exit 1
fi
    exit 0

After saving the file, ensure you set this file to be executable:

chmod +x checklogin.sh

One more script to make and we’ll be set.  This next script sets the logic that will set the ACPI wake-up time before the computer shuts down.  Save this file as MythWakeSet in your home folder:

< id=”code”>#!/bin/sh

# inspired from http://www.mythtv.org/wiki/index.php/ACPI_Wakeup
# and https://help.ubuntu.com/community/MythTV/Install/WhatNext/ACPIWake
#
# MythWakeSet
#
# set mythtv wake-up time with UTC-adjusted time
#
# use: MythWakeSet date time     
# ex.: MythWakeSet 2008-11-02 20:15:00
# See also ‘man date’ for date/time-formats.

# TimeZone, use +0100 for GMT+1
#TZ=”+0100″
TZ=$(date +%z)

LOG=/var/log/mythtv/mythbackend.log

DATE=$(date -d “$1 $2 $TZ” “+%F %H:%M:%S” -u)
SECS=$(date -d “$1 $2” “+%s”)

echo Running $0 to set the wakeup time to $1 $2 >>$LOG

if [ -e /sys/class/rtc/rtc0/wakealarm ]; then
  echo 0 > /sys/class/rtc/rtc0/wakealarm
  echo $SECS > /sys/class/rtc/rtc0/wakealarm
  echo “echo 0 > /sys/class/rtc/rtc0/wakealarm” >>$LOG
  echo “echo $SECS > /sys/class/rtc/rtc0/wakealarm” >>$LOG
  cat /proc/driver/rtc  >>$LOG
else
  if [ -e /proc/acpi/alarm ]; then
    echo $DATE > /proc/acpi/alarm
    echo “echo $DATE > /proc/acpi/alarm” >>$LOG
  else
    echo “ERROR, Wakeup not set, no /sys/class/rtc/rtc0/wakealarm and no /proc/acpi/alarm found” >>$LOG
  fi
fi</>

Do the same thing with this file as well to ensure it is executable:

chmod +x MythWakeSet

Now, one more last thing to do before getting into the settings of MythTV Backend to make this all possible.

You need to allow the mythtv user (or whatever user is logged into the computer) to run the MythWakeSet script and shutdown routines without being a root user.  To do this, type:

sudo visudo

At the end of the file, put in the following (the first word may vary depending on your username used – I put in both entries just to be safe):

%mythtv ALL = NOPASSWD: /home/user/.mythtv/MythWakeSet, /sbin/shutdown, /bin/sh
%user ALL = NOPASSWD: /home/user/.mythtv/MythWakeSet, /sbin/shutdown, /bin/sh

 Now all of the configuration for the operating system is done.  It is time to open up your MythTV Backend to make some changes.  Go to your Menu at the top (it will say “System”), choose “Administration”, and then choose “MythTV Backend Setup”.

Once it loads, go into the “General” item and then you will have to go through a few screens until you get to the Wakeup/Shutdown settings.

– Uncheck the Block Shutdown checkbox

– Idle Shutdown Timeout – set this to how many minutes you want your computer to be idle before it shuts down.  I have mine set to 10 minutes (600 seconds).  This way if all of your applications are closed on the computer (basically those that you outlined in your checklogin.sh script), the computer will shut down.

–  Max wait for recording – set this to how long the computer will stay on if a recording is scheduled.  If you have a recording that will take place in two hours and want your computer to stay on, you will put 120 in this field (since this is in minutes).  This ensures that the computer will not shut down and then turn back on x minutes later for a recording.  If you only have 30 minutes between a recording, it would be pointless to shutdown the computer for 20 minutes (30 minutes – the Idle Shutdown Timeout setting indicated above).

Startup Before Recording – this will set extra time to allow the computer to boot up.  If a recording starts at 3:00 pm and your computer takes a minute to boot, you will want to ensure this setting is set to at least 60 seconds (I would do 120 seconds to be safe – in case a disk check or something else runs).  Otherwise if you do not set this, the computer will start up right when the recording is supposed to start at 3:00 pm and cut off part of your recording.

Wakeup Time Format:  Set this to: yyyy-MM-dd hh:mm:ss

Command To Set Wakeup Time: sudo -H /home/USER/MythWakeSet “$time”     —– This command should point to the script that you created above to setup the ACPI wake-up time.  Note to change the USER part with your username for the home folder where you saved the script.

Server Halt Command:  sudo -H shutdown -P now    ———– This is the command that will shutdown your computer.  I used the -P setting which means to power off the computer for the full shutdown.

 Pre Shutdown Check Command:  sudo -H /home/USER/checklogin.sh    ———- This command should point to the script that you created above that will check to see if there are any specific programs running.  If they are, this will ensure the computer does not shutdown.  Note to change the USER part with your username for the home folder where you saved the script.

That is all!  Now close out of Myth-Backend and you should be ready to go!

RealTek 8185 Wireless on Ubuntu 9.04 Jaunty

Tags:

RealTek 8185 Slow on Ubuntu 9.04 Jaunty
RealTek 8185 problems on Ubuntu 9.04 Jaunty

I have been running Ubuntu 9.04 Jaunty now for a few weeks and I like all of the extra features and the fact that it is open source.  Part of being open source is the idea of sharing information and passing along other solutions to others.

Since moving to Ubuntu 9.04 Jaunty, I've noticed extreme wireless network slowness.

I have a Gateway MT3422 laptop with the RealTek 8185 wireless card built-in.  With Ubuntu 9.04 Jaunty, there is bult-in support for this card using the rtl8180 driver that is in the kernel.  Unfortunately, this driver causes very bad wireless signal in Ubuntu 9.04 Jaunty.

After reading several articles online, I finally was able to get a much better wireless signal.  In addition, the connection is much more stable and I don't have anymore problems with the RealTek 8185 wireless card in Ubuntu 9.04 Jaunty.

To start off, you will want to download the ndiswrapper utilities.  To do this, go to your main menu and then choose Add/Remove.  In there, ensure that "All Available Applications' is selected.  Then type in "ndis" in the search box and wait for the results.  After a few moments, you should see "Windows Wireless Drivers" show up.  Check the box to install this and then hit Apply Changes.

This will install the graphic user interface for the ndiswrapper along with the ndiswrapper-common and ndiswrapper-utils packages.

Now that these are installed it is time to download the RealTek 8185 driver.  I have created an archive file that is available here which includes the three files needed.  Extract these to a folder in your home folder for easy access

Now that you have the RealTek 8185 wireless driver downloaded and ndiswrapper insalled, it is time to blacklist the built-in rtl8180 driver in Ubuntu 9.04 Jaunty. Navigate and edit the /etc/modprobe.d/blacklist.conf file.  In there, scroll all the way to the bottom and add the following line:

blacklist rtl8180

Now close and save this file.

Go ahead and reboot your PC.  Once back in Ubuntu, you'll notice that you are no longer connecting to your wireless card.  It is now time to get ndiswrapper and the recently downloaded drivers working.

Go to your main menu – System – Administration – Windows Wireles Drivers.

In here, click "Install New Driver".  Now, browse for the RealTek 8185 driver you just downloaded, and double-click on the net8185.inf file.  You may get a message about the hardware not being found, but that is fine.  You should now see the net8185 driver and it should say "Hardware present:  Yes".

You may then need to right-click on your network icon on your panel and choose "Enable Wireless".

PPTP VPN on Ubuntu Jaunty Dies When Using Samba

Recently I began dual booting my laptop with Ubuntu 9.04 (Janty) to mess around with Linux again.  There were a few things that didn't work quite right with previous versions of Ubuntu (wireless card wouldn't work and sound wouldn't work without a lot of tweaking).

One thing that I really like about Ubuntu/Linux is the fact that it is relatively secure from viruses and all those popups online about your computer being infected with viruses and spyware.  It is also very stable and doesn't seem to slow down the longer you leave the computer on.

Another big plus is the cool Compiz Fusion desktop effects – ranging from 3D cubes, animations, and many other features.  While this is just "eye candy", when anyone else sees these features, they are intrigued and they all want those effects for their computer!

However, I have fallen on to one problem with Ubuntu 9.04 (Jaunty) that is somewhat of a problem for me – PPTP VPN and moving large files or big chunks of data.  Using the built-in Network Manager in Ubuntu, there are a few packages you need to install to allow you to use a PPTP VPN.  The neat thing about the way it is setup is that the network icon on your panel can be clicked – then there is a VPN menu in there and it is quick and easy to connect to a VPN connection.

To install the needed features to get a PPTP vpn to work, issue the following command:

sudo apt-get install network-manager-pptp

 After installing the PPTP items for VPN, you can then configure your VPN by left-clicking the network icon in your panel, go to VPN Connections, and then Configure VPN.  In there, you will setup your new VPN connection with all of the items you need.  One issue that was a problem previously was the fact that you couldn't disable EAP authentication.  In the new Network Manager, you can disable this feature.  I only select the one authentication method I allow for VPN and uncheck the rest.  Under the IPv4 settings, there is a Routes button.  In here, I ensure to check the "ignore automatically obtained routes" and "Use this connection only for resources on its network."  I then have to specify the route I want by clicking in each of the fields in the box above.  This will ensure that anytime I enter an IP address within that network range, it routes it over the VPN instead of the connection being attempted over the default route (regular Internet).

I then can connect up to the VPN and it works just fine!  However, I found a slight problem – the VPN will fail and disconnect anytime I attempt to transmit a large amount of information!  Specifically, when I attempt to use VPN to connect to a Samba server on the network, it fails.  I can open up the Samba share and see all the shared files/folders, but the moment I attempt to copy or delete a file on the share, the VPN would fail.  Every now and then, the VPN would also fail if I used the Terminal Services Client in Ubuntu to connect to a VNC connection on the network.  However, it does appear that I was able to use SSH fine through the VPN – but I rarely need that use versus the ability to move and transfer files.

After working on the problem for a bit, the error logs were showing the following when the disconnect happened:

Jul 31 10:20:16 Desktop pptp[5449]: nm-pptp-service-5440 warn[decaps_gre:pptp_gre.c:331]: short read (-1): Message too long

 After a little bit of tweaking using a manual method of making a PPTP connection, I discovered that the problem was the MTU (Maximum Transmission Unit) seemed to be too large.  When connecting to a VPN using the Network Manager, it sets the MTU at 1400.  The MTU on the Ethernet connection is 1500.  I played with the MTU/MRU numbers in a manual configuration file for a little while until I discovered that an MTU/MRU of 1250 was the highest I could set it.  If it Iset it at 1275, the connection would also fail when attempting to move data to a Samba share over the VPN.

So, needless to say, I am having to manually connect to VPN for the time being.  I'm surprised that the VPN Network Manager in Ubuntu will not allow you to set the MTU of the connection.  If this could be done, this problem would be easily resolved by allowing users to change it to what is the most stable.  Below I will illustrate the steps I used to get the VPN to work manually.

 First, you will need to open your chap-secrets file as the root user (/etc/ppp/chap-secrets).  Make an entry similar to the following:

USER     PPTP     PASSWORD     *

Ensure to set USER to the username for the connection and PASSWORD to the password for the connection.  PPTP says that it will be used on the PPTP connection and the * (asterisk) indicates that the username/password will be used for any PPTP connection you make to any server.  You can also change this specifically to the IP address or server where the connection will be made.  Now save and close the chap-secrets file.

The next file to change will be your options.pptp file (/etc/ppp/options.pptp).  If you use MPPE encryption, you will want to ensure to remove the hash sign (#) from in front of the appropriate command.  If you use 128-bit MPPE, remove the has in front of the "require-mppe-128" line.  Also, ensure that your configured authentication type is allowed.  In the configuration file, the default authentication types are all refused:

refuse-pap
refuse-eap
refuse-chap
refuse-mschap

After you have your settings updated, click Save and close the file.

Now, there is one more file you need to modify – this one you actually will need to create.

Go into your /etc/ppp/peers folder.  In there, create a new file.  You will have to have root access in order to get into this folder.  For simplicity, I would make it one word – maybe just VPN.  Now, here is a copy of the file I made.  I named mine VPN as well:

pty "pptp SERVER  –nolaunchpppd"
name USERNAME
remotename PPTP
file /etc/ppp/options.pptp
ipparam VPN
mru 1250
mtu 1250

Let's go over some of those settings.  The first line has SERVER in it.  Ensure this is changed to the IP address or fully qualified domain name of the VPN server you will connect to.  For the name line, ensure you change the USERNAME to the username you use to connect to vpn.  For the remotename line, PPTP is shown here.  This corresponds back to the /etc/ppp/chap-secrets file (remember where PPTP was put in?).  Lastly, the ipparam line, VPN is the name of this file you saved.  So, since I named mine VPN, it says VPN.  You can see also that I pushed the settings of the MRU and MTU to 1250 – which are the two lines needed to keep the VPN running stable.  Now, save and close this file.

You are all done with the manual method of a PPTP VPN connection!

In order to run the VPN connection, you will then run the following command as root:

pon VPN

Again, ensure VPN is the name of the file you saved in the /etc/ppp/peers folder with your connection settings.

After connecting to VPN, I bet you notice that nothing is working!  This now because you need to tell yoru computer what to route through the VPN.  This can be done by the following:

sudo route add -net 192.168.254.0/24 dev ppp0

Ensure you put in the network range that your VPN uses.  When I connect to VPN, I get a 192.168.254.x IP address – and I know that the network all is within that range.

If you want the route to be automatically be added when the connection is made, this can also be done.  This alleviates an extra command that has to be entered whenever you make a connection.

To have the route added automatically, navigate to your /etc/ppp/ip-up.d folder.  In there, create a new file called route-traffic.  Type in the following:

#!/bin/bash
route add -net 192.168.254.0/24 dev ppp0

Close and save the file.  Now ensure that it is executable by running:

sudo chmod 755 route-traffic

The file will then run whenever your VPN connection is created.

So, you are now fully connected to your VPN!  Now, to disconnect, enter the following command as root:

poff VPN

Again, where VPN is the name of the file you saved in /etc/ppp/peers.

This is definitely a long work-around for VPN, but once it is setup, it is just a matter of issuing the two commands to connect (or one if you made the route-traffic file), and the one to disconnect.  I am hoping that they will fix t he Network Manager to allow users to put in their own MTU levels sometime shortly.

HOWTO: Setup MythTV, Myth Plugins, SPDIF Audio, Xabre 330 on Ubuntu 32-Bit Linux 8.10 Intrepid

I realize that the release of 9.04 is just right around the corner for Ubuntu, but I have been working on a project to convert the home theater PC from Windows to Linux for the past few weeks.  Over the course of this time, I have researched on many different blogs and help forums to piece all of this together.  This is specifically for the 32-bit installation as there are many applications that have trouble with the 64-bit installation (like the Sun Java and Adobe Flash plugins).

Please note that this setup is composed of several different parts and pieces – so if you are having various problems with audio, ac3 pass-through or dts pass-through in Ubuntu amongst other things, this might help a bit.

Let’s first start off with getting SPDIF output on Ubuntu Linux 8.10 Intrepid working.

Search Tags:
SPDIF not working in Ubuntu 8.10 Intrepid
Firefox has no sound in Ubuntu 8.10 Intrepid
Coax output doesn’t work in Ubuntu 8.10 Intrepid
Sound doesn’t work in Ubuntu 8.10 Intrepid

OK, those above are mostly to help people find this page to maybe alleviate some of their issues.  I had trouble getting SPDIF output working on Linux.  This is because Ubuntu now uses the PulseAudio server to play music through the main system and PulseAudio only is setup to detect the primary card, but not the IEC958 / SPDIF output.  So for this, we have to change a few settings.  Many other people try to completely remove PulseAudio or have very long instructions for  a work-around, but this is a bit quicker.

Edit the /etc/pulse/default.pa file and add this line close to the other lines (around line 32):

load-module module-alsa-sink device=hw:0,2

At this point, go ahead and reboot your PC so that PulseAudio is updated with the new module.

The next step is to install the Pulse Audio Device Chooser.  Go to Applications – Add/Remove.  In the drop-down list that appears, choose “All Available Applications” and then search for “pulse”.  Put a checkmark next to the Pulse Audio Device Chooser and hit Apply Changes.

Now, open the program by going to Applications – Sound/Video and then click Pulse Audio Device Chooser.  It will open a new icon up by your network or sound on the top bar.  Left-click on it once and choose Preferences.  In there, put a checkmark next to “Start applet on session login” and hit Close.

Lastly, left-click on it again and choose Default Sink and select Other.  In the box that pops up, type in the following:

alsa_output.hw_0_2

Now, open up Firefox or something else that will play some kind of sound.  You should now have sound through your SPDIF!  If not, there are a few other things to check.

Go to System – Preferences – Sound.  In there, make sure you choose your IEC958 device for each of the items (except sound capture).  Mine shows up as “NVidia CK8S with ALC655 NVidia CK8S – IEC958 (ALSA)”.  For the Default Mixer Tracks, change the drop-down box to your Alsa-mixer (mine shows as “NVidia CK8S (Alsa MIxer)”)  In the list of items, ensure “Master” is selected and close the window.

Next, right-click your Volume control on the top bar and choose Open Volume Control.  In there, ensure your Alsa Mixer is selected again (mine shows as “NVidia CK8S (Alsa mixer)”).  Click the “Preferences” button and put a check mark next to the IEC958 with Playback and Switches on the right-hand column and hit Close. Back in the mixer, scroll over to the right (if needed) and ensure that the IEC958 is not muted.  The volume can be all the way down, that doesn’t matter.  Now click the “Switches” tab and ensure to put a check mark next to IEC958.  Now try to play something on your computer.


Setup SiS Xabre 330 Video Card for Dual-Head Mode in Ubuntu Linux 8.10 Intrepid

I have a SiS Xabre 330 video card.  This card has both a VGA connector and a TV-Out connector.  In Windows, I could have both a monitor and a TV going with different pictures at the same time – which is called dual-head mode.  For Linux, I opted to have the same display on both – just because the only thing we use the TV for is watching movies and the like.  Therefore, I “cloned” the desktop (as you will notice below).  I highly recommend performing a backup of your /etc/X11/xorg.conf file before making changes to it.  I noticed that with the default Ubuntu install, when I would play live TV or movies, the TV shows a blue screen while the monitor would have the movie playing.  This configuration corrects that.

Section “Device”
     Identifier “Card0”
     Driver “sis”
     VendorName “Silicon Integrated Systems [SiS]”
     BoardName “330 [Xabre] PCI/AGP VGA Display Adapter”
     BusID “PCI:1:0:0”
     Screen 0
     Option “ForceCRT1VGAAspect” “normal”
     Option “ForceCRT1Type” “VGA”
     Option “ForceCRT2Type” “COMPOSITE”
     Option “UseSSE” “on”
     Option “TVStandard” “NTSC”
     Option “MergedFB” “on”
     Option “CRT2Position” “Clone”
     Option “MetaModes” “1024×768”
     Option “CRT2HSync” “30.0 – 50.0”
     Option “CRT2VRefresh” “59.9 – 59.9”
     Option “XvOnCRT2” “yes”
EndSection

Section “Monitor”
     Identifier “Monitor0”
     HorizSync 30 – 95
     VertRefresh 75
EndSection

Section “Screen”
     Identifier “Primary Screen”
     Monitor “Monitor0”
     Device “Card0”
     DefaultDepth 24
     SubSection “Display”
          Depth 24
          Virtual 1024 768
     EndSubSection
EndSection

Section “ServerLayout”
     Screen 0 “Primary Screen”
EndSection

One thing to note above is the Option “XvOnCRT2” “yes” line.  This line tells the video card to put all video overlay for live TV, movies, or any other motion pictures on the TV-Out port instead of on the VGA port.  This means that the blue screen that was on the TV-Out will now be on the monitor when you playback.


Setup MythTV, MythVideo, MythStream, and other applications on Ubuntu Linux 8.10 Intrepid with a Hauppauge PVR-150 Tuner Card

This next section, again, is setup specifically for my needs.  But these will also work for you as well.  Included is Adobe Flash and Java for Firefox – since Ubuntu does not come bundled with them installed. Let’s get right to it.

At a terminal window, type:

sudo apt-get install mythtv mythvideo mythstream mc flashplugin-nonfree sun-java6-plugin audacious mplayer lirc ncurses-dev gstreamer0.10-ffmpeg gstreamer0.10-fluendo-mpegdemux

Let’s go over what each of these are.

  • mythtv – The program for making your PC into a Home Theater PC.  MythTV provides the applications for playing and recording Live TV, playing DVDs, playing video/music streams, and allowing you to play your other videos.  MythTV has plugins (I use two of them listed below) for providing the functionality.  MythTV is kind of like a digital cable box and DVR rolled into one – plus extras.  It will also allow you to get Program Guide information (like TV Guide).
  • mythvideo – MythVideo is the plugin that will allow you to play videos you have on your computer.  In addition, MythVideo also comes with some scripts that will query the IMDB site and download movie posters and other metadata for videos
  • mythstream – MythStream is another plugin for MythTV that will play back streaming content from the Internet.  You can use it to view movie clips and such from YouTube or DailyVideo.  Apparently the developers are trying to get it to work with Hulu, but I haven’t seen this working yet.  MythStream also allows you to stream online radio stations from ShoutCast – which is my primary purpose for this plugin.
  • mc – This is “Midnight Commander” which is a file editing/manipulation GUI that runs in a terminal window.  I use it for editing all the files I need instead of using gEdit or others (quicker at the command line)
  • flashplugin-nonfree – This is the Adobe Flash Plugin.
  • sun-java6-plugin – This is the Java plugin for Firefox.  It will take care of downloading all the other needed Java packages with just this one package.
  • adacious – A media player that looks similar to Winamp
  • mplayer – A Movie Player that is used by the MythVideo plugin in MythTV to play the movies
  • lirc – an Infrared Controller for Linux.  If you received a remote with your TV tuner card (as I did with the Hauppauge PVR-150 card), this package will allow you to use your remote to control MythTV and MPlayer (amongst others).
  • ncurses-dev – Development package for the LIRC package that is needed
  • gstreamer0.10-ffmpeg – This is a package of “codecs” needed to decode videos and other streams.  My videos are in XviD format.  This package will allow for those to play in addition to AC3 or DTS encoded files
  • gstreamer0.10-fluendo-mpegdemux – This package allows you to play back MPEG-2 files in other media players, like Totem.

During the install process, it wll prompt you to enter a MySQL root password – it did twice during my install.  Do not enter a password and just hit OK  – otherwise the MythTV instalation won’t go as smoothly.

Also – when LIRC is installed, it will prompt you for the remote you are using.  In my case, I selected “Hauppauage TV Card”

After it is done installing, it is now time to setup MythTV.  Point to System – Administration – and then MythTV Backend Setup.  You can change these settings as you wish, but here is what I have.

General

  • Time Zone – Auto
  • Channel Frequency – us-cable
  • Start auto-commercial flagging jobs – Yes

Capture Cards

  • Change the drop-down box from V4L to PVR-x50
  • Video device at /dev/video0
  • Audio device at /dev/vbi0

Video Sources

  • There is a blank source – hit Enter to open this one and rename it to Default
  • Choose No Grabber
  • Frequency is us-cable

Input Connections

  • Under Tuner 1 – use the Default video source
  • DO NOT Scan for Channels (covered later as the Program Guide setup will allow you to choose which channels you want to include and will not duplicate.  If you scan for channels and use my instructions for the program guide, you will have duplicate channels)

Storage

  • Put in your location where you want the LiveTV and TV Recordings saved to.  Ensure that the mythtv user has access to write to this folder otherwise when you click “Watch TV” in MythTV, it will flash the screen black and then go back to the main menu.

That is all!  Now, open the MythTV Frontend which is under Applications – Sound/Video.  Then go into the Utilities/Setup menu.

General

  • Enable AC3 to SPDIF (allows for pass-through of the better quality sound without changing it to PCM)
  • Enable DTS to SPDIF (reason is same as above)
  • Passhtrough Output Device – IEC958 (set this if you are using SPDIF for output)
  • Audio Output Device – ALSA:SPDIF (set this if you are using SPDIF for output)
  • Uncheck the Confirm exit (so MythTV closes instead of asking if you are sure about that)
  • Uncheck the auto run Mythfilldatabase (explained later as well with the Program Guide setup)

Appearance (all of these are solely up to you)

  • UI Theme – Blootube
  • Font Size – Small
  • Unhide mouse cursor

TV Settings

General

  • Uncheck Auto Expire Default
  • Uncheck Strict commercial detection
  • Uncheck Run Transcoder (I don’t use transcoders to turn the video format of recorded TV into another since my PVR-150 card automatically encodes in MPEG-2 format)
  • Make the Default Transcoder “Autodetect”
  • Record past end of show – 0 Minutes

Program Guide

  • Guide Starts at Channel 2 (You probably can’t set this until you get the channels setup.  I will create the channels with the instructions on the Program Guide below)
  • Check Use Select to change channels
  • Check Allow channel jump

Playback

  • Uncheck extra audio buffering
  • Check enable picture controls (allows you to set Brightness, Contrast, Hue during TV or playback)
  • Default group filter to apply – “All Programs” (I use this so I can see the LiveTV recordings that haven’t auto-deleted and I can delete them if I wish)
  • Automatically Skip Commercials – Automatically Skip

Playback OSD

  • OSD Theme – Blootube

Recording Profiles

  • Ensure the Sampling Rate on all of the MPEG-2 encoders are 48,000
  • Change the Bitrate/Maximum Bitrate on all the MPEG-2 encoders (Default, High Quality, Low Quality) to 1900 bits (this will use about 1 GB per hour of recording)
  • Change Bitrate for MP3 to 224

Video Settings (only shows up if you installed MythVideo)

General

  • Put in the directory location where all of your videos are/will be stored
  • Directory to hold the movie posters (directory needs to be created!) – /home/<user>/.mythtv/MythVideo (replace <user> with your username that you will use to run MythTV)
  • Default View – Gallery (nice if you have the movie covers, otherwise I would use List)
  • Video Gallery – Columns – 3 (a bit scrunched with 4)

Player Settings

If you want to ensure that Mplayer passes through AC3 and also ensure that MPlayer plays through SPDIF, you need to make changes to your /etc/mplayer/mplayer.conf file

Search for “ao” in the file and change the line to show as:

ao=alsa:device=spdif

Search for “ac” in the file and change the line to show as:

ac=hwac3,

Ensure you put the comma after the 3 above so that MPlayer will use other default codecs if the sound is not AC3.

If you have an IR Remote and will be using it – and want to ensure that MPlayer will respond to the commands, you need to add the following entry to the end of the “Default Video Player” and “VCD Player” commands:

-lircconf /path/to/lircrc/file

There you go!  That is all the settings (that I use, at least) for MythTV.  Now, lets setup MythTV to get Program Guide information.


How To Get Program Guide Information Into MythTV on Ubuntu Linux 8.10 Intrepid

First of all, go to this website and download the mc2xml file.  I would recommend placing it in your home folder and then make a new folder called “mc2xml” and place this file in there (and, if you choose, your channel file as well).

mc2xml Download

Now that you have this, you can either decide to import all channels that mc2xml finds for your area, or you can be picky and choose.  I choose to be picky because I don’t want all those shopping channels showing up – or channels we never watch.  To do this, create a file named mc2xml.chl in the SAME folder as the mc2xml file you just downloaded.  On each line put the channel that you want to have.

Now, run the following command in a terminal:

/path/to/mc2xml -c us -g <ZIPCODE>

Ensure you change <ZIPCODE> with your zipcode (do not enclose in those brackets though.  The mc2xml program does its thing and will then prompt you to select what TV lineup you want.  Select that and it will start downloading the program listings.

Now, you need to fill your database with the new listings.  This will also fill it with the channels for MythTV.  Issue this command:

mythfilldatabase –refresh-all –file 1 ./xmltv.xml

NOTE:  You need to ensure you are in the same directory as the xmltv.xml file, so make sure that you do an “ls” at the terminal to ensure it shows up there.  The process of filling the database may take a little bit of time.

Now, the question comes up – How can I have this run and automatically update the program guide before the program guide runs out (usually around 14 days)?  Good question!  Below is a script that will do just that – save it, again, in the mc2xml folder in your home directory:

#!/bin/sh
cd ~/mc2xml
if ~/mc2xml/mc2xml ; then
     mythfilldatabase –refresh-all –file 1 ./xmltv.xml
fi

 Save the file as whatever you would like, but I saved mine as “mythtv-schedule.sh”

Now, you need to create a cron job to run.  Mine is set to run at midnight every night (it is a bit overkill, but if there are any changes in the schedule it will update them daily).  Navigate to the /etc/cron.d folder and create a new file called “mythtv-schedule” and enter this:

0 * * * * user ~/mc2xml/mythtv-schedule.sh

Ensure you change “user” to your username that you use on your PC.

There you have it!  Now you will have your program guide automatically populated with data in MythTV so you can schedule recordings and use the OSD while watching TV to browse the channels and see what is showing – just like a digital cable box!


Setup the Hauppauge Infrared Remote with MPlayer and MythTV on Ubuntu Linux 8.10 Intrepid

This is specifically for the Gray Hauppauge remote I received with the PVR-150.  It is the same remote as the WinTV-Go-Plus cards as well (that was the first card I bought).

Ensure that you installed lirc and libcurses-dev.  If not, run this at a terminal:

sudo apt-get install lirc ncurses-dev

When it prompts you for your remote, choose Hauppauage TV Card.

After this, you need to ensure the LIRC program will start up, so type this in a terminal:

echo “lirc_i2c” | sudo tee –a /etc/modules

Now open the /etc/modprobe.d/aliases file and scroll down to the proper area and add the following line and save:

alias char-major-61 lirc_i2c

Now, you need to have a file that tells MythTV and other programs what each button the remote does.  You can download the file I use (works well but takes getting used to) HERE.

You need to copy this file to /home/<user>/.mythtv/lircrc where you substitue <user> with your username.  It must be placed here in order for MythTV to find the file to use.

Additionally, if you use MythVideo, you need to ensure that MPlayer (the player used for videos) can find the file.

  1. Open MythTV Frontend
  2. Go to Utilities/Setup
  3. Go to Media Settings
  4. Go to Video Settings
  5. Go to Player Settings
  6. In the commands for VCD and Video, add on to the very end (if you didn’t do it in the above steps for general MythTV setup):
-lircconf /home/<user>/.mythtv/lircrc

Again, substitue your userid with <user>

Your remote should now be complete!

If you want to set your remote to open MythTV if it is not currently open with your remote, follow these few small steps.

Create a file called .lircrc in your home folder:

touch ~/.lircrc

In that file, copy/paste the following.  This will make it so that when you hit the Power button, it will open MythTV:

# power button
begin
prog = irexec
button = POWER
#repeat = 4
config = mythfrontend –service

 Now, ensure that the irexec program automatically starts upon booting Ubuntu.  To do this, go to Menu – System- Preferences – Startup Applications.

In here, click Add.  For a name, just put in irexec and put in irexec for the command as well.

In addition, if you wish to use other buttons on the remote to launch other applications while MythTV is not open, just add those extra items to the ~/.lircrc file as well.


Setup MythTV with MythStream with the ShoutCast Parser in Ubuntu Linux 8.10 Intrepid

Like I previously indicated, I use MythStream solely for the ShoutCast recordings.  Ensure you have MythStream installed:

sudo apt-get install mythstream

 Now you need to go to the creator’s website and download the Shoutcast parser.  Untar the files to /home/<user>/.mythtv/mythstream/parsers

Open up MythTV, go to Media Library – Play Online Streams and you will have a “Browse Shoutcast genres” available.  All of the radio stations are available right there!

NOTE:  If you cannot hear any of the playback through SPDIF, it is because you need to update your /etc/mplayer/mplayer.conf file. 

Search for “ao” in the file and change the line to show as:

ao=alsa:device=spdif

How To allow for DVD Playback in MythTV on Ubuntu Linux 8.10 Intrepid

For the DVD playback to work, you need to download some CSS stuff.  I tried to play a DVD without this package, and the drive just flashed for over ten minutes and did nothing.

At a terminal, type:

sudo wget http://www.medibuntu.org/sources.list.d/intrepid.list –output-document=/etc/apt/sources.list.d/medibuntu.list
sudo apt-get update && sudo apt-get install medibuntu-keyring && sudo apt-get update
sudo apt-get install libdvdcss2

How To Bulk import IMDB Data for Videos for MythStream in Ubuntu Linux 8.10 Intrepid

 If you have a lot of videos and do not want to manually go through the list and pull IMDB data for each, here is how you can do it all at once!

Download these two files and untar them to a temp directory on your desktop (or whever):

imdbupdater
metacleanup

Now, after untarring the files, open up the metacleanup.sh file.  Most of these settings should already be fine, but you will need to put in your MythTV database password (this can be found in /etc/mythtv/mysql.txt) and the location to where your videos and posters are located.  I would recommend creating the posters folder at /home/<user>/.mythtv/mythvideo/posters and replace <user> with your userid.

Now, to update ALL IMDB information for the videos you have, enter this in a terminal (need to be in the same directory as the imdb-bulk-update script):

./imdb-bulk-update.pl -A -Host localhost -User mythtv -Password <PASSWORD_HERE> -Fileup -Folder <PATH_TO_MOVIES>

Ensure you update <PASSWORD_HERE> with your mythtv database password (again, found in /etc/mythtv/mysql.txt), and update the <PATH_TO_MOVIES> with the location where your movies are stored so the script can find all of them.

During the process, if there are a few results for a movie returned, you will be asked to select which movie on which year.


How To Start MythTV upon login on Ubuntu Linux 8.10 Intrepid

Since I didn’t install Mythbuntu, I wanted to find a way to get MythTV to run when the user logged in (I have the user set to auto-login as well – so I turned the PC on, wait for it to boot, and then MythTV comes up with no interaction – that way I can just sit on the couch and use the remote from the start).

  • Go to System – Preferences – Session
  • Click Add
  • Name:  mythfrontend (can be whatever you wish actually)
  • Command:
mythfrontend –service

 Hit OK and MythTV will now launch when you boot up!


How to share MythVideo movies on the backend server with other MythTV Clients

For simplicity sake, go to the Mediashares site and read instructions how to setup NFS so your MythVideo movies can be shared amongst other frontend MythTV computers.


How to setup Boxee integration and remote control access with MythTV

Recently I installed Boxee and I like the way it integrates several online webcasting and webvideo functions.  This is a perfect solution for allowing quick and easy access to a plethora of videos online that are available – with the ease of use of integration into MythTV with remote control access.

First of all, you will need to install Boxee.  To do this, you need to go to your Software Sources, click the Third Party tab, and enter a new line:

deb http://apt.boxee.tv jaunty main

Then, reload your sources and install Boxee:

sudo apt-get install boxee

After Boxee is installed, you will need to add a line entry to your MythTV Menu.  I put mine under the Recordings menu.  Open up the /usr/share/mythtv/library.xml file and add this to it.  Where you put it depends on where you want it since the order they appear in this XML file will be how they appear on the menu in MythTV:

    <button>
     <type>TV_WATCH_RECORDINGS</type>
     <text>Launch Boxee</text>
     <action>EXEC /opt/boxee/run-boxee-desktop</action>
   </button>

Now save and close the file.  You have just integrated Boxee into MythTV.

 Next is setting up the remote.  In this case, it is very important that you setup your remote correctly.

First of all, it is best if you run irw to find what the remote name is.  Simply issue:

irw

at a command prompt and press a few keys on your remote.  You should see some garbage information, the button that was pressed (like Power, VolUp, Left, Right, etc), and then the remote name.  In my case, it says “Hauppauge_350”.  This information must be EXACT in the two files you create for the Boxee remote control.  You can then hit Ctrl+C to get out of the irw prompt.

This is the code I have for my remote.  This file needs to be saved in two places.  If you only save it in your home directory, it still won’t work (at least it didn’t for me).  Save this file as lircmap.xml:

<lircmap>
        <remote device=”Hauppauge_350″>
                <pause>Pause</pause>
                <stop>Stop</stop>
                <forward>Forward</forward>
                <reverse>Rewind</reverse>
                <left>Vol-</left>
                <right>Vol+</right>
                <up>Ch+</up>
                <down>Ch-</down>
                <select>Ok</select>
                <pageplus>Red</pageplus>
                <pageminus>Yellow</pageminus>
                <back>Back/Exit</back>
                <menu>Menu</menu>
                <title>Play</title>
                <info>More</info>
                <skipplus>Skip</skipplus>
                <skipminus>Replay</skipminus>
                <display>Blank</display>
                <start>Home</start>
                <record>Record</record>
                <volumeplus>Green</volumeplus>
                <volumeminus>Blue</volumeminus>
                <mute>Mute</mute>
                <power>Power</power>
                <myvideo>Videos</myvideo>
                <mymusic>Music</mymusic>
                <mypictures>Pictures</mypictures>
                <mytv>TV</mytv>
                <one>1</one>
                <two>2</two>
                <three>3</three>
                <four>4</four>
                <five>5</five>
                <six>6</six>
                <seven>7</seven>
                <eight>8</eight>
                <nine>9</nine>
                <zero>0</zero>
                <mytv>Red_</mytv>
                <mymusic>Green_</mymusic>
                <mypictures>Yellow_</mypictures>
                <myvideo>Blue_</myvideo>
        </remote>
</lircmap>

 

Note above the device=”Hauppauge_350″ line.  You need to change what is in quotes to what you saw when you used the irw command for your device name.

The file needs saved in these two locations:

~/.boxee/UserData/lircmap.xml
/opt/boxee/UserData/lircmap.xml

Bash Scripting for Web Hosting Setups

This week I worked on creating a script that will be of great use for me.

When I have to setup a new customer or delete an old customer, there were many steps, and one of which I might forget or even setup wrong in the first place.  When a new customer signs up, the following things have to take place:

  • Setup the domain in my mail server to allow the servers to accept relaying for the new domain
  • Setup a web directory
  • Setup an e-mail account
  • Setup a mailbox directory 
  • If the user needs a database for their website, this needs to be created
  • If the user needs a database for their website, a SQL user needs to be created with privileges to their database
  • A primary zone needs to be added to the DNS servers for their domain
  • Configuration on both servers for a new VirtualHost

Much of the information that is needed is redundant as well – such as the domain name in question.  So, I finally finished up a 641-line bash shell script that will do all of these things!

While it would be nice to post the code here, I cannot do so because I have some proprietary code in it for my specific setup – such as the IP addresses for the servers.

Originally the goal was to use it as just a new user setup, but after tinking with the scripting a bit more, I was able to figure out how to find a specific line in a file using grep and cut, and then finding an ending line in a file using grep and cut as well, then using sed to delete between the two lines.

After this, I was thinking, "boy it would be nice if I could also use the same script to update both servers simultaneously".  Well sure enough, more research led me to how to send commands through an ssh tunnel to the other server!  So, this one script will do everything needed now in a matter of minutes.  It would take quite a while to set everything up for a new user, or to delete an old user.

I never was much of a person to get into programming – just because there wasn't too much I could think of to program.  Well after this, I now have thought of trying to make a PHP page that will allow customers to recover their e-mail password, or even a page that will allow them to create more e-mail accounts for their domain.  I allow up to five free e-mail addresses per domain, then there is an additional $1 fee for any additional.

Zoom Media Gallery 2.5.1 RC4 Freezes or Crashes Apache2

After getting a little bit of time to research the new problem causing Apache2 to crash or freeze up and use 100% CPU utilization, I believe I have found at least part of the problem.

The Zoom Media Gallery 2.5.1 RC4 does not check to ensure that the Page Number is legit.  I kept checking the server-status on Apache and each of the times, I kept noticing that the website address including an address with a negative page number.  How could it be possible for a page number to be negative?  I don’t know, but ask Google!  Google keeps spidering the web sites here and many times has a negative page  number – which doesn’t make any sense.

To head off this issue, I inserted a few lines of code into the zoom.php file in the /components/com_zoom directory.  I created these lines directly under the:

//error reporting(E_ALL)

comment around line 34 – just before the:

// Create zOOm Image Gallery object

Here is the code to insert:

// Check to ensure the Page number is valid (not negative) or throw an error
$PageCheck = mosGetParam($_REQUEST,’PageNo’);
if ($PageCheck < 1 && isset($PageCheck)) {
     echo (‘Page number cannot be zero or negative.’);
     exit;
}

I am not 100% sure yet if this will fix all the problems with Zoom Media Gallery 2.5.1 RC4 and the 100% CPU utilization with Apache, but I know this will help curtail the problem.  When I tried to put the same URL that caused an Apache process to use 100% of the CPU into my web browser, it sat there until the five minute timeout period for scripts (I set a five minute, or 300 second timeout period in the php.ini file under max_execution_time).

I have completed all changes needed for this issue in my Downloads section.  You can simply download the full component there and install it as required.