Qmail Autoresponder


 $ make
 # ./installer
 # ./instshow
 # vi /etc/vmailmgr/vdeliver-postdeliver

And make sure it contains:

 if test -s $MAILDIR/autoresponse/message.txt
   qmail-autoresponder $MAILDIR/autoresponse/message.txt $MAILDIR/autoresponse


 # /etc/vmailmgr/vdeliver-predeliver

and make sure it contains:



 # chmod a+x /etc/vmailmgr/*



 |qmail-autoresponder MESSAGE_FILE DIRECTORY

into your


file before other delivery instructions. MESSAGE_FILE is a pre-formatted response, including headers, and DIRECTORY is the directory into which rate-limiting information will be stored. Any instance of “%S” in MESSAGE_FILE will be replaced with the original subject.

Follow these instructions from the vautoresponder file:

  1. set MAILDIR to the (virtual) user’s mail directory
  2. create a directory “autoresponse” within the user’s mail directory
  3. create a file “message.txt” within the users autoresponse directory

How to change ownership of a PostgreSQL database

To change the owner of a database we have found this solution:

UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE usename='new_owner') WHERE datname='db_name';


    * From: Tom Lane
    * To: Devrim GUNDUZ
    * Subject: Re: changing ownership of db
    * Date: Tue, 29 Jul 2003 17:41:08 -0400

Devrim GUNDUZ  writes:
> On Tue, 29 Jul 2003, Benjamin Thelen (CCGIS) wrote:
>> I would like to change the ownership of a database.

> UPDATE pg_database SET datdba=(SELECT usesysid FROM pg_shadow WHERE
> usename='new_owner') WHERE datname='db_name';

That is all you need to do --- it's the only place CREATE DATABASE
records the owner's identity.

> If you also want to change the owner of the tables, update pg_class:

> UPDATE pg_class SET relowner=(SELECT usesysid FROM pg_shadow WHERE
> usename='new_owner')  WHERE relname IN (SELECT relname from
> pg_class WHERE relname NOT LIKE 'pg_%');

This is likely to be a very bad idea, especially if you give ownership
of the system tables to a non-superuser.  Ownership of those tables
stays with the postgres user during a CREATE DATABASE.

			regards, tom lane

PostreSQL Upgrade Process

  • First you need to change permissions on the localhost to trust:
    # cd /var/lib/pgsql/data
    # vi pg_hba.conf

    Change the autorization/authentication for the line that starts with “local” to trust:

    local        all                                           trust
  • And prevent clients to access the database by changing in postgresql.conf:
    tcpip_socket = true


    tcpip_socket = false


    ssl = true


    ssl = false
  • restart postgres:
    # service postgresql restart

    If you are having trouble restarting postgres, try to force the restart:

    # su - postgres
    $ pg_ctl -m immediate -D /var/lib/pgsql/data restart
  • Create a backup of the database:
    # sudo -u postgres pg_dumpall > ~postgres/backups/full-[version]-[date].out
  • Shut down PostgreSQL
    # service postgresql stop
  • Upgrade PostgreSQL
    # rpm -Uvh /usr/src/redhat/RPMS/i686/postgresql-*rpm
  • Move the old db structure out of the way:
    # mv /var/lib/pgsql/data /var/lib/pgsql/backups/data-[oldversion]
  • Start postgres back up:
    # service postgresql start
  • Modify the pg_hba.conf file back to what we need it to be for the migration (see previously)
  • Restore the database:
    sudo -u postgres psql -e template1 -f ~postgres/backups/full-[version]-[date].out > create.log 2> error.log
  • Restore the /etc/init.d/postgresql file with the logging:
    su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl  -l /var/log/pgsql -D $PGDATA -p /usr/bin/postmaster -o '-p ${PGPORT}' start  > /dev/null 2>&1" < /dev/null

    Make sure to check the error.log, and if you encounter “permission denied” problems, make sure the the user (at top of the backup file) has the correct permissions set.

  • Restore pg_hba.conf and the postgresql.conf files to the original values
  • Restore the server certs
    cp -a /var/lib/pgsql/backups/data-[version]/server.* /var/lib/pgsql/data
    chown postgres.root /var/lib/pgsql/data/server.*
    chmod 600 /var/lib/pgsql/data/server.*
  • Restore the postgres password to the correct pass:
    ALTER USER "postgres" WITH PASSWORD 'secret-password-here' CREATEDB CREATEUSER
  • Restart PostgreSQL

Rebuild Postgres for specific platform

# rpm -i postgres-[version number].src.rpm

# rpmbuild -bb --target i686 /usr/src/redhat/SPECS/postgresql.spec

If you get a problem with unpackaged files, use the following trick:

vi /usr/lib/rpm/macros

An modify some of the lines as follows:


# Script gets packaged file list on input and buildroot as first parameter.

# Returns list of unpackaged files, i.e. files in $RPM_BUILD_ROOT not packaged.


# Note: Disable (by commenting out) for legacy compatibility.

#%__check_files         /usr/lib/rpm/check-files %{buildroot}


# Should unpackaged files in a build root terminate a build?


# Note: The default value should be 0 for legacy compatibility.

%_unpackaged_files_terminate_build      0


# Should missing %doc files in the build directory terminate a build?


# Note: The default value should be 0 for legacy compatibility.

%_missing_doc_files_terminate_build     0

PHP after upgrading to 4.3.10 displays errors: "Warning: Illegal offset type in…"

I found this solution originally on Kreny’s Blog

Troubleshooting for “Warning: Illegal offset type in …” in PHP

Posted by kreny at December 17, 2004 02:08 AM

System Environment:
Red Hat 9.0 + Apache 2.0.52 + PHP 4.3.10 + Zend Optimizer v2.1.0 etc.

  • Description:I upgraded PHP 4.3.9 to 4.3.10 and when I opened my sites like phpMyAdmin or Nucleus v2.5 beta, the page led to:

    Warning: Illegal offset type in abc.php on line 91
    Warning: Illegal offset type in abc.php on line 108

    After I downgraded PHP to 4.3.9, everything goes well.

  • Troubleshooting:I searched PHP Bugs and found some interesting issues:
  • Bug #31116 Pear not working after update to 4.3.10
  • Bug #30914 foreach returns the wrong value
  • So I was wondering that the low-version of Zend Optimizer caused the problem.

    Upgrading Zend Optimizer to 2.5.7
    Please read the Zend Optimizer User Guide first.

    # tar -zxvf ZendOptimizer-2\[1\].5.7-linux-glibc21-i386.tar.gz
    # cd ZendOptimizer-2.5.7-linux-glibc21-i386
    # ./install

    The following configuration changes have been made:

    – The php.ini file has been relocated from /usr/local/lib to /usr/local/Zend/etc.
    – A symbolic link for the php.ini file has been created in /usr/local/lib.
    – The original php.ini was backed up to /usr/local/lib/php.ini-zend_optimizer.bak

    Some lines updated in php.ini:


    Then restart the apache and recombine the PHP 4.3.10 by using configure in my previous setting, and remember to run:
    #libtool –finish /root/source/apache2/php-4.3.10/libs

How do I change the speed duplex on an Intel card with Linux?

If you ever had a Linux on a dev network with various switches (decommissioned from production) you may have encountered traffic throughput problems. Quite often this can be caused by a speed duplex problem. Here is how to modify speed duplex on Linux with Intel cards, when the dev environment is not nearby.

First, you need to have a card with a modern driver, that uses the mii module. Then you can write a small script (assuming you are remotely logged in) to make sure that you don’t cut yourself off:

mii-tool -F 10baseT-FD eth0
echo Switched to full duplex, if you can see this text,
echo you have been successful and you have 5 seconds to
echo press +C to keep the settings
sleep 5
echo Timed out.  Reverting to original settings
mii-tool -F 10baseT-HD eth0

To make the changes permanent at reboot, under kernel 2.4, you can modify modules.conf by adding the following line:

options eepro100 full_duplex=1

And under kernel 2.6, you can modify modprobe.conf by adding the sameline:

options eepro100 full_duplex=1

Please note that if you try to use e100 you may encounter problems, as the line

options e100 e100_speed_duplex=4

doesn’t seem to work for most people, even though the mii-tool command does work.

How to create or apply a patch?

Often programmers that haven’t worked with patches before find it intimidating. Patches are actually very simple to deal with. Here is how.

Creating Patches

diff -u oldfile newfile > filename.patch


diff -urN /olddir /newdir > filename.patch


diff -urN -X excludes /olddir /newdir > filename.patch

diff options:
-u Output (default 2) lines of unified context.
-r Recursively compare any subdirectories found.
-N Treat absent files as empty.
-X FILE Exclude files that match any pattern in FILE.

Note: The -u options can be replaced with -c to create a context format diff file with a setting of two lines.

Applying Patches

gzip -cd patch.gz | patch -p0


bzip2 -dc patch.bz2 | patch -p0


patch -p0 < filename.patch

patch options:
-p NUM Strip NUM leading components from file names.

Installing SSH on Android (aka Google Phone)

The Google phone has a very potent ssh client called ConnectBot. For a novice Android phone user, it is easy to get lost among all the options there are to install the ConnectBot ssh client.

Installing ssh using the Android Market

This method is done completely from the Android phone:

  • Press the “Home” button next to the green talk button
  • Expand the tab on the right (or bottom) of the screen to show all the apps available. The tab is gray and has a little triangle in a circle in it. You can expand it by sliding your finger from the tab to the right (or upward).
  • Tap the icon that has “Market” as the label. The icon looks like a white shopping bag, with a green android logo printed on it.
  • Press the “Menu” button next to (or above) the mini track wheel.
  • Tap the “Search” option that pops up.
  • Type in “ssh” and hit the enter key.
  • Select “ConnectBot”
  • Tap “Install”

Within a few seconds your ssh client will be downloaded and installed.

Installing ssh using the Android SDK

This method is much more complex, but if you don’t want to use the Android Market, this method is for you.

  • Download and Install the Android SDK.
  • Open a terminal / console window and go to the directory you installed the SDK to, and go down into the tool directory.
  • Connect your Google phone to your laptop with the USB cable.
  • Download the latest version of ConnectBot from its website for example: ConnectBot-svn-r211.apk.
  • Install ConnectBot with ./adb install /path/to/ConnectBot-svn-r211.apk (replace version number as appropriate).

Adding a shortcut to your desktop

After using either method, you can use ConnectBot to connect via ssh to a remote host by opening the apps from “Home” as described above. If you want to make a shortcut to ConnectBot to your desktop, just follow these steps:

  • press the “Home” button,
  • tap the “Add” box,
  • tap the “Application” line,
  • slide the list with your finger until you see the “ConnectBot” line,
  • tap the “ConnectBot” line.