PHPBuilder - The Power of CVS Page 3



RSS Twitter
Articles Site Operation

The Power of CVS - Page 3

by: Tim Perdue
|
July 30, 2000

Now I want to blow out my local directory and start checking out from the tree (back up first).
[tperdue@db www.phpbuilder.com] $ cd ..
[tperdue@db docs] $ rm -rf www.phpbuilder.com
[tperdue@db docs] $ cvs -d :pserver:cvs@mybox.com:/fireball/cvs checkout www.phpbuilder.com
Now the tree is recreated on my local drive and I can begin editing and committing changes. I want to create a 1.0 version of the entire site and commit that to the tree. I no longer have to use the -d option, since the server info is stored within my local tree.
[tperdue@db docs] $ cd www.phpbuilder.com
[tperdue@db www.phpbuilder.com] $ cvs update   #not really necessary here
[tperdue@db www.phpbuilder.com] $ cvs commit -r 1.0
Now if you make changes, commit them, and then regret it, you can always come back to version 1.0.
[tperdue@db www.phpbuilder.com] $ cvs update -r 1.0 #or use "cvs checkout -r 1.0"
How's that for cool? You're all set up, and you even have the building blocks to allow multiple developers to work safely against the same cvs tree.
Updating the web server
Now what if you want to automate the updating of your website? I wrote a script that does this. Once you have committed all of your code and you're confident that everything works fine, you can run a script to automate the process.
First, of course you need to know where the DOCUMENT_ROOT of your server is. Mine is at: /fireball/share/www.phpbuilder.com/. I then created a directory next to share, called share-update. I keep a checked-out version of my site in that directory.
[tperdue@mybox www.phpbuilder.com] $ mkdir /fireball/share-update/
[tperdue@mybox www.phpbuilder.com] $ cd /fireball/share-update/
[tperdue@mybox share-update] $ cvs -d /fireball/cvs checkout www.phpbuilder.com
So now I have a directory on my webserver that is similar to my "real" web server directory, and I can update it using CVS, then move it over to the live server directory.
#!/bin/sh
#
#    go to the update directory
#
cd /fireball/share-update/www.phpbuilder.com/
#
#    use CVS to update that directory with the latest code
#
cvs update
#
#    clear out the "real" web server directory
#
rm -rf /fireball/share/www.phpbuilder.com/*
#
#    move the updated files over to the "real" web server directory
#
cp -R /fireball/share-update/www.phpbuilder.com/* /fireball/share/www.phpbuilder.com/
#
#    go to the live web server directory
#
cd /fireball/share/www.phpbuilder.com/
#
#    recursively delete all the directories called CVS
#
find . -type d -name CVS -exec rm -fr {} \;
#
#    make sure it's all readable by the server
#
chmod -R 755 *

« Previous Page
1
|
2
|
3
|
4
Next Page »

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Tim Perdue

Comment:



Comment:

(Maximum characters: 1200). You have characters left.