Archive for category Linux

Terminator color palettes

Bored of the normal everyday terminal colors? These can be easily changed by right clicking on the terminal window, clicking preferences and changing the colors:

You can see how my terminal colors are different than standard:

If you want to know where this information is stored on your filesystem:

#!/bin/bash
cat ~/.config/terminator/config

My current palette:

palette = "#2e3436:#cc0000:#4e9a06:#c4a000:#c48dff:#75507b:#06989a:#d3d7cf:#555753:#e52222:#a6e32d:#fc951e:#3465a4:#fa2573:#67d9f0:#f2f2f2"

The same can be done for gnome-terminal, but that stores it’s defaults in gconf. You can retrieve them using gconftool-2:

#!/bin/bash
gconftool-2 --all-entries /apps/gnome-terminal/profiles/Default

This is fun as these colors carry over into Vim etc, so when you are not using the graphical versions, you can still spice up your syntax highlighting.

Stylish desktop, new search engines

My Desktop
Read Seif’s post on his desktop, so I copied most of that style (original post) :

Desktop

I actually enabled compiz for the first time in a long time, and AMD’s linux drivers have come a long way since my critical posts a few years ago about them. Great to see the whole stack improving.

Default Search Engine
This week I switched over my default search engine to Duck Duck Go.


I really like it’s clean interface, and their attention to privacy and technology enthusiasm.

New Home Page
In addition, I updated my generic landing page using Python / Flask to pull feeds etc, I really like the simplicity of Flask and the well thought out design / documentation. I also published the source on github.

Using Apache to decrypt SSL pages

Although you should almost never have a decent rationale for doing this, at some point I needed to do it, and documentation was scarce. The basic idea is we have a website – https://www.securewebsite.com and our clients cannot use https (ssl), so we need to decrypt it to http for them.

In order to accomplish this, Apache 2.x is needed, along with mod_ssl and mod_proxy. Here is the magic:

<VirtualHost virtualhostipaddress:443>
        SSLProxyEngine on
        #SSLProxyCACertificateFile /etc/apache2/ssl/google.crt
        SSLEngine on
        RequestHeader set Front-End-Https "On"
        ServerName testing

        #SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
        SSLCertificateFile /etc/apache2/ssl.crt
        SSLCertificateKeyFile /etc/apache2/ssl.key
        #LogLevel debug

        ErrorLog /var/log/apache2/ssl_proxy_error.log
        CustomLog /var/log/apache2/ssl_proxy_access.log combined

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        ProxyVia On
        ProxyRequests Off
        ProxyPreserveHost Off
        ProxyPass / https://www.securewebsite.com:443/
        ProxyPassReverse / https://www.securewebsite.com:443/

        #SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [1-4]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [5-9]" ssl-unclean-shutdown
</VirtualHost>

Obviously replace virtualhostipaddress with the ip you want to bind to and securewebsite.com with the actual website.

Linux guru needed

I have another position open, it’s a contract position for 3 months atleast. Pays great, will need to come onsite to Cincinnati.

Skills we need:

  • Administration – familiar with Apache / SSL / SSH / Kickstart or autoyast / rsync / hardening etc
  • Virtualization – xen
  • RPM creation
  • Perl (Catalyst is a plus)
  • PHP (Symfony is a plus)
  • Python (Django is a plus)
  • C
  • Compiling kernels, making slight adjustments to drivers etc
  • Thin client experience is a plus
  • Software distribution (ZLM / Altiris)
  • Bash scripting
  • Javascript / Jquery
  • HTML / CSS
  • Rest
  • XML / JSON / Yaml
  • Git / Bazaar / Svn
  • Having a github or launchpad account is a plus

If you think you fit the bill email me ASAP as it is an immediate opening, and I will put you in touch with my HR department. You can find my email through Launchpad or Google.

SLES 11 SP1 and Novell / SUSE Autoyast with Intel / Dell Raid Controllers

When using an Intel raid controller, you have two options: let the raid controller handle the raid, or run a linux software raid (md). If you want to run a linux software raid, and use autoyast, a prompt box will popup during the middle of the installation. This becomes a problem if you are imaging several thousand Linux systems.

Add this to your bootup options (in our case PXE config, but you can type it manually also from the installation CD prompt):

libstorage_imsm_driver=mdadm

That is all there is to it. To configure the rest of autoyast, you can check out Uwe Gansert’s website as he maintains it: http://www.suse.com/~ug/

Other hard to find resources when tracking these things down:

Programming using IOCTL to interface with Linux kernel drivers

IOCTL is a function call that allows you to interface with kernel drivers, allowing you to adjust settings or set parameters from code without compiling a new module.

From a programming perspective, having the linux kernel source is a prerequisite. In this example, I cloned the main kernel:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux

Once I had the source, I specifically wanted to see exactly how I could interface with the driver called usblp. I was using a USB to parallel port converter, and wanted to see if there was any way to force it to operate differently as we needed a non-printer device to work with it.

After opening the kernel source, I found the driver file itself which was under /drivers/usb/class/usblp.c. In this file I found a section of information about which IOCTLs it supported, and put them in a header file for my program called usblp-hack.h:

#ifndef USBLP_HACK_H
#define USBLP_HACK_H

#include <linux/ioctl.h>

/* ioctls: */
#define IOCNR_GET_DEVICE_ID     1
#define IOCNR_GET_PROTOCOLS     2
#define IOCNR_SET_PROTOCOL      3
#define IOCNR_HP_SET_CHANNEL        4
#define IOCNR_GET_BUS_ADDRESS       5
#define IOCNR_GET_VID_PID       6
#define IOCNR_SOFT_RESET        7
/* Get device_id string: */
#define LPIOC_GET_DEVICE_ID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_DEVICE_ID, len)
/* The following ioctls were added for http://hpoj.sourceforge.net: */
/* Get two-int array:
 * [0]=current protocol (1=7/1/1, 2=7/1/2, 3=7/1/3),
 * [1]=supported protocol mask (mask&(1<<n)!=0 means 7/1/n supported): */
#define LPIOC_GET_PROTOCOLS(len) _IOC(_IOC_READ, 'P', IOCNR_GET_PROTOCOLS, len)
/* Set protocol (arg: 1=7/1/1, 2=7/1/2, 3=7/1/3): */
#define LPIOC_SET_PROTOCOL _IOC(_IOC_WRITE, 'P', IOCNR_SET_PROTOCOL, 0)
/* Set channel number (HP Vendor-specific command): */
#define LPIOC_HP_SET_CHANNEL _IOC(_IOC_WRITE, 'P', IOCNR_HP_SET_CHANNEL, 0)
/* Get two-int array: [0]=bus number, [1]=device address: */
#define LPIOC_GET_BUS_ADDRESS(len) _IOC(_IOC_READ, 'P', IOCNR_GET_BUS_ADDRESS, len)
/* Get two-int array: [0]=vendor ID, [1]=product ID: */
#define LPIOC_GET_VID_PID(len) _IOC(_IOC_READ, 'P', IOCNR_GET_VID_PID, len)
/* Perform class specific soft reset */
#define LPIOC_SOFT_RESET _IOC(_IOC_NONE, 'P', IOCNR_SOFT_RESET, 0)
#endif

There are plenty of hints on usage here, and I was able to grab a little more info after searching for some of those defines in google code search. Using these IOCTLs I wanted to know exactly which modes the USB to parallel converter supported, and try to set it in mode 3, which I hoped would give me more options for talking to the device.

Here is my usblp-hack.c which was able to probe and update these settings, although in my case mode 3 didn’t work, but shows an example of exactly how to do it:

#include "usblp-hack.h"
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>		/* open */
#include <unistd.h>		/* exit */
#include <sys/ioctl.h>		/* ioctl */

main()
{
	int fd;
	int twoints[2];

	fd = open("/dev/usblp0", O_RDONLY | O_NONBLOCK);
	if (fd < 0) {
		printf("Cannot open device.\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &twoints) >= 0)
		printf("Great success: %d / %d\n", twoints[0], twoints[1]);
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SET_PROTOCOL, 2) >= 0)
		printf("set protocol to version 2\n");
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_GET_PROTOCOLS(sizeof(int[2])), &twoints) >= 0)
		printf("Great success: %d / %d\n", twoints[0], twoints[1]);
	else {
		printf("Fail!\n");
		exit(-1);
	}

	if(ioctl(fd, LPIOC_SOFT_RESET) >= 0)
	{
		printf("Success reset device\n");
	} else {
		printf("Could not reset device\n");
		exit(-1);
	}

	close(fd);
	exit(0);
}

You can compile the above example just using gcc:

gcc -o usblp-hack usblp-hack.c

You can see in the example above I was able to probe the device to see what mode it was currently in and supports (LPIOC_GET_PROTOCOLS), attempt to set the device mode (LPIOC_SET_PROTOCOL), and soft reset the device (LPIOC_SOFT_RESET).

So in the end, nothing here too complex or mind blowing, but if you are just getting your feet wet it might take you a minute to dig this sort of information up.

Tenda W322P Wireless N PCI Card

Purchased this card at Microcenter (http://www.microcenter.com/single_product_results.phtml?product_id=0316296). Out of the box works on Ubuntu 9.10, supports WEP, WPA, WPA2 and has no stability issues transferring large files etc.

Attempted to install the card under Windows 7 x64, x32, and Windows XP SP3, all of which did not recognize the card without additional drivers.

Summary: PCI wireless N card that is Ubuntu compatible with a price under $25
Grade: A+

Tags: , ,

Pygoocanvas, pygtk etc

I was reading a post about PyGoocanvas, and decided to take a look at some code and see what fun could be had. I haven’t done much yet, but this screenshot of it is pretty entertaining in it’s own right:

Ohio Linux Fest

I will be at Ohio Linux Fest all day Saturday, hope to see a lot of Ubuntu people there!

I am looking forward to “Python for Linux System Administration”, “Linux Boot Process”, “Introduction to GNOME 3.0″, “The Ubuntu Kernel”, “Understanding Debian” and “Building a Community Around Your Project”.

Should be a good time, official schedule is: http://www.ohiolinux.org/schedule.html

Tags: , ,

SLES / SLED 10 with Intel 965 Graphics

If you need to update your installation to work with Intel graphics, there is an RPM you can install that will likely resolve your issues:

http://download.opensuse.org/repositories/home:/mhopf:/hp/SLE_10/i586/intel-i810-xorg-x11-6.9.0.2-8.1.i586.rpm

Install that, then run Sax or edit xorg.conf, and make sure to pick the i810 driver. (This post is in response to the number of forum posts on this subject offering no solutions)

Tags: , , , ,