Importing existing SSL key and certificate for tomcat
Fri, 07/25/2008 - 16:50 — sandip- 
 Convert key and cert to a single pkcs12 format.
openssl pkcs12 -export -inkey <pathto>/key.txt -in <pathto>/cert.txt -out cert.pkcs12keytool -delete -alias tomcat -keystore <pathto>/cacertskeytool -importkeystore -destkeystore cacerts -srckeystore cert.pkcs12 -srcstoretype PKCS12keytool -list -keystore <pathto>/cacerts | grep PrivateKeyEntrykeytool -changealias -alias 1 -destalias tomcat -keystore <pathto>/cacertsSimple captcha for oscommerce contact form
Thu, 07/24/2008 - 21:52 — sandipEmbed the captcha image by calling a php script in "contact_us.php":
<input type="text" name="verify" />
<img src="/image.php" width="60" height="20" alt="Please enter the values from this image" />Edit contact_us.php file and exactly after the below line:
  if (isset($HTTP_GET_VARS['acplace the verification code:
     
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbs
    &nbsSupport for 32 bit development libraries on 64 bit CentOS
Fri, 07/18/2008 - 09:45 — sandipTo support C/C++ 32 bit development libraries on CentOS-5.2 x86_64 arch the below devel packages are required:
yum install glibc-devel.i386 libstdc++-devel.i386Below is example output of multilib support for gcc:
$ gcc -print-multi-lib; gcc -print-multi-os-directory; gcc -print-multi-os-directory -m32
.;
32;@m32
../lib64
../libCreate users in OpenVZ Containers
Fri, 07/11/2008 - 00:35 — sandipHelper script to create users on all OpenVZ VEs simultaneously:
#!/bin/bash
# create_ve_users.sh
# Usage: ./create_ve_users.sh <username> <password> <uid> <group1,group2>
USERNAME=$1
PASSWORD=$2
USERID=$3
GROUP=$4
EXPECTED_ARGS=4
OUT_FILE=.create_users_$$
 />
if [ $# -ne $EXPECTED_ARGS ]
then
  echo "Usage: `basename $0` <username> <password> <uid> <group1,group2>"
 />  exit 65
fi
VE_LIST=$(/usr/sbin/vzlist -H -o veid)
for VE in ${VE_LIST}
do
    &nbs
    &nbs
    &nbs
    &nbs
done
exit 0Update OpenVZ containers
Wed, 07/09/2008 - 16:51 — sandipIf you manage several OpenVZ containers, here is a simple bash script to keep the OpenVZ containers upto date.
#!/bin/bash
# vzyum_updates.sh
# updates VEs
VE_LIST=$(/usr/sbin/vzlist -H -o veid | grep -v Warning)
for VE in ${VE_LIST}
do
  /usr/bin/vzyum $VE update
done
exit 0OpenVZ CentOS template cache creation with vzpkgcache
Mon, 07/07/2008 - 23:44 — sandipFollowing the instruction over at OpenVZ Wiki, I've had no problems with the installation and creation of templates prior to CentOS-5.2 on x86_64 systems. However, with the latest set of updates to CentOS-5.2, the vzpkgcache seems to have been broken as sysklogd is no longer being installed by default. Below is how I got it to work:
Note: edit /vz/template/centos/5/x86_64/c
# vzpkgcache -f centos-5-x86_64-minimalwhich gives the below error at the end:
sed: can't read /etc/init.d/syslog: No such file or directory
ERROR: Script install-post failedThe solution was to edit "/vz/template/centos/5/x86_64/
# Disable klogd
$VZCTL exec2 $VEID \
    &nbs
    &nbs
    &nbs
...
# Disable fsync() in syslog
$VZCTL exec2 $VEID \
    &nbs
    &nbsReducing logical volume
Thu, 07/03/2008 - 09:56 — sandipI've had to reduce the logical volume that was alloted for mysql data from 8GB to 4GB, which was a breeze with e2fsadm available for lvm1 on RHEL-3 .
Stop the running serivces using the volume:
# service httpd stop
# service mysqld stope2fsadm will reduce the filesystem and then the logical volume.
# umount /mnt/lv-mysql
# e2fsadm -L -4G /dev/hdb2-vg00/lv-mysql
# mount /mnt/lv-mysqlCheck with df, which should now show the new volume size:
$ df -h /mnt/lv-mysql
Filesystem   
/dev/hdb2-vg00/lv-mysql 4.0G  531M  3.3G  14% /mnt/lv-mysqlStart the running serivces using the volume:
# service httpd start
# service mysqld startNote: e2fsadm is not available in lvm2 and will need to reduce in two steps:
1. Reduce the filesystem residing on the logical volume.
2. Reduce the logical volume.
# resize2fs /dev/vg0/lv0 4G
# lvreduce -L -4G /dev/vg0/lv0ffmpeg with mp3 encoder support on Ubuntu Dapper
Wed, 07/02/2008 - 00:26 — sandipThe default install of ffmpeg on Ubuntu Dapper does not come with support for encoding mp3. I had to get the source and re-compile with mp3 support using lame as the encoder.
Make sure you have multiverse and universe enabled.
$ sudo apt-get build-dep ffmpeg
$ sudo apt-get install liblame-dev libfaad2-dev libfaac-dev libxvidcore4-dev liba52-0.7.4 liba52-0.7.4-dev libx264-dev
$ apt-get source ffmpeg
$ cd ffmpeg-*/
$ ./configure --enable-gpl --enable-pp --enable-pthreads \
    &nbs
    &nbs
    &nbs
$ make
$ sudo make installAPF on CentOS-5 OpenVZ Containers
Tue, 06/24/2008 - 12:00 — sandip- 
 Increase the NUMIPTENT values in VE conf file to 1000 on the host:
NUMIPTENT="1000:1000"IPTABLES="ipt_REJECT ipt_tos ipt_TOS ipt_LOG ip_conntrack ip_conntrack_ftp ip_conntrack_irc ipt_owner ipt_length ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state iptable_nat ip_nat_ftp ipt_recent"Restart the VE
# vzctl restart <VEID>Warning: Unknown iptable module: ipt_recent, skippedYou can verify the modules loaded via:
# vzctl exec <VEID> grep ipt_recent /proc/net/ip_tables_matchesNote: ipt_recent is required for passive ftp to work, else... will need to specify passive ftp ports in ftp conf file and open those ports via apf as well.
Here is a typical apf config on a VE with CentOS-5 running ISPConfig.DEVEL_MODE="0"
IFACE_IN="venet0" 
IFACE_OUT="venet0"
IFACE_TRUSTED=""r />SET_MONOKERN="1"r />IG_TCP_CPORTS="21,22,25
 />IG_UDP_CPORTS="53"
EGF="1"
EG_TCP_CPORTS="21,25,80
EG_UDP_CPORTS="20,21,53Trusting CAS Self-signed Certs
Mon, 06/23/2008 - 11:24 — sandipYales' CAS client attempts to verify the service ticket it received from CAS, and when it tries to connect to the CAS server, it encounters SSL handshake error caused by using a self-signed SSL certificate on the CAS server. The Java process running tomcat does not trust the certificate presented by the CAS server. This is part of Java security.
A work around the issue would be to tell Java to trust the self-signed certificate as below:
# keytool -importcert -trustcacerts -alias {cert_alias_name} -file \
    &nbs
    &nbsUse the below command to list:
$ keytool -list -keystore /usr/local/java/jre/lib/securi