Archive for January, 2012

Contact Form 7 options

When using Contact Form 7 in WordPress, you may need to add a hidden identifier, like the submitters IP address.

This is easily done by adding [_remote_ip] into the email template.

 

More tags here: http://contactform7.com/special-mail-tags/

Useful inputrc

Place the following in ~/.inputrc or /etc/inputrc
While ~/.inputrc works sometimes, it doesn’t on all systems.

"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
set completion-ignore-case On

All lines except the last enable nice readline & bash cursor movement (control + arrow keys and what not) while the last line turns on case insensitivity for tab-completion, enabling you to have folders and files of mixed case characters while not having to type the capital letters. (You can have a directory called “Documents” and tab-complete by tying “doc

From: http://linuxart.com/log/archives/2005/10/13/super-useful-inputrc/

Recover corrupted RPM database

From http://honglus.blogspot.com/2011/09/recover-corrupted-rpm-database.html

RPM database consists of a number Berkeley DB files in /var/lib/rpm, the exception is __db.* files, which like cache files are updated for every rpm operation and they can be safely deleted.

#tested in Centos 5.5

$ ls /var/lib/rpm
Basenames __db.001 __db.003 Filemd5s Installtid Packages Provideversion Requireversion Sigmd5
Conflictname __db.002 Dirnames Group Name Providename Pubkeys Requirename Sha1header
$ file /var/lib/rpm/Packages
/var/lib/rpm/Packages: Berkeley DB (Hash, version 8, native byte-order)

If one of the DB files is partially corrupted and it is still readable by /usr/lib/rpm/rpmdb_dump, you can reload the DB file and rebuild db.

$cd /var/lib/rpm/
$rm -f __db*
$mv Packages Packages.orig
$/usr/lib/rpm/rpmdb_dump Packages.orig | /usr/lib/rpm/rpmdb_load Packages
$/usr/lib/rpm/rpmdb_verify Packages

#if you got this error: db_verify: PANIC: fatal region error detected; run recovery
#make sure /var/lib/rpm/__db.* are cleaned
#It is unlikely to rebuilddb if rpmdb_verify fails

$rpm -v –rebuilddb

If one of the DB files is completely corrupted and it is not readable by rpmdb_dump, you have to restore from backup,

$cd /var/lib/rpm
$cp Packages Packages.bak

#simulate a damaged RPM DB file

$ >Packages
$ cp Packages.bak  Packages

# Simply restoring from backup file won’t work
# file verification is successful

$ /usr/lib/rpm/rpmdb_verify Packages

#but any rpm operation fails

$rpm -qa error: rpmdbNextIterator: skipping h#     294 Header V3 DSA signature: BAD, key ID e8562897

#Even “rpm –rebuilddb” fails

$rm -f __db.*
$rpm –rebuilddberror: rpmdbNextIterator: skipping h#     294 Header V3 DSA signature: BAD, key ID e8562897

#Notice the error about signature: BAD? The Pubkeys have to be cleaned as well.

$ mv Pubkeys Pubkeys.bak

#all good after removing Pubkeys file, a new Pubkeys is generated automatically on “rpm –rebuilddb”

$ rm -f __db.*
$ rpm –rebuilddb
$ rpm -qa | head -2man-pages-2.39-15.el5_4bash-3.2-24.el5