makewhatis

Random Linux Garble.

Install Unrar Fedora 15 Beta

Unrar has yet to come to the repo, but its super easy to install.

  1. Download the binary from their site. http://www.rarlab.com/rar/unrar-linux-x64.gz

  2. gunzip the file

  3. Copy it to /usr/bin as root

  4. Give it the correct permissions 0755

Heres a simple script that will do all that for you.

#!/bin/bash  
# Install unrar binary to /usr/bin  
#  
# \***| Must be run with root privileges \***|  
cd /tmp  
wget http://www.rarlab.com/rar/unrar-linux-x64.gz  
gunzip -N unrar-linux-x64.gz  
cp /tmp/unrar /usr/bin  
chmod 0755 /usr/bin/unrar  
echo "Unrar installed."

NFS 4 Mounts on Red Hat Enterprise Linux 6 With Iptables Enabled.

So when running nfs under RHEL 6 with iptbables, there is some extra things to do in order to make it work. If you run system-config-firewall, you will notice it opens up 2049, the port for NFS 4. Thats great and all, but that alone will not allow your nfs mounts to be seen.

This actually tripped me up. I figured that 2049 would be the only thing that would have to be opened, and that if anything else was required to be opened, surely the firewall tool would let me know.

If you read on the rhel 6 guide, it outlines what needs to be done. http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/s2-nfs-nfs-firewall-config.html

I checked out what ports my services were currently listenting on:

rpcinfo -p | awk '{print $3 " " $4 " " $5}' | sort -k 2 | uniq -f 1

So I opened up the firewall for these ports, and that worked great. But then I thought about it, and realized that these ports might change on reboot and make my changes obsolete. Sure enough after a reboot I get the same error on the client

rpc mount export: RPC: Unable to receive; errno = No route to host

So to make the change permanent I had to do a little more work. Next I had to go into the /etc/sysconfig/nfs and uncomment the following lines:

LOCKD_TCPPORT=32803  
LOCKD_UDPPORT=32769  
MOUNTD_PORT=892  
STATD_PORT=662

Then I added these rules to my iptables to open up ports for this service.

-A INPUT -p udp -m state --state NEW -m udp --dport 111 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 111 -j ACCEPT  
-A INPUT -p udp -m state --state NEW -m udp --dport 662 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 662 -j ACCEPT  
-A INPUT -p udp -m state --state NEW -m udp --dport 875 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 875 -j ACCEPT  
-A INPUT -p udp -m state --state NEW -m udp --dport 892 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 892 -j ACCEPT  
-A INPUT -p udp -m state --state NEW -m udp --dport 2049 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 2049 -j ACCEPT  
-A INPUT -p udp -m state --state NEW -m udp --dport 32769 -j ACCEPT  
-A INPUT -p tcp -m state --state NEW -m tcp --dport 32803 -j ACCEPT

Then I restarted the nfs and iptables services and all works great.

Awesome Command Line S3 Backup Tool

So I was recently trying to solve my backup/sync problem that I was running into with a lot of these backup services. The main two that I was using were Jungledisk and Dropbox. Dropbox is great for documents, scripts, pdfs, etc that I wanted to have synced accross my machines. Jungledisk was not such a great sync tool, and configuring it was kind of a pain.

I want a simple backup of my home directory really, that I can sync with my work computer, laptop, and home pc. I found this little gem, , that provides a simple wrapper for rsync, with most of the important options. I was able to write a simple script that syncs my home directory, excluding a few folders, to Amazon S3 and back.

Here is the simple script that I used to back up my home directory, excluding Music and Video folders, which can be pretty huge. Keep in mind I have already installed the s3adm program on my machine which is currently running Fedora 15 alpha.

#!/bin/bash  
# Script to backup to amazon s3 with s3cmd  

directories=`find ~/ -maxdepth 1 -type d ( ! -iname ".*" ! -iname "Video"   
         ! -iname "Music" ) | awk -F / '{print $4}'`  

