Sunday, April 8, 2012

Continuous Integration environment with svn on linux

On my previous post I wrote a way I used to create a CI environment that'd export the entire application to a web location after each commit. I was working then for windows. Now, I have created a setup for Linux - with addition this time the post-commit will only update those files that are actually committed. Following is the post-commit script I got on Stackoverflow:
#!/bin/sh
REPOS="$1"
REV="$2"
# A - Item added to repository
# D - Item deleted from repository
# U - File contents changed
# _U - Properties of item changed; note the leading underscore
# UU - File contents and properties changed
# Files and directories can be distinguished, as directory paths are displayed with a trailing "/" character.
LOOK=/usr/local/svn/bin/svnlook
SVN=/usr/local/svn/bin/svn
DEV=/var/www/test
cd /location/to/your/svnrepo
for changes in `$LOOK changed $REPOS | awk '{print $1 "=" $2;}'`;
do
len=${#changes}
idx=`expr index "$changes" =`;
directory=${changes:$idx};
action=${changes:0:$idx-1};
if [ ${changes:len-1} = '/' ]
then
case "$action" in
"A" ) \
mkdir --mode=775 -p $DEV/$directory;
chown nobody:nobody $DEV/$directory;
chmod 775 $DEV/$directory;
;;
"D" ) \
rmdir $DEV/$directory;
;;
esac
else
case "$action" in
"A"|"U"|"UU" ) \
$SVN export --force --non-interactive -r HEAD -q file://$REPOS/$directory;
BASE=`basename $directory`;
DIR=`dirname $directory`;
chown nobody:nobody $BASE;
chmod 775 $BASE;
mkdir --mode=775 -p $DEV/$DIR;
cp -f --preserve=ownership $BASE $DEV/$DIR;
unlink $BASE;
;;
"D" ) \
rm -f $DEV/$directory;
;;
esac
fi
done
exit 0

Reference:

Friday, April 6, 2012

php redirect losing sessions on Chrome/IE issue resolved

My new CodeIgniter app was working beautifully locally - everything's just fine. But when I uploaded to the demo location online - I found I can't login !! After debugging it is discovered - after checking the user credentials and setting the sessions when I was redirecting to the dashboard the user- session was getting lost !
Started with googling for a while and following is the link I got people were suggesting couple of fixes :

Unfortunately, this din solve my issue. I was still getting lost sessions. And finally, [I don remember where I saw someone was suggesting to check the server time] I checked my server time and yes, it was certainly not right - around 5 hours late from the time as it was supposed to be. Fixed the time with the following command [as it was a linux box] :
date +%T -s "10:13:13"
Then, tried login again and bingo - it is working cool.

Reference:
  1. Linux commands to set dates and time