binpkg: a Gentoo Masterpiece

If you were running a cluster of Gentoo driven machines, would you actually compile source for each of them?

Or rather use binary packages?

Gentoo’s masterpiece is binpkg, when you compile for one machine, you don’t have to recompile throughout, use quickpkg to build binary packages. Such packages can be hosted over a central server and each system downloads just the binary package.

You can use this even if your not running a cluster, but frequently reinstall certain packages. Use the -b flag with emerge to install and build the package as well.

Setting the PKGDIR in /etc/make.conf
Add the following directive in make.conf

PKGDIR=”/var/cache/portage/binpkg”

Building binary packages is easy.

quickpkg $(qlist -IC)

That goes on your main server.

You can add the parameter –include-config=y , it’s not reccommended because then you’ll bascically be cloning the host. Your IP addresses, etc. are installed as is. Deploy an instance of puppet.

Now your binary packages are built, you can symlink them and make them available on the webserver for production purposes.

Adding BINHOST to your sister machines, add the following directive in your make.conf, make the necesssary changes:

PORTAGE_BINHOST="http://your.server.repo/path/to/binary/packages"
PKGDIR="/var/cache/portage/binpkg"

 

Options
–getbinpkg Fetch binary source if available, else, fetch source
–getbinpkgonly Fetch binary source ONLY
–usepkg Use binary package for merge if available, else resort to source compile
–usepkgonly Use binary package ONLY

 

Note: If you specify to fetch/merge using ONLY binary packages, if certain dependencies are missing, emerge will simply abort. Hence, its not advisable to do so.

/usr/local/bin/waitpid

A quick script to wait for a certain pid, then once that quits, execute a command.
You may ask, why not just do command1 && command2 ? Well, if command1 exits with a non-zero exit status value, command2 will not get executed. Hence, I’ve brewed a quick script for this purpose.

File: /usr/local/bin/waitpid