for directory in $directories   
do  
    echo "Syncing the "$directory" folder to S3"   
    s3cmd sync -v ~/$directory/ s3://homepc_backups/$directory/  
done

Again, the tool can be found HERE

Register Red Hat Enterprise Linux 6.1 Beta

I was given a number of subscriptions from Redhat for the 6.1 Beta release. Tonight was the first time I tried to use one, to setup a learning environment for my brother here. I did not install this with a desktop, so I did not have the option of choosing to register from System->Administration->RHN Registration.

So naturally I tried to type: rhn_register . This took me to the register utility tui, but did not let me register the system. I kept getting errors about the not having any valid entitlements. So then I actually read through the entire email and saw that they had included this with the Beta info, that rhn_register will not work. The new command for this in 6.1 is as follows:

 subscription-manager register --username myusername --password '\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\*'

 subscription-manager subscribe --username myusername --password '\*\*\*|\\*\*\*|\\*\*\*|\\*\*\*|\*'

Personally, I liked rhn_register, but whatever. Its all the same I supposed.

Single User Mode Red Hat Enterprise Linux 6.0 and Passwd Problems

I was trying to show my little brother how to root a RHEL6 box in single user mode today, and ran into a little issue. I booted the machine into init 1, but was not able to change the password. I could add a user, but could not assign a password. You could type: *passwd root * and the cmd prompt would just appear on the next line, as if the command was just blank.

Then I remembered SELINUX, my old buddy. Disabled selinux: setenforce 0 and bam! Password updated and life goes on.

Configure a Caching-only Name Server to Forward DNS Queries

To pass the RHCE one of the things that Red Hat wants you to setup is a caching-only name server. This is actually pretty easy with RHEL 6.

Install the bind package

sudo yum install bind

Then start the package and set it up to start on boot.

sudo /sbin/service named start && sudo /sbin/chkconfig named on

You have successfully setup the caching-only name server, for real. Now to get it to forward queries to a specific name server.

For me I just forwarded the queries to my local nameserver, the router on 192.168.1.1. To do this you edit named.conf

sudo vim /etc/named.conf

In the options section I added:

listen-on port 53  { 127.0.0.1; 192.168.1.101;};

;which is the ip for the bind dns server)

allow-query  { localhost; 192.168.1.0/24;};

; adding the ip block for localhost)

forward only;  
forwarders {192.168.1.1;};

This tells our bind server that I want to forward all dns queries to my router. I could also, for example, forward all queries to my ISP’s nameservers. In this case the ip would be 68.2.16.30 (ns1.ph.cox.net).

forwarders {68.2.16.30;};

Thats all there is to that requirement for the Red Hat Certified Engineer exam.

Red Hat 6 # /usr/bin/which: No Semanage in …

So I was buckling down for the RHCE today and getting into knee deep into SELinux, when I ran across a little hurdle. I was trying to use “semanage” and was not able to find the binary. Everything pointed back to the pollicycoreutils package, which was already installed.

Turns out you actually have to install policycoreutils-python in order to get the semanage binary. I would think it would be a little less cryptic than that, but whatever.

Installing PHP 5.3.x on Centos 5.5

Centos is a great Distro for hosting. Its tried and tested, as oppossed to Fedora and Ubuntu, which, while on the cutting edge, can still have a few quirks. My biggest problem with Centos is that lack for cutting edge, like the default PHP that installs with Centos, 5.1. It can be a pain to find 3rd party repos.

Well hopefully thats where you are. Looking for 5.3 on Centos. One of the most solid repos out there is . I’ll run through how to get that version of php you want on your server.

This assumes you have no php installed at this point. If you do, back up and remove it. Once you are ready:

Have to add the Epel repo first, so run these two commands as root

wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/epel-release-1-1.ius.el5.noarch.rpm  
rpm -Uvh epel-release-1-1.ius.el5.noarch.rpm

Now lets add the IUS Community Repo

wget http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/x86_64/ius-release-1.0-6.ius.el5.noarch.rpm  
rpm -Uvh ius-release-1.0-6.ius.el5.noarch.rpm

