strcmp in bash

If you want to compare two strings in shell you can use something like

test "$str1" = "$str2" but that will only tell you if the strings are equal. The strcmp(3) C function also tells you if the first string is less or greater then the second ( alphabetically) . I created a similar function in shell.

Continue reading strcmp in bash

functions in bash

When programming/scripting in shell, like in most of the other programing languages you can organize your code in functions that can be called from anywhere in your code, you can pass parameters to them and they can return a value or output something.

Continue reading functions in bash

PHP pecl freebsd port bug

A bug exists in the pecl cli script on freebsd that will not permit you to install any pecl package.

The problem is that the pecl script needs pcre.so but the script calls php with -n ( don't use php.ini ) so the pcre.so extension is not loaded.

A quick fix is to edit /usr/local/bin/pecl and remove "-n" from the last line so it will look like
exec $PHP -C -q $INCARG -d output_buffering=1 -d safe_mode=0 -d register_argc_argv="On" $INCDIR/peclcmd.php "$@"

I found this bug when I wanted to install the svn extension but it seems the bug is known for some time and there is a patch for it : http://www.freebsd.org/cgi/query-pr.cgi?pr=110209

Qmail with smtp-auth and DomainKeys on FreeBSD

I tried to set up qmail with tls and smtp auth on freebsd. I have configured my server with SMTP-AUTH so that I can use it to relay messages for me and other authenticated users. I would like qmail to sign the messages that the authenticated users send through my server.

I compiled qmail-tls from ports, checked the smtp-auth and qmailqueue options, then I compiled qmail-dk and selected the SMTP-AUTH patch. I set up my private and public keys, I set up bin/qmail-dk for qmailqueue as described on this page : http://jeremy.kister.net/howto/dk.htm but still not results. It just does not want to add the DomainKeys signature but instead it tries to verify the messages. Continue reading Qmail with smtp-auth and DomainKeys on FreeBSD

The whole Post

When using the <!--more--> tag to split your posts wordpress will generate a link that will take to a bookmark in the full post text.

I wanted the link to take the user to the top of the page so that the user will also see the page's header.

There is an entry on wordpress.org faq about this named How can I customize the "more" tag? that suggests a modification to: wp-includes/template-functions-post.php or wp-includes/post-template.php for wp 2.1 . The modification is fairly easy to do and it's about removing the "#more-id" anchor from the link but I don't want to do this because this means I'll have to remember to do it every time I upgrade wp.

My solution was to implement this as a plugin. Basically my plugin just removes the anchor from the link that takes you to the post page. This is slower then the modification suggested on wordpress.org but it's more convenient to me.

Update: this plugin is now published in wordpress plugins directory and can be installed directly from wordpress plugin admin. Just search for "the whole post"

squid digest authentication


If you use authentication in squid you have several mechanisms ( authenticators ) to chose from. The Basic authenticator is the easiest to set up and the most insecure because the client sends the username and password in plain text to the proxy server.

Instead of using the basic you would consider using the digest authenticator. This authenticator does not require the client to send the user and password in plain text but encoded in an MD5 hash so that an attacker that captures the data between the client and proxy server will not be able to use the user and password.

Continue reading squid digest authentication

Google Sitemaps – Jerome’s Keywords Plugin

I wrote this little wordpress plugin to integrate Jerome's Keywords plugin with Google Sitemaps plugin so that the generated sitemap will also include tag pages. This plugin was inspired by a an addon that integrates Ultimate Tag Warrior with Google sitemaps.

You will need WordPress 2.0.x, Google sitemap 3.0beta and Jerome's keywords 1.9 for this plugin to work. It would be easy to make this work with Google sitemap 2.x so if you need it just let me know.I don't know how this would work on older versions of Jerome's Keywords cause I haven't tried that.

Download: Google Sitemaps - Jerome’s Keywords Plugin

freebsd 7.0 outperforms linux

The development version of FreeBSD ( 7.0 ) seems to scale a lot better then linux on SMP systems.

A combination of latest freebsd scheduler ULE 2.0 that is built into FreeBSD 7.0, the libthr threading library and a patch (not commited, yet ? ) that addresses poor scalability of file descriptor locking and some other patches is what made a system with 8 core amd64 cpu and 16 GB of ram outperform linux by a factor of 4 in MySQL tests.

The tests were performed using sysbench OLTP benchmark, a tool designed for testing mysql performance.

Brief test results: Linux is actually a little ( ~ 2% ) faster then FreeBSD for less then 9 clients, but when the number of clients grows to 20 linux performance drops a lot and FreeBSD's performance stays the same.

More details about the test here:

http://people.freebsd.org/~kris/scaling/mysql.html

DRBD 8.0.1 released


This is a maintenance release of the 8.0 code that fixes a few bugs as the original accounce says:

Tara! The first maintenance release of the 8.0 code:

8.0.1 (api:86/proto:86)
--------
* Fixed some race conditions that could trigger an OOPS when the loca disk fails and DRBD detaches itself from the failing disk.
* Added a missing call to drbd_try_outdate_peer().
* LVM's LVs expose ambiguous queue settings. When a RAID-0 (md) PV is used the present a segment size of 64k but at the same time allow only 8 sectors. Fixed DRBD to deal with that fact corretly. Continue reading DRBD 8.0.1 released

mysql replication monitor

This is not a tutorial about how to set up mysql replication. You can find all the details about how to set up mysql replication in the official mysql documentation. This is just a script that can be used to monitor a MySQL replication setup. A MySQL replication setup consists of a master server and a slave server. On the slave server there are two threads that run continuously, one is the I/O thread that fetches changes that occurred on the master server and one is the SQL thread that tries to run the queries that were executed on the master server.

Continue reading mysql replication monitor