Life of a Geek Admin

The Daily adventures of a true geek administrator

Life of a Geek Admin - The Daily adventures of a true geek administrator

Enabling APC UPS on Ubuntu 9.10

After several years of using an APC UPS I had to replace the system. Previously I never used the plug to the USB from the UPS to my Linux Server. Being the tinkerer that I am I decided it was time to get it to work on the server. Fortunately this was not a hard task.

Install APCUPSD by typing
$ sudo apt-get install apcupsd apcupsd-cgi

Once installation is completed you must configure it and start it up.

The apcupsd software has no menu entry. Using the Gnome desktop, open your terminal. Applications>Accessories>Terminal.
Now type:
$sudo gedit /etc/apcupsd/apcupsd.conf

A text editor opens up. Please note that the examples shown below are from my computer and you need to adapt them to your computer. Scroll down very slightly until you reach this section:

# UPSCABLE
# Defines the type of cable connecting the UPS to your computer.
#
# Possible generic choices for are:
# simple, smart, ether, usb
#
# Or a specific cable model number may be used:
# 940-0119A, 940-0127A, 940-0128A, 940-0020B,
# 940-0020C, 940-0023A, 940-0024B, 940-0024C,
# 940-1524C, 940-0024G, 940-0095A, 940-0095B,
# 940-0095C, M-04-02-2000
#
UPSCABLE usb
Change the UPSCABLE to the one that matches your particular battery backup, in this and most cases change it to usb.

Scroll down to the next section:
# To get apcupsd to work, in addition to defining the cable
# above, you must also define a UPSTYPE, which corresponds to
# the type of UPS you have (see the Description for more details).
# You must also specify a DEVICE, sometimes referred to as a port.
# For USB UPS’s, please leave the DEVICE directive blank. For
# other UPS types, you must specify an appropriate port or address.
#
# UPSTYPE DEVICE Description
# apcsmart /dev/tty** Newer serial character device,
# appropriate for SmartUPS models using
# a serial cable (not USB).
#
# usb Most new UPS’s are USB.
# A blank DEVICE setting enables
# autodetection, which is th best choice
# for most installations.
#
# net hostname:port Network link to a master apcupsd
# through apcupsd’s Network Information
# Server. This is used if you don’t have
# a UPS directly connected to your computer.
#
# snmp hostname:port:vendor:community
# SNMP Network link to an SNMP-enabled
# UPS device. Vendor is the MIB used by
# the UPS device: can be “APC”, “APC_NOTRAP”
# or “RFC” where APC is the powernet MIB,
# “APC_NOTRAP” is powernet with SNMP trap
# catching disabled, and RFC is the IETF’s
# rfc1628 UPS-MIB. Port is usually 161.
# Community is “private”.
#
# dumb /dev/tty** Old serial character device for use
# with simple-signaling UPSes.
#
UPSTYPE usb
DEVICE

Again select the right options for your ups unit
Also, note that “# usb” is not literal, so don’t type just leave a blank space.

Now click the save button in the text editor and then close it.

Now keeping your terminal open type:
$sudo gedit /etc/default/apcupsd

# Apcupsd-devel internal configuration

APCACCESS=/sbin/apcaccess
ISCONFIGURED=yes

See the “ISCONFIGURED=no”. Change the no to yes just like in my example.

Now click the save button in the text editor and then close the editor.

Keeping your terminal open type:
$sudo /etc/init.d/apcupsd restart

Look for any errors, if you don’t see anything great.

Keeping your terminal open type:
root@tardis:/etc/init.d# tail -f /var/log/apcupsd.events
Sat Jun 12 11:32:31 EDT 2010 apcupsd 3.14.6 (16 May 2009) debian startup succeeded

By editing the two configuration files you can change various parameters. Don’t be shy to open them up and explore!

Disable IPV6 on Ubuntu 10.04

Ran into an issue on Ubuntu the other day in which network functions were having issues. Through a little PD found that IPV6 was the culprit. Here is a tip on how to disable IPV6 on Ubuntu 10.04.

To check if IPv6 is disabled, run the following command:

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

0 means it’s enabled and 1 – disabled.

To disable IPv6, you have to add the following lines to /etc/sysctl.conf:

#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

To do it from the command line, paste this in a terminal:

echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf

echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf

Then reboot and check if IPv6 has been disabled with the command in the beginning of this post.

A Few Essential Repositories for Ubuntu

There are a few essential repositories that I use to add missing applications, codecs and other applications that are not available in Ubuntu. There are many more out there but these three are top added to my systems.

Medibuntu (http://www.medibuntu.org/)
Medibuntu (Multimedia, Entertainment & Distractions In Ubuntu) is a repository of packages that cannot be included into the Ubuntu distribution for legal reasons (copyright, license, patent, etc).

The following bash command adds Medibuntu’s repository to Ubuntu. It also adds Medibuntu’s GPG key to your keyring, which is needed to authenticate the Medibuntu packages.

* This command should be run in the Terminal (Applications → Accessories → Terminal):

$ sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

You may also wish to add the following packages. The first will cause many apps from the Medibuntu repository to appear in Ubuntu Software Center (Ubuntu 9.10+) or Add/Remove Applications (versions prior to 9.10). The second will allow users to generate crash reports against Medibuntu packages and submit them to the Medibuntu bugtracker.

$ sudo apt-get --yes install app-install-data-medibuntu apport-hooks-medibuntu

Please note you may have to use –force-yes instead of –yes in order for this command to succeed.

GetDeb.net (http://www.getdeb.net/welcome)
GetDeb is an unofficial project with the mission to provide the latest open source and freeware applications for the current Ubuntu Linux release, in an easy to install manner.

The GetDeb repository extends the official repositories by providing latest versions and new applications. Unlike the official packages, GetDeb packages do not have a predefined release schedule – new software versions are provided as they become available from their authors. There is a short and limited testing phase instead of a full testing cycle to ensure packaging quality, however it is less strict than Ubuntu’s official requirements.

Installing GetDeb

1. Install the getdeb (http://archive.getdeb.net/install_deb/getdeb-repository_0.1.1~getdeb1_all.deb) package. This is the easiest and preferred method
2. Or configure the repository manually:
Go to System-Administration-Software Sources, Third-Party Software tab, Add:
deb http://archive.getdeb.net/ubuntu karmic-getdeb apps

Add the repository GPG key, open a terminal window and type:
$ wget -q -O- http://archive.getdeb.net/getdeb-archive.key | sudo apt-key add -
3. Click the “Install this now” button below the screenshot of the desired application on the GetDeb site.

Philip Johnsson Extra Repos. UbuntuStudio related latest packages.
Add the PPA to the Software sources, open a terminal window and type:
$ sudo add-apt-repository ppa:philip5/extra

Update Repository
$ sudo apt-get update

I hope this adds many new options to your Linux experience!!!

Downloading YouTube Videos and Extracting Audio on Ubuntu

Have you ever had a YouTube video that you just wanted to have on your PC in-case you were not online to watch it or you wanted the audio extracted from one of those videos to listen to on your PC or iPod? With Firefox addons  that is a reality. I had a friend who had found a very, very old German song and found it on YouTube put to a slideshow and was asked how to download the video and extract the audio. This can be done in two steps very easy.

First download the Firefox addon called Fast Video Download. It is available here https://addons.mozilla.org/en-US/firefox/addon/3590. Install the addon and restart Firefox. Once restarted you will see a little icon in the top right portion of the toolbar or the bottom right corner.

Next make sure you have the correct programs for the audio extraction. This is primarily done with ffmpeg and a few supporting actors.
$ sudo apt-get install ffmpeg gstreamer0.10-ffmpeg gstreamer0.10-ugly-multiverse
mpg123 mpg123-alsa

At the command line type
$ ffmpeg -i input.flv -acodec copy output.mp3

And in seconds you have music to listen to!!!

If you want more information on the use of ffmpeg go to http://www.ffmpeg.org.

Epson 4490 Photo scanner Ubuntu

The Epson Perfection 4490 Photo scanner is not supported in Ubuntu by sane. To get the scanner to work in Ubuntu you must download and install third party software. This how to describes how I was able to install it on Ubuntu Karmic 9.10 64-bit.

  1. Install libsane-extras (sudo apt-get install libsane-extras)
  2. Edit /etc/sane.d/dll.conf and uncomment epson2 if it is not done already.
  3. Go to http://www.sane-project.org/lists/sa…-external.html
  4. Scroll down and find “Perfection 4490 PHOTO” and click on the link and you’ll be redirected to Avasys http://www.avasys.jp/lx-bin2/linux_e/scan/DL1.do
  5. Fill in the form and download iscan_2.24.0-4.ltdl7_amd64.deb iscan-plugin-gt-x750_2.1.0-5_amd64.deb for 64 bit Ubuntu
  6. Install the two files from a terminal or by double clicking. (sudo dpkg -i iscan*)
  7. Power cycle or unplug-plug back in the scanner.
  8. From the terminal test that sane finds the system (sane-find-scanner and also run scanimage -L)
  9. Open X-sane and start scanning.

Adding DVD Support Ubuntu Karmic 9.10

Due to licensing on encrypted DVD you are unable to watch your movies on Ubuntu. To remedy this you can add the support needed to Ubuntu 9.10.

$ sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

Now install the DVD support and a few codecs

$ sudo apt-get install libdvdcss2 libxine1-ffmpeg gxine mencoder non-free-codecs ubuntu-restricted-extras

And finally a player to watch them. I prefer VLC and mplayer since both are very versatile players.

$ sudo apt-get install vlc mplayer mozilla-plugin-vlc

Creating YouTube type video using Kino and JW Player on Ubuntu

This post will cover creating a video and posting the video in Flash format to a website in the YouTube format. The tools / programs used are Kino, WinFF and JW Player. For the hardware a firewire connection to a MiniDV video Camera is used for the video source, you could omit the camera and Kino step if you have a video already and just need to convert and post.

Download and Install needed Packages

First need to make sure the needed code is installed on your Ubuntu system.

WinFF

Install WinFF from Synaptic Package Manager or from the terminal type sudo apt-get install winff.

Kino

Kino is at version 1.3.2 in the Ubuntu Repositories. First install it from there either using the command line or Synaptic, whichever method you prefer. This version will suffice for what we need to accomplish, but the latest version can be found on GetDeb (http://www.getdeb.net/) or at http://www.kinodv.org . At the time of this writing the version is at 1.3.4.

Install from Command Line

sudo apt-get install kino

FFMPEG

Use the ubuntu repositories to install FFMPEG so you will have added export features in Kino. Run the command sudo apt-get install ffmpeg.

JW Player

JW Player is a flash plugin to deliver flash video content. It is free for personal use but requires a fee for business use. It can be downloaded from http://www.longtailvideo.com/players/jw-flv-player/.

Flowplayer

Flowplayer is another plugin to deliver flash videos to the internet. As the JW Player it is also free. Download the code from http://www.flowplayer.org.

The Process

Now that we have downloaded and installed the code we are ready to start the process of capturing the video, converting it and posting it to the web. In this example we will be using a firewire connection to a MiniDV Camcorder and importing in the file using Kino.

Plug-in your camcorder into the firewire port on your computer and turn it on. Open Kino and click on Edit > Preferences and click on the IEEE 1394 tab. If the module loaded properly you should see your device listed in the drop down.

If not and you see an error you will need to make a few changes to the settings. Close the Kino Preferences dialogue, open a command prompt and type sudo modprobe raw1394, then type sudo chmod a+rw /dev/raw1394. Reopen Kino Preferences again and now your device should show.

A feature turned on by default in Kino is to Auto Split the captures. If you want the capture to be one file then you will need to turn off this feature. If not then exit Kino Preferences, if so then click on the click on the Capture tab and uncheck Auto Split Files and click OK.

Now click on the Capture tab and lets start the capture. With the use of fireware you can control the actions of the camera from within Kino. So to start the Capture click Capture.The files will be saved to /home/<id>/capturXXX.dv. When you are done capturing click on Stop.

Click on the Edit tab and you’ll see the clip has been added to the storyboard column and you can edit the file. Lets say that we are satisfied with the clip and we are ready to export it to Flash. The newer version of Kino will let us do just that.

With Kino as the export for flash do the following. Click on the Export tab and then click on Other tab in the Export Section. Input the filename, From the Tools dropdown select Flash Dual Pass (FFMPEG) and from the Profile Dropdown select either Broadband Quality FLV or Low Quality FLV and then select Export. If you are not using Kino for the import and have an existing file to convert then WinFF is used to convert to FLV

Converting Using WinFF

Open WinFF, Click on the Add button and add the file from Kino that was captured or another file to convert. In the Convert To drop down select Websites. In the drop down box next to it select Flash Video (flv) for Web (4:3) and click Convert. Note: you can also select Flash Video (flv) for Web (16:9)

Setting up JW Media Player

Step 1: Transfer the player.swf and swfobject.js file from the ZIP to your website. (Make sure that you’ve also uploaded all the necessary videos / songs / images to your site.)

Step 2: Embed the player in your HTML page with the lines of code below. Note: If you place the files in different directories, make sure to set the references in this code accordingly.

<p id='preview'>The player will show in this paragraph</p>

<script type='text/javascript' src='swfobject.js'></script>
<script type='text/javascript'>
var s1 = new SWFObject('player.swf','player','400','300','9');
s1.addParam('allowfullscreen','true');
s1.addParam('allowscriptaccess','always');
s1.addParam('flashvars','file=video.flv');
s1.write('preview');
</script>

Notice the flashvars parameter above can contain a list of variables for configuring the player to use different Plugins or Skins. To quickly set up flashvars, use the setup wizard. Simply choose an example, select the variables you want to use and paste the code onto your page. It’s that easy.

Switch to our mobile site