This will add the repos to your /etc/yum.repos.d/ directory. Now to go into the .repo file and make a few changes.

The repo configuration file by default is configured to hit the mirrorlist. Lets set the base url and make sure the repo is enabled.

First comment out the “mirrorlist=http” line in the main ius repo, and then make sure “enable=1″. The first section of your ius.repo should look like this:

[ius]  
name=IUS Community Packages for Enterprise Linux 5 - $basearch  
baseurl=http://dl.iuscommunity.org/pub/ius/stable/Redhat/5.5/$basearch  
#mirrorlist=http://dmirr.iuscommunity.org/mirrorlist?repo=ius-el5&arch=$basearch  
failovermethod=priority  
enabled=1  
gpgcheck=1  
gpgkey=file:///etc/pki/rpm-gpg/IUS-COMMUNITY-GPG-KEY

Awesome. Now the was IUS does things, is they name php based on version, so php 5.3 is php53u and if you wanted 5.2 it would just be php52. An easy way to check, would be do a yum list:

yum list php53u

Or to see all php53u packages:

yum list php53u*

Now just yum install the packages you need and you’ll be running on a fresh version of php 5.3.

Using Postmark API With Kohana 3

Postmark gives API access to their service, which rocks. People have been kind enought to develop libraries to access the API as well. There is a lot of info out there on different implementations of the API, but none that I could find specifically for Kohana 3. So I threw together a little post for it.

I had to work with Postmark and Kohana 3 this past week. There is no library for Kohana 3 alone, but there is a nifty one for php. Ill run through an example of how to implement that library into a Kohana 3 application.

So first we have to import the library into our application. First create a directory in called “vendors”, so “application/vendors”. Create another directory inside vendors for postmarkapp.

Download postmark php library from Github and place those files in the application/vendors/postmarkapp directory.

Also, if you haven’t signed up with postmark, you will want to do that.

Now that thats in place, next step is to actually tell Kohana that we are using that library, and where to find it.

In the application/bootstrap.php add this line above the section that starts with “//– Configuration and initialization”

//import postmarkapp api  
$path = Kohana::find_file('vendors', 'postmarkapp/Postmark');  
if($path) {  
    [ini_set][1]('include_path',  
    [ini_get][2]('include_path') . PATH_SEPARATOR . [dirname][3]([dirname][3]($path)));  
    require_once 'postmarkapp/Postmark.php';  
}

Awesome, now its ready to start using it. In whatever controller you want to use it in (I’m going to do it in my controller/main.php file) create a function to send mail.

I am setting up some constants for postmark like From Name and From Email, as well as including the API key I got from Postmark.

Now you have the function setup that does the heavy lifting for you. Typically you would call this function to send a confirmation or a submitted form. Below is a very simplified example. If nothing is posted yet, it loads the form which is in views/contact/form. If the form has posted, then it processes the data. Keep in mind I have done very little error handling and data filtering. Lots of good info on the unofficial wiki about that.

How to Scrobble to Last.fm From Pandora

So I have been loving my Pandora membership lately, now that I’m in a position at work where I can just listen. One thing that always bugged me was the rivalry between Pandora and Last.fm, because I love to listen to music on Pandora while keeping track of music on Last.fm.

There is the plugin for Firefox, LastFMFirefox Extension which is cool, but doesn’t seem to work on Linux. I used to use this back when I still used windows and it worked great. Now I primarily use Ubuntu, and well that doesnt seem to work.

Also, not really a fan of firefox anymore, I use Chrome as it seems to handle my obnoxious habits (keeping 25 tabs open) much better. So besides Pandora allowing Last.fm scrobbling, there wasn’t much else I could find.

Then I ran across which accomplishes just this. It loads Pandora into a frame in the browser, and sends the listened tracks to last.fm as they are played. Pretty nice.

Hopefully one day Pandora One subscribers will be able to just do this in the settings area, but for now this will do.