Archive for the ‘Uncategorized’ Category

Wordpress Auto-Update Script For A Linux Server

Monday, March 16th, 2009

I wrote a little update script for my server to auto update my wordpress installation and figured it might help some other people as well. To use it you simply supply as arguments to the script three things:

1. the directory where your wordpress install lives
2. the name of the backups you’d like to create for that directory
3. the version of the wordpress install you’d like to upgrade to

For example, on my server I use this command to update my wp version:

sudo ./updateWordpress.sh /path/to/wordpress/installation efnx 2.7.1
[enter password]
[watch output]

done!

Here is the code to my script:

#!/bin/bash
DIR2UPDATE=$1
NAME=$2
VERSION=$3

echo "Beginning update of $DIR2UPDATE to version $VERSION..."

if [ -d wordpress_svn ]
then
    day=`date | cut -d" " -f3`
    tme=`date | cut -d" " -f4`
    hour=`echo ${tme} | cut -d":" -f1`

    fileday=`ls -lh | grep wordpress_svn | cut -c 37-39`
    filehour=`ls -lh | grep wordpress_svn | cut -c 40-41`

    if [ ${fileday} != ${day} ]; then
            echo "SVN directory not up to date, [ file's date ${fileday} != today ${day} ] deleting and updating"
        rm -rf wordpress_svn/*
        cd wordpress_svn
            svn co http://svn.automattic.com/wordpress/tags/${VERSION} .
    else
            if [ "$filehour" != "$hour" ]; then
                    echo "SVN directory not up to date, [ file's hour ${filehour} != now ${hour} ] deleting and updating"
                rm -rf wordpress_svn/*
                    cd wordpress_svn
                    svn co http://svn.automattic.com/wordpress/tags/${VERSION} .
        else
                    echo "SVN directory is up to date, skipping update"
                cd wordpress_svn
        fi
    fi

else
    echo "Creating new svn directory and checking out version $VERSION...";
    mkdir wordpress_svn;
    cd wordpress_svn;
    svn co http://svn.automattic.com/wordpress/tags/${VERSION} .;
fi

cd ..

if [ -d wordpress_int ]
then
    echo "Removing old intermediate container...";
    rm -rf wordpress_int;
fi

echo "Creating new intermediate container..."
mkdir wordpress_int
echo "Moving version $VERSION files into intermediate container..."
cp -rpf wordpress_svn/* wordpress_int

echo "Moving config and custom files from $NAME into intermediate container..."

cp -p ${DIR2UPDATE}/wp-config.php wordpress_int
cp -rpf ${DIR2UPDATE}/wp-content/* wordpress_int/wp-content/
cp -p ${DIR2UPDATE}/.htaccess wordpress_int
echo 'Updating svn for wp-content'
svn update wordpress_int

echo "Backing up $DIR2UPDATE..."
mkdir ${NAME}_backup
#mv -f ${DIR2UPDATE}/* ${NAME}_backup   # if you'd like to mv instead of cp
cp -rpf ${DIR2UPDATE}/* ${NAME}_backup
tar -czvf ${NAME}_backup.tar.gz ${NAME}_backup
rm -rf ${NAME}_backup

echo 'Removing svn data from intermediate container...'
rm -rf `find wordpress_int/ -type d -name .svn`
echo "Moving intermediate container contents to $DIR2UPDATE..."
cp -rpf wordpress_int/* ${DIR2UPDATE}

Or you can just download the script here [rightclick + 'save as']->
updateWordpress.sh

My current inactivity.

Tuesday, January 13th, 2009

Hey all, I’ve been visiting my blog less and less these past few months, and as a result I have the lowest traffic rates in over a year. It’s all because of a rather good event. I’ve been recruited by a web firm in San Rafael, CA, called Synapse Group, to develop some undisclosed projects which have been taking all of my development time. When I code flash + web services all day, I hardly feel like spending my waning night hours coding my own flash projects. Rightfully so I’ve taken up more C++. I’ve found solice in OpenFrameworks, a bundle of classes that wrap OpenGL, rtAudio, FreeType, FreeImage and QuickTime together in a “user-friendly” [read: reduced programming headache] format. Earlier last year I found OF, then decided to dive into OpenGL and rtAudio on my own, but now I’ve gone back, why re-invent the wheel?
So, expect some C++ projects to get thrown up here soon. One thing I would really like to do, is get a Flash API-like display list system running in OpenGL. I have a crude working concept of OpenGL, but it suffices to display my 2D musings. Any gurus out there available for pointers? No pun intended.

OLPC Give One, Get One

Sunday, November 16th, 2008

The OLPC [One Laptop Per Child] Foundation is starting their annual Give One Get One campaign on November 17th! Last year I donated a laptop and got mine in the mail a few months later. It’s not the fastest computer, but it’s cute and rugged and novel [did I mention hackable?]. One laptop only costs $199, and I’m sure a lot of you out there are self-employed, which means you can benefit from the write off. You get a tax break and a kid gets a computer. Sweet deal.

OLPC Equation

OLPC Equation

Pure Actionscript 3 Window Class

Thursday, November 13th, 2008

I’ve been working on an easily skinnable windowing system, and this is what I have so far. I’ve attempted to mimic mac’s theme for Leopard.

Actionscript 3 Leopard GUI

Actionscript 3 Leopard GUI

The source and documentation are in their usual spots -> My classes. I’ll be updating them pretty regularly. Here’s the source for the project itself -> project source

You know you’re a programmer if…

Friday, November 7th, 2008

I just stuck “you know you’re a programmer if” into google to see what popped up, who knows, maybe I’m not a real programmer? Looks as if I meet the standards. I’m going to be compiling a list of my favorites:

You know you’re a programmer…

  • when noone understands WTF you’re talking about.
  • when you stop coding to look at the clock and realize it’s Saturday.
  • if your idea of fun is coding something you don’t get paid for.
  • if you have to stay up “just a while longer” to fix ALL the bugs.
  • if you have to remember that when people say “or” they mean “exclusive or”.
  • if you respond faster to email than voicemail.
  • if you use brackets in place of parenthesis [way better, btw].

More to come when I think of them. Feel free to add to this list!

ZendCon 08

Thursday, September 18th, 2008

I just got back from ZendCon 2008 and it was pretty fun. Much more fun than a typical work week. I got to learn a lot about the new features of PHP, some common and not so common security pitfalls and I met a lot of rad programmers. The highlight for me though, was the Yahoo party. Yahoo raffled off a Nintendo Wii, which I happened to win! When I went to pick it up from the rafflers the crowd of PHP developers started shouting “Speech! Speech!” So I stood up on a chair and told them I was an AS3 developer, and they promptly booed me down. I escaped unscathed, with the Wii.

Look at that happy lad! Time to get this thing ready for some homebrew apps.

Blog Activity

Tuesday, July 8th, 2008

Hey guys, I’m not sure who reads this on a regular basis, but I’ve been super swamped with work lately and haven’t had a lot of time [or energy] for my own development. Hopefully I’ll be seeing things clear up soon and I’ll have some new classes and new projects to share with you. Thanks for sticking in there, tiger. In the meantime, here’s a rad video.

First Software Purchased Evar.

Monday, February 4th, 2008

The first piece of [non-game] software I ever purchased was TextMate, just now. I buckled down and bought it. It is flippin sweet. I hope my move to linux finds me an equivalent editor. DORKSAUCE. Ah, I also bought 4GB of RAM for my MacBook for $80 at newegg. That’s almost 10x less than buying 2GB from Apple. They’re not “fully buffered EEC” but 2×2GB @ $36 each? Bomb! > 2×1GB @ $150 each, that’s for sure. I’ll let you know how it goes after installation.

*update*
Macbook Pros (at least my model) only support a max of 3gb of RAM. So I’m full up and have 2gb left over. I’m giving it to my friend Matthew. My mbp’s been running great with the new memory, so it’s all good.

Joa Ebert SpeedCodes a Particle Explosionater [Explodinating the Countryside]

Tuesday, January 15th, 2008

I just like posting vidyos when I’m too lazy to code or write about code.

Rad Video

Thursday, January 10th, 2008

This guy and Paul Roberts would be my dream team to work on a platformer with.