How to re-run the CONFIGURATION script for software in FreeBSD Ports

Some of the software in FreeBSD’s Ports provide a menu based interface to configure the package. For instance, when you’re trying to install the curl package by typing make in the ports directory, the install has an option to use GNUTLS which you can select.

However if you do this without disabling OpenSSL, the port will fail to compile since these two options are mutually exclusive.

You can try to run ‘make’ again hoping to fix this configuration error. However you will notice that ports is not bringing up the configuration menu anymore. Removing the ‘work’ dir where all the source file related operations (configure, make etc) are performed, you will still not be able to bring the configuration menu up.

That’s because the initial configuration options are kept elsewhere. These files are in /var/db/ports . For instance, you will find a file called “curl” which contains a representation of all the options you’ve previously selected in a way that the Makefile (configure script is more accurate) of the port will understand.

Remove this file and the next time you try to install the same port, you will see the configuration menu again.

In my opinion make should accept a ‘reconfigure’ option that overrides the cache. If it does I didn’t find it.

Sending files to Sony Ericsson K750 via Bluetooth on Linux

I just received my Sony Ericsson K750c (c denotes an Asian model). It’s a pretty decent phone - apparently the best seller of the company last year. I decided to buy this model instead of a newer model because it uses regular memory stick duo (and pro duo) as opposed to the micro version that came out more recently. I thought it would be a cheaper to get a decent sized stick for this model and I was right. I just ordered a 2gig Sony one with MagicGate (I’m not mentioning because I’ll use this, but to make price comparison easier) for around $70 from overstock.com. There’s also better support for it on both Windows and Linux because of the relative maturity of the phone.

As soon as I got the phone I wanted to install an rss feed reader so I can read lewrockwell.com articles from anywhere I want. Most free rss readers seem to require some sort of registration the purpose of which escapes me. So I finally found one that doesn’t need registration. This one isn’t free-as-in-free-software either so I will need to find a replacement. The software is distributed as a .jar file which is a glorified .zip that java enabled devices know how to handle. You just send the file to the device and it asks you what to do with it. “Install” would be my pick :) But how do you actually send the file to the device?

First you need to have your bluetooth set up under linux. Nowadays it’s not that difficult. Then you need to download some sort of obex ftp client which is the client for an ftp-over-bluetooth kind of protocol. Then you use this client to send the file to the device and voila (or “bak şu allahın işine”) the phone installs the software and you can start using (!) it. (Come to think of it, wonder what it does with the archive file itself once it’s decompressed. Probably deletes it)

If your bluetooth is set up properly you can use the hcitool utility to scan and find your phone.

oktay@sibop:~$ hcitool scan
Scanning …
00:12:EE:90:DF:FE Kestane
oktay@sibop:~$

Next, you can use the obexftp command to send the file to this phone.

oktay@sibop:/usr/share/doc/gnome-bluetooth$ obexftp -b 00:12:EE:90:DF:FE -p ~oktay/Desktop/RSSManager.jar
Browsing 00:12:EE:90:DF:FE …
Channel: 6
Connecting…done
Sending “/home/oktay/Desktop/RSSManager.jar”…-done
Disconnecting…done
oktay@sibop:/usr/share/doc/gnome-bluetooth$

If your phone keeps asking for a PIN/Password but won’t accept whichever password you enter, you need to configure /etc/bluetooth/hcid.conf and set the “pin_helper” parameter in “options” to something like:

pin_helper /usr/bin/pin-helper;

You can use various other pin helper scripts like I had decided to use ‘bluez-pin’ but apparently I neglected to fix the line above and it still works. Beats me. I had tried a bunch of other stuff one of which must have worked. :)

So just ignore this post till I figure out what’s going on.

How to run multiple Wordpress blogs on the same server using a single install base

Intro

I have two blogs. One is in Turkish Safsata.org, the other is this one, which as you might have guessed already, is in English. I wanted to find an easy way to maintain both blogs and keep up with updates and security fixes. Running two seperate complete installs would mean twice the effort so I decided to try and see if two domains can be run from one directory of source (that is, php source mostly) files.

There's already good documentation about a similar situation I found online. If it suits your needs, you should use that more complete solution.

Scenario

OK. Here's our scenario. We have access to a web server and we have two seperate domains on this server. These domains may or may not have their own domain names. It doesn't matter. We want to install the Wordpress files on a single directory and have both (or more than two) blogs be served from this common base. You still have to have a seperate database for each blog since the data (posts, user accounts, comments, settings) etc would be different per blog.

Steps

I already had one of the blogs installed. I moved the source files from this directory to a wordpress sources directory in my home directory. Where you put the files really doesn't matter as long as the web server can access those files. Here's what that directory looks like.

-bash-2.05b$ ls -1a /home/oktay/wordpress/source
.
..
.htaccess
index.php
license.txt
readme.html
wp-admin
wp-atom.php
wp-blog-header.php
wp-comments-post.php
wp-commentsrss2.php
wp-config-sample.php
wp-config.php
wp-config.php.bkp
wp-content
wp-feed.php
wp-includes
wp-links-opml.php
wp-login.php
wp-mail.php
wp-pass.php
wp-rdf.php
wp-register.php
wp-rss.php
wp-rss2.php
wp-settings.php
wp-trackback.php
xmlrpc.php

There are two important files here which need to provide the different settings for each blog. These files are wp-config.php and .htaccess the latter only being necessary if you want to use pretty urls, and when I call them pretty, how can you not use it right? :)
Once we have the files in place, we need to make sure that the blogs point to these files on the filesystem.

On my setup I prefer to keep the base of the domain as a non-blog site (not that I have anything there yet) and have the blog on a subdirectory.

It looks like this for my sites:

On the document root for safsata.org there's a symlink to the source files by the name 'saf'. This way the blog ends up at http://safsata.org/saf .

saf -> /home/oktay/wordpress/source/

The link for thatissopunkrock.org looks like:

punk -> /home/oktay/wordpress/source/

Likewise, the blog url for this site is http://thatissopunkrock.org/punk . (Actually having a different subdirectory name for each blog causes a problem with .htaccess which we'll fix later on)

At this point you can access both sites on your browser. If you don't mind both blogs being identical that is. To me this feels slightly counter to the subject of this post, so we shall tackle this nuisance :).

The reason both sites are identical is because they are both using the same database. What we need to do is to create a dump of the existing database, and import it back into a database with a different name. (If you have only one database on the server, you can also play with the table prefix settings but that's not explained here). Please refer to documentation on how to actually accomplish this.

What follows is the actual meaty part of this article. If we're going to have seperate databases serving these blogs, we have to configure this in wp-config.php . However, since we're sharing this file we can't just edit it. We have to put a little bit of logic into the file. (This is but one solution. Many solutions are possible involving symlinks, more coding etc)

PHP:
  1. if($_SERVER['HTTP_HOST']=='safsata.org') {
  2. define('DB_NAME', 'safsata_wp');
  3. define('DB_USER', 'safsata_wp');
  4. define('DB_PASSWORD', 'PASS HERE');
  5. define('DB_HOST', 'localhost');
  6. }elseif($_SERVER['HTTP_HOST']=='thatissopunkrock.org') {
  7. define('DB_NAME', 'tispr_wp');
  8. define('DB_USER', 'tispr_wp');
  9. define('DB_PASSWORD', 'PASS HERE');
  10. define('DB_HOST', 'localhost');
  11. }else{
  12. die("no such thing is setup here");
  13. }

Basically the config file now knows to check the hostname of the requested blog and look at the correct database accordingly.

However, we stil do have two identical blogs. (Darn!) Worse, we can't really change the options on the web interface of the second blog because the url parameters are still set to the first blog meaning every link you click will take you to the first blog.

We will fix this with a database query on the second blog's database.

SQL:
  1. UPDATE wp_options SET option_value = 'http://thatissopunkrock.org/punk' WHERE option_name = 'siteurl';

Now you can log into the second blog and make all the rest of the changes through the admin interface. All previous themes, plugins etc will be available. However, future ones need to be activated on each blog seperately. (You're still only downloading those once into the common source directory)

Conclusion

So what's the benefit of this setup? Why not just install two instances?

First of all. That is a valid solution as well. If you'd rather do that, please go ahead and do it. However, if you are going to repeat the same process for fifty blogs, I think there's some value in using a common source directory.

As a bonus, you'll only need to upgrade your files once if there's a security fix or an upgrade. And you don't need to download/install themes/plugins more than once.

We're almost done. Almost. The pretty urls don't work yet, because the rewrite rules in .htaccess are pointing to the first blog. Now we could fix this the elegant way by modifying our web server configuration so that each host would have a seperate .htaccess file (such as .htaccess-saf and .htaccess.punk etc). However, there's a faster hack for this. Again, if you have the same subdirectory on each of your domains (like a normal person would :P), you won't need this hack.

The reason your pretty urls don't work is because (using my setup as an example) the second blog is still seeing the rewrite rules and looking for a directory called 'saf' which is not there. (Remember the blog is at 'punk'). We work around this by just creating a new symlink with the same name, so our rewrite rules will be happy. Since this all happens in the background, we'll never see 'saf' mentioned anywhere on the second blog.

So taking my setup as an example again, the new symlink on the document root for http://thatissopunkrock.org/punk (second blog) would look like this:

saf -> punk

Well. There you have it. Sorta. Questions/Comments, use the Contact form.

Subversion umask tip

When using the subversion source control system with access methods other than apache2+webdav it's a good idea to create a seperate group and add all developers' usernames into this group.

Afterwards change the group of everything in the repository to this group. Assuming the group name is 'svn' the unix command to do this would be something like

chgrp -R svn /path/to/repository

Then you will also have give the group write access to the repository;

chown -R g+rw /path/to/repository

If everybody's umask's are set such that newly created files/directories will have 'rw' access for the group, then you're all set. That mask would be something like 002 (which creates a file equivalent to the chmod parameter 775).

umask's are usually not set at 002, they are set at 022 which gives write access to only the creator of the file.

So it's a good idea to use wrapper scripts for commands such as svn, svnadmin , svnserve etc. (When doing svn+ssh , a svnserve instance running as that user is spawned, so the wrapper will get called there too)

Before creating the wrapper, rename the actual svn executable to svn-real.

Assuming 'svn' is at /usr/local/bin a wrapper for 'svn' might look like this

#!/bin/sh
umask 002
/usr/local/bin/svn-real "$@"

It would also make things a lot easier if you initially created the repository while logged in as a user that's in the 'svn' group. Just remember to do

umask 002

before running the 'svnadmin create' command and the permissions will be created correctly.

It's a little late in the post to tell you why you need all of this but it's better late than never. When using the file:// and svn+ssh:// methods of access, svn commands are run with the identity and permissions of the user that's running the command (in the ssh case, the username given to ssh). When multiple people are accessing the same repository, sooner or later you will get stuck with permission errors while creating or modifying the Berkeley DB files subversion creates in the repository. The above solution is needed to fix this. When using apache2+webdav this problem does not exist because once configured access to the database file is always made by the same daemon user.

Good luck.