#!/bin/sh
# Find the pid of the required process either by using psaux | grep -i command
# or by pidof command
#set -x
if [ $# -ne 3 ]; then
	echo "Usage: waitpid [pid to wait for] [app name] [command]"
	echo "       [command] should be command to execute after pid is dead"
	exit 1
fi
pidr=$1
app=$2
while true; do
	pid=`pidof $app | grep -o $pidr`
	if [ "$pid" = "$pidr" ]; then
		# do nothing
		echo "pid does exist,"
		echo "waiting for 5 seconds before next check"
		sleep 5
		continue
	fi
	break
done
# if we've reached here it means that the PID is dead
echo "specified pid does NOT exist,"
echo "running command provided in 10 seconds"
echo ""
echo "Press Ctrl + c to stop"
sleep 10
$3

Coloured /var/log/messages at tty12

Reading logs could never become any more easier, at just a keystroke, you have your logs displayed where you want, in some fancy colour. They look great too.

CCZE colourized logs

TTY’s can be accessed by pressing Alt + Ctrl + F[1 – 12] simultaneously. In the following, you’ll get a decent, colourized log display of /var/log/messages when you press Alt + Ctrl + F12

First install ccze, most distributions have it in their repositories. CCZE is a robust and modular log colorizer with plugins for apm, exim, fetchmail, httpd, postfix, procmail, squid, syslog, ulogd, vsftpd, xferlog, and more. It brightens up the log view.

To quickly test it, try tail -f var/log/messages | ccze -A

The -A switch prevents ccze from starting itself in a curses window.

Create a file cclm in /usr/local/bin(you have to be root to be able to do so), with the following contents:

#!/bin/sh
file="/var/log/messages"
where="/dev/tty12"
tail -f $file | ccze -A >> $where

Add the following line to /etc/inittab
c12:123456:respawn:/sbin/agetty -n -l /usr/local/bin/cclm 38400 tty12 linux
That’s all that there is to be done, either reboot to get it working, or execute the following in a terminal with privileges:

/sbin/agetty -n -l /usr/local/bin/cclm 38400 tty12 linux

This can be used on any ttys’. The most obvious ones to use would be tty8 to tty12.

Lazy System Admins – Bash Completion

Let’s admit it, we’re all lazy system admins. The bash completion in any other distribution is incomplete, and not as powerful as the one in Gentoo. It just does not work the way it works so brilliantly in Gentoo Linux. Ofcourse, you can port that same source to other distributions. To enable bash completion in gentoo, first enable the global flag bash-completion:

euse --enable bash-completion

Now remerge all packages that have that flag:

emerge -avuDN world

You can now see that eselect bashcomp list lists all the completions available, but are not enabled. To enable them all at once, for the current user(in the following, “jude”), do:

mkdir ~/.bash_completion.d
ln -s /usr/share/bash-completion/* ~/.bash_completion.d/

Now disable the following two sets:

eselect bashcomp disable Makefile.am
eselect bashcomp disable Makefile.in

Re-login, and your all set, cheers!

QEMU | Quick Networking for TCP/UDP

Networking with a guest in QEMU is often a headache, TUN/TAP, seriously? Too hectic, let’s stick to the basics, TCP/UDP based. Instead of setting up a really complex set of configuration files, wouldn’t it be easy to just emulate the network card, DHCP the guest, and let it work right out of the box?

Well certainly yes. QEMU can do all this very easily.

Cut the chase, hit the code:

#!/bin/sh
qemu="qemu-system-x86_64"
cpu_args="-cpu qemu64 -smp 2"
mem_args="-m 128M"
drive="-hda /media/fowlmanordisk1/devel/virtual/red.tvway"
net_args="-net user -net nic,model=rtl8139"
redirs="-redir tcp:8022::22"
${qemu} ${cpu_args} ${mem_args} ${drive} ${net_args} ${redirs} -nographic &

is one of my virtual servers’ running on Ubuntu server. Take a look at the network arguments:
-net user -net nic,model=rtl8139
Pretty simple? The QEMU emulator runs an inbuilt DHCP server, if the guest recognises the network card, and requests the configuration from the DHCP server, it acquires the required IP address, and viola! Instant access to the outside world. The file /etc/resolv.conf still needs to be configured to your preferable DNS servers. OpenDNS is usually a good solution.

Notice the -redir argument, it specifies that an issue to port 8022 on the outside be mapped to port 22 on the inside(guest). So basically you could ssh localhost -p 8022 and get access to your guest machine.

The -redir is as follows(from the QEMU manual pages):

-redir [tcp|udp]:[hostaddr]:hostport-[guestaddr]:guestport
         Redirect incoming TCP or UDP connections to the host port
         hostport to the guest IP address guestaddr on guest port
         guestport. If guestaddr is not specified, its value is x.x.x.15
         (default first address given by the built-in DHCP server). By
         specifying hostaddr, the rule can be bound to a specific host
         interface. If no connection type is set, TCP is used. This
         option can be given multiple times.

Enjoy virtual machines with QEMU.

visual basic 6 revisited – linux – wine

Earlier this year, I had written an article on running Visual Basic 6 on linux under wine, this is an update for it, the prior one is deprecated

Getting Visual Basic 6 to work on linux is pretty easy, not much trouble, all the basic things work, as of what I’ve tested.

Here’s how you get that damn thing to work:

Copy over the contents of OS/SYSTEM/ from the CD root to your wine system32 directory

$ cp -r /media/cdrom/OS/SYSTEM/* ~/.wine/drive_c/windows/system32/

Since we are only concerned about Visual Basic 6, copy over the folder VB98 from the CD root to your Program Files

$ cp -r /media/cdrom/VB98/ ~/.wine/drive_c/Program\ Files/
# for the sake of convenience, let's rename this folder as Visual Basic 6
$ mv ~/.wine/drive_c/Program\ Files/VB98/ ~/.wine/drive_c/Program\ Files/Visual\ Basic\ 6/

Register the two dynamically linked libraries essential to run Visual Basic 6 smoothly

$ cd ~/.wine/drive_c/windows/system32/
$ wine regsvr32 comcat.dll
$ wine regsvr32 MSSTDFMT.DLL

Easy, eh? Your all done, now, let’s create an optional launch command with the following contents
File: vbasic

#!/bin/bash
cd ~/.wine/drive_c/Program\ Files/Visual\ Basic\ 6/
wine VB6.EXE

Make our launcher executable and place it in the right place

$ chmod +x vbasic
# following command must be issued as root
$ mv vbasic /usr/local/bin/

Now you can just issue the command vbasic, and all should work well, using this launcher, you can create entries for your panel, etc.

Deployed with a fresh install of wine version 1.2-rc2

CPU scaling governors and you

What is your CPU being governed by? Should it be governed by it? Why? How?
Here’s an outlook on the various CPU frequency governors, namely conservative, ondemand, powersave, userspace, and performance, that steps up and steps down the CPU:
conservative
Pros:

  • very much alike the ondemand governor
  • gracefully increases the stepping, unlike ondemand which sets it to maximum when there is any load
  • more suitable for battery powered environments

ondemand
Pros:

  • the best of all
  • sets the speed to what is required
  • saves power
  • doesn’t hinder CPU power, as it scales to what is required

powersave
Pros:

  • sets the CPU statically to use the lowest possible frequency supported
  • you save power

Cons:

  • if you use resource hungry software, your machine may start to lag

userspace
Pros:

  • another application can be used to specify the frequency
  • lets you manually specify the frequency your CPU should run on

Cons:

  • mostly useless!
  • external application may set it low, you save power, but less performance
  • external application may set it high, you consume more power

performance
Pros:

  • statically sticks to the highest possible CPU scaling available, regardless of the available ones
  • your system will run as fast as possible

Cons:

  • takes the most power that you CPU is able to consume
  • not very suitable for battery powered environments, or even to save more power your machine consumes

embedded gentoo [uclibc] | nothing beats this

A few uclibc embedded gentoo facts:

  • the compilation of the box takes around 15 minutes
  • at boot up, takes less than 3 megabytes of RAM
  • disk space: 17 megabytes
  • boots in under 8 seconds on a pentium3

link to stage3 tarballs archive
HTOP - Displaying System Statistics
# this is my make.conf, it should be the same in the stage3, if installing anything in the stage3, and even before updating, comment the line INSTALL_MASK=”*.h HACKING.gz TODO.gz”

CFLAGS="-Os -mtune=i386 -pipe"
CXXFLAGS="-Os -mtune=i386 -pipe"
CHOST="i386-gentoo-linux-uclibc"

FEATURES="strip"
MAKEOPTS="-j3"
GENTOO_MIRRORS="http://mirror.bytemark.co.uk/gentoo/ http://www.ibiblio.org/pub/Linux/distributions/gentoo"

USE="-ipv6 -python3 -cracklib -minimal"

LINGUAS="en"
VIDEO_CARDS=""
ACCEPT_KEYWORDS="~x86"
INSTALL_MASK="*.h HACKING.gz TODO.gz"

# download my stage3, from the previous post links, and then prepare to chroot

mount -o bind /dev stage3-*/dev
mount -o bind /proc stage3-*/proc
chroot stage3-*

# update the system, and create the necessary path, if you come across any errors, post them here, and expect a reply soon

emerge -avuDN world
mkdir /mounted

# begin the installation
# install necessary packages

ROOT=/mounted/ emerge -auvND baselayout uclibc bash dropbear pam udev iptables coreutils nano util-linux shadow kbd net-tools grep procps gzip sed findutils mawk htop
mkdir /mounted/proc
mkdir /mounted/dev

Continue reading “embedded gentoo [uclibc] | nothing beats this”

noCD? |boot from usb| Sabayon Linux

I had a pen-drive lying around, and so I decided to try out a new distribution of linux, Sabayon Linux.

Why Sabayon?

  • On a base install, everything is there and just works perfectly
  • For a newbie, the hard part is often getting playback codecs, well, Sabayon has them pre-installed
  • Sabayon has focused on the base theme too, it looks great
  • Entropy, their package manager, is really awesome, ‘man entropy’ to see more

Let’s mount and copy the contents of the live image, it can be downloaded here. As super user, do

mkdir /media/sabayon
mount -o loop /path/to/iso/file /media/sabayon

Plug in you pen-drive, wait for the device to settle down first, then copy whatever is important to you from the pen-drive to a hard-disk, and format it after you’ve successfully backed up your previous data

mkfs.ext3 /dev/sdyx

Replace sdyx as per your needs, i. e. the partition where you will be booting the live image from, in my case it was sdc1. You can choose any filesystem type you want to, but let’s just stick to ext3 for now.
Now copy the contents of the live image which you previously mounted to this drive after mounting it

mkdir /media/target
mount /dev/sdyx /media/target
cp -r /media/sabayon/* /media/target/

The parameter ‘-r’ indicates that it should copy recursively, and not just the files present in the top level directory
Now we’ll need to setup that device to boot correctly, you may not want to end up with a few errors and be done with it, do you?
Continue reading “noCD? |boot from usb| Sabayon Linux”

Restore Broken Package DB on Sabayon

System database not found or corrupted, running in safe mode using temporary, empty repository

phoenix jude # equo rescue resurrect
>> ####### ATTENTION: The installed package database will be resurrected, this will take a LOT of time.
>> ####### ATTENTION: Please use this function ONLY if you are using an Entropy-aware distribution.
     Can I continue ? [Yes/No] yes
     Are you REALLY sure ? [Yes/No] yes
     Do you even know what you're doing ? [Yes/No] yes
>>  @@ Creating backup of the previous database, if exists.
>>  @@ Previous database copied to file /var/lib/entropy/client/database/amd64/equo.db.backup.15103
>>   Initializing the new database at /var/lib/entropy/client/database/amd64/equo.db
>>   Database reinitialized correctly at /var/lib/entropy/client/database/amd64/equo.db
>>   Found 420663 files on the system. Assigning packages...
>>   Matching in repository: Sabayon Linux Official Repository
>>   Found 0 packages. Filling database...
>>   Database resurrected successfully.
>>   Now generating reverse dependencies metadata...
>>   Now indexing tables...
>>   Database reinitialized successfully.
>>   Keep in mind that virtual packages couldn't be matched. They don't own any files.
phoenix jude # 

fascinating and too simple!
For one thing, I have no clue why did it say “Found 0 packages.”, because just after this I was successful in doing an equo upgrade and it worked beautifully.
equo has become a teenager…

Defining Two Different System Gateways

Situation above ground forces:
You have two modems, or two ethernet connections, and want part of your connections to go through ppp0, and the rest through ppp1

Quick Fix:
Quite easy, get both your connections live, and ppp0 will by default be the default gateway. Now, use a proxy for all other connections, so if this proxy is 10.10.1.100 on some random port, and the gateway to ppp1 is 10.6.6.6, issue the following:

route add 10.10.1.100 gw 10.6.6.6

Fedora Constantine, SYSRQ and needless swapping

By default, fedora disables the SYSRQ functionality of the kernel, for some reason. To enable it, either add sysrq_always_enabled at the end of your kernel line in /boot/grub/menu.conf, or edit /etc/sysctl.conf, changing

kernel.sysrq = 0

to

kernel.sysrq = 1

Some kernel updates on fedora also have the tendency to write to swap needlessly, even though you have loads of RAM available, to stop this, edit /etc/sysctl.conf again, and add the following two lines

# Controls the swapiness of the machine
vm/swappiness = 0

To just temporarily disable it, do

echo -n 0 > /proc/sys/vm/swappiness

as root

***These tips are applicable to almost any GNU/Linux distribution, not necessarily for Fedora alone

Visual Basic drinking Wine

This tutorial is depreciated, please follow my new tutorial: visual basic 6 revisited – linux – wine
Visual Basic running on Fedora

Get past with your life on Windows, install Microsoft Visual Basic 6 on GNU/Linux with some good old wine…

  1. Install the required libs, etc.
    $ winetricks ddr=gdi vb6run gecko gdiplus fontfix d3dx9 corefonts mdac_typ dcom98
  2. From a working Windows XP installation, copy over riched20.dll, riched32.dll, urlmon.dll, oleaut32.dll, and hhctrl.ocx, from the system32 folder to your wine system32 folder
  3. In your Wine configuration dialog, under the Libraries tab,
    set the following files to native:
    hhctrl.ocx
    oleaut32
    riched20
    riched32
    urlmon
    And set these to builtin:
    ole32
    rpcrt4
  4. Do a fresh install of IE6 with ies4linux, click on Advanced and edit the downloads and the install prefix to make it totally compatible with your existing .wine directory.
  5. Then run the Visual Basic 6 installer, and if everything goes well, cd to .wine/drive_c/windows/system32 and execute “wine regsvr32 comcat.dll” and “wine regsvr32 MSSTDFMT.DLL”

And your done! Have fun with Visual Basic on Linux!

Tested with wine 1.1.38 and Fedora Constantine(F12)

Upgrade WordPress, eh?

Here’s what most, or at least all of you are doing: your upgrading your WordPress blog back-end from time to time as and when releases are out. Most of the articles about this tell you how to upgrade. Well, this one doesn’t. Here are five reasons why not to upgrade WordPress!

  • Your present theme(which you are most comfortable with) would probably break
  • Your plugins, if the authors are either paralyzed or dead, won’t upgrade them, so you lose out on plugins that you already have installed and then waste your time looking for newer ones which provide the same functionality
  • In worse scenarios, you may lose your database(of course, you do have a backup, but restoring it would take time)
  • Takes ten minutes of your precious time(as a science student, I really don’t have much time on my hands)
  • Why on earth would you want to upgrade?

Then again, “When I upgraded my WordPress, I have new features and increased robustness”. Okay, so what? Let’s stick to one release which doesn’t have any bugs nor any glitches. Recently, around a year back, Automatic released two upgrades for WordPress, one after another within a month or so, because the earlier one had a potential security flaw. So your really not sure if the one your going to updade to would be secure as in “secure”, or would a flaw be discovered after you’ve upgraded, and then have your blog hacked.

There are so many features in the present WordPress which most of us fail to use or make use of properly, so why would you want to upgrade it when your not going to use the new features?

Now, think again,

Do I really want to upgrade my WordPress back-end?

P. S. If anyone knows how to disable that yellow banner that pops up when a new WordPress update is available, and/or know how to disable plugins from showing their updates, please comment how to.