Code

17th January
2010
written by Tom Evans

Here is another script to pull the latest SVN.  This one is for punbb 1.3.  I no longer use this one, but figured I’d share it for those who are interested

#!/bin/sh
 
# Script created 2008-03-27 by Tommy Evans (hostbunch.com) to dump a production database and import it into a test database
# Update 2010-01-17 by Tommy Evans - Added variables
# This is for testing punbb 1.3 and extensions
 
#############################################
###### Configure the below variables ########
#############################################
# The domain in which to copy files from.
SRCDOMAIN="domain.com"
 
# The domain in which to copy files to.
DESTDOMAIN="punbb13.domain.com"
 
#SVN Path
PUNSVN="http://punbb.informer.com/svn/punbb/trunk/"
EXTSVN="http://punbb.informer.com/svn/additions/punbb-1.3/extensions/"
EXTPATH="punbb13.extensions"
 
#The source SQL database
SRCSQL="punsql.domain.com"
SRCUSER="srcuser"
SRCPSSWD="srcpassword"
SRCDB="pundb"
 
#The destination SQL database
DESTSQL="testsql.domain.com"
DESTUSER="destuser"
DESTPSSWD="destpassword"
DESTDB="pundb13"
 
## Modify the below for any custom SQL you wish to add. It will go at the bottom of this script
CUSTOMSQL1="TRUNCATE search_matches;"
CUSTOMSQL2="TRUNCATE search_words;"
#############################################
###### End of configured variables   ########
#############################################
 
echo "Clear old cache direcory"
rm -f ${HOME}/${DESTDOMAIN}/cache/*
 
echo "Get the latest SVN from ${SVN}"
cd ${HOME}/${DESTDOMAIN}
svn up ${SVN} ${HOME}/${DESTDOMAIN}
 
echo "Get latest Extensions from SVN"
svn up ${EXTSVN} ${HOME}/${EXTPATH}
cp -ur ${HOME}/${EXTPATH}/* ${HOME}/${DESTDOMAIN}/extensions
 
echo "Remove install.php"
rm -f ${HOME}/${DESTDOMAIN}/admin/install.php
 
# Abort on any errors
set -e
 
cd ${HOME}
 
echo "clean up ${SRCDB} before the dump"
mysqlcheck --auto-repair -r -s -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} -B ${SRCDB}
 
echo "dump ${SRCDB} to ${DESTDB}"
mysqldump -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} --opt -f -n ${SRCDB} | mysql -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB}
 
echo "Update database custom SQL"
mysql -f -n -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB} -e "${CUSTOMSQL1}${CUSTOMSQL2}${CUSTOMSQL3}${CUSTOMSQL4}${CUSTOMSQL5}${CUSTOMSQL6}${CUSTOMSQL7}"
 
echo "Get the avatars from ${SRCDOMAIN}"
cp -u ${HOME}/${SRCDOMAIN}/img/avatars/* ${HOME}/${DESTDOMAIN}/img/avatars/
 
#move db_update.php and .htaccess
#cp -u ${HOME}/${DESTDOMAIN}/extras/db_update.php ${HOME}/${DESTDOMAIN}/
#cp -u ${HOME}/${DESTDOMAIN}/.htaccess.dist ${HOME}/${DESTDOMAIN}/.htaccess
#cp -u ${HOME}/${DESTDOMAIN}/.htaccess ${HOME}/${DESTDOMAIN}/.htaccess

You’ll need to make sure you add the config.php and edit to for the new database location and base url

<?php
 
$db_type = 'mysqli';
$db_host = 'localhost';
$db_name = 'pun13';
$db_username = 'root';
$db_password = '1234567';
$db_prefix = 'punbb_';
$p_connect = false;
 
$base_url = 'http://localhost';
 
$cookie_name = 'forum_cookie';
$cookie_domain = '';
$cookie_path = '/';
$cookie_secure = 0;
 
define('FORUM', 1);
Tags: , , ,
17th January
2010
written by Tom Evans

This script will pull the latest SVN for FluxBB 1.4.  This script assumes you are running an update from an existing version of fluxbb or punbb.  If you are not, you will need to comment out the line that deletes install.php.

In addition, this also sets all styles back to Oxygen since the new version may not have the styles some users may be using.  Grabs avatars from existing install so they will be visible for test install.  At the end of the script is code to add a redirect to your .htaccess.  This only needs to be added once.  After the first time, you can comment it out.

Run this as a cron job at a schedule you like, and you will have the latest SVN with the latest DB from your live site.

#!/bin/sh
 
# Script created 2008-03-27 by Tommy Evans (hostbunch.com) to dump a production database into a test database
# and grab the latest SVN for project
# Update 2010-01-17 by Tommy Evans - Added variables and path to fluxbb 1.4
 
#############################################
###### Configure the below variables ########
#############################################
# The domain in which to copy files from.
SRCDOMAIN="domain.com"
 
# The domain in which to copy files to.
DESTDOMAIN="fluxbb14.domain.com"
 
#SVN Path
SVN="http://fluxbb.org/svn/fluxbb/trunk/"
 
#The source SQL database
SRCSQL="srcsql.domain.com"
SRCUSER="srcuser"
SRCPSSWD="srcpassword"
SRCDB="punbb"
 
#The destination SQL database
DESTSQL="testdb.domain.com"
DESTUSER="destuser"
DESTPSSWD="despassword"
DESTDB="fluxbb14"
 
STYLE="Oxygen"
## Modify the below for any custom SQL you wish to add. It will go at the bottom of this script
CUSTOMSQL1="UPDATE config SET conf_value = '${STYLE}' WHERE CONVERT(conf_name USING utf8) = 'o_default_style';"
CUSTOMSQL2="UPDATE users set style = '${STYLE}' where CONVERT(style USING utf8) != '${STYLE}';"
CUSTOMSQL3="UPDATE config SET conf_value = 'http://${DESTDOMAIN}/upload' WHERE CONVERT(conf_name USING utf8) = 'o_base_url_alt';"
CUSTOMSQL4="UPDATE config SET conf_value = 'http://${DESTDOMAIN}/upload' WHERE CONVERT(conf_name USING utf8) = 'o_base_url';"
CUSTOMSQL5="TRUNCATE search_cache;"
CUSTOMSQL6="TRUNCATE search_matches;"
CUSTOMSQL7="TRUNCATE search_words;"
#############################################
###### End of configured variables   ########
#############################################
 
echo "Clear old cache direcory"
rm -f ${HOME}/${DESTDOMAIN}/upload/cache/
 
echo "Get the latest SVN from ${SVN}"
cd ${HOME}/${DESTDOMAIN}
svn up ${SVN} ${HOME}/${DESTDOMAIN}
 
echo "Remove install.php assumes you want to run db_update.php"
echo "If that is not the case, comment this line out"
rm -f ${HOME}/${DESTDOMAIN}/upload/install.php
 
# Abort on any errors
set -e
 
cd ${HOME}
 
echo "clean up ${SRCDB} before the dump"
mysqlcheck --auto-repair -r -s -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} -B ${SRCDB}
 
echo "dump ${SRCDB} to ${DESTDB}"
mysqldump -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} --opt -f -n ${SRCDB} | mysql -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB}
 
echo "Update database custom SQL"
mysql -f -n -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB} -e "${CUSTOMSQL1}${CUSTOMSQL2}${CUSTOMSQL3}${CUSTOMSQL4}${CUSTOMSQL5}${CUSTOMSQL6}${CUSTOMSQL7}"
 
echo "Get the avatars from ${SRCDOMAIN}"
cp -u ${HOME}/${SRCDOMAIN}/img/avatars/* ${HOME}/${DESTDOMAIN}/upload/img/avatars/
 
#move db_update.php and .htaccess
#cp -u ${HOME}/${DESTDOMAIN}/extras/db_update.php ${HOME}/${DESTDOMAIN}/upload/
#cp -u ${HOME}/${DESTDOMAIN}/upload/.htaccess.dist ${HOME}/${DESTDOMAIN}/upload/.htaccess
#cp -u ${HOME}/${DESTDOMAIN}/.htaccess ${HOME}/${DESTDOMAIN}/upload/.htaccess
 
#add redirect to upload folder
/usr/local/php5/bin/php -q << EOF
<?php
#file_put_contents("${HOME}/${DESTDOMAIN}/.htaccess", "\n\nRewriteEngine On\nRedirectMatch ^/\$  http://${DESTDOMAIN}/upload", FILE_APPEND);
?>
Tags: , , ,
16th January
2010
written by Tom Evans

I do a lot of code testing before pushing any changes production sites.  This is a script I created to copy files from the production domain to a test domain.  It also copies the production database to another database to ensure you don’t corrupt anything. 

This script is meant to be run via shell, or cron job.

If you get:
-bash: ./filename: /bin/sh^M: bad interpreter: No such file or directory
You will need to run a dos2unix filename via shell before you run it.

#!/bin/sh
 
# Abort on any errors
# set -e
 
# Script created 2010-01-15 by Tommy Evans (hostbunch.com) to dump a production database and import it into a test database
 
#############################################
###### Configure the below variables ########
#############################################
# The domain in which to copy files from.
export SRCDOMAIN="domain.com"
 
# The domain in which to copy files to.
export DESTDOMAIN="test.domain.com"
 
#The source SQL database
export SRCSQL="livesql.domain.com"
export SRCUSER="dbuser"
export SRCPSSWD="userpsswd"
export SRCDB="sitedb"
 
#The destination SQL database
export DESTSQL="testsql.domain.com"
export DESTUSER="testuser"
export DESTPSSWD="testpsswd"
export DESTDB="testdb"
 
## Modify the below for any custom SQL you wish to add. It will go at the bottom of this script
export CUSTOMSQL1="UPDATE config SET conf_value = 'http://${DESTDOMAIN}' WHERE conf_name = 'o_base_url';"
export CUSTOMSQL2="UPDATE config SET conf_value = 'http://${DESTDOMAIN}' WHERE conf_name = 'o_base_url_alt';"
export CUSTOMSQL3="TRUNCATE search_cache;"
export CUSTOMSQL4="TRUNCATE search_matches;"
export CUSTOMSQL5="TRUNCATE search_words;"
#############################################
###### End of configured variables ########
#############################################
 
echo "Delete all listed folders in ${DESTDOMAIN}"
#You can change these folders as you please
cd ${HOME}
mv ${DESTDOMAIN}/config.php ${DESTDOMAIN}/config2.php
mv ${DESTDOMAIN}/.htaccess ${DESTDOMAIN}/keep.htaccess
rm -dfr ${DESTDOMAIN}/attachments
rm -dfr ${DESTDOMAIN}/calendar
rm -dfr ${DESTDOMAIN}/cron
rm -dfr ${DESTDOMAIN}/images
rm -dfr ${DESTDOMAIN}/img
rm -dfr ${DESTDOMAIN}/include
rm -dfr ${DESTDOMAIN}/lang
rm -dfr ${DESTDOMAIN}/log
rm -dfr ${DESTDOMAIN}/plugins
rm -dfr ${DESTDOMAIN}/style
rm -dfr ${DESTDOMAIN}/uploads
rm -dfr ${DESTDOMAIN}/cache
 
echo "Copy listed folders from ${SRCDOMAIN} to ${DESTDOMAIN}"
cp -fR ${SRCDOMAIN}/attachments ${DESTDOMAIN}/attachments
cp -fR ${SRCDOMAIN}/calendar ${DESTDOMAIN}/calendar
cp -fR ${SRCDOMAIN}/cron ${DESTDOMAIN}/cron
cp -fR ${SRCDOMAIN}/images ${DESTDOMAIN}/images
cp -fR ${SRCDOMAIN}/img ${DESTDOMAIN}/img
cp -fR ${SRCDOMAIN}/include ${DESTDOMAIN}/include
cp -fR ${SRCDOMAIN}/lang ${DESTDOMAIN}/lang
cp -fR ${SRCDOMAIN}/log ${DESTDOMAIN}/log
cp -fR ${SRCDOMAIN}/plugins ${DESTDOMAIN}/plugins
cp -fR ${SRCDOMAIN}/style ${DESTDOMAIN}/style
cp -fR ${SRCDOMAIN}/uploads ${DESTDOMAIN}/uploads
 
echo "Create cache folder in ${DESTDOMAIN}"
cd ${HOME}/${DESTDOMAIN}
mkdir cache
chmod 0755 cache
 
echo "Copy all root files from ${SRCDOMAIN} to ${DESTDOMAIN}"
cd ${HOME}
cp -uf ${SRCDOMAIN}/* ${DESTDOMAIN}/
cp -f ${SRCDOMAIN}/.htaccess ${DESTDOMAIN}/.htaccess
 
#remove unneeded files
echo "Removing unneeded root files in ${DESTDOMAIN}"
rm -f ${DESTDOMAIN}/0
rm -f ${DESTDOMAIN}/core
rm -f ${DESTDOMAIN}/Web.config
 
#replace config.php and .htaccess
echo "Renaming saved config.php and .htaccess in ${DESTDOMAIN}"
mv -f ${DESTDOMAIN}/config2.php ${DESTDOMAIN}/config.php
#mv -fv ${DESTDOMAIN}/keep.htaccess ${DESTDOMAIN}/.htaccess
 
#clean up ${SRCDB} before the dump
echo "Cleaning up ${SRCSQL}"
mysqlcheck --auto-repair -s -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} -B ${SRCDB}
 
echo "Dumping ${SRCSQL} to ${DESTSQL}"
#dump ${SRCDB} to ${DESTDB} and a few extra steps to ensure subject on index work
mysqldump -u${SRCUSER} -p${SRCPSSWD} -h ${SRCSQL} --opt -f -n ${SRCDB} | mysql -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB}
 
echo "Updating ${DESTSQL} with new URL info and truncating search tables"
 
### Custom SQL is here
mysql -f -n -u${DESTUSER} -p${DESTPSSWD} -h ${DESTSQL} -D ${DESTDB} -e "${CUSTOMSQL1}${CUSTOMSQL2}${CUSTOMSQL3}${CUSTOMSQL4}${CUSTOMSQL5}"
Tags: , ,
10th January
2006
written by Tom Evans

I created Havoc Offroad using php-Nuke with phpbb and for a few months I enjoyed how it performed.  As the community grew and members began to expect more from the site it became too much to keep the code patched and the mods coming.  So, I looked for an alternative to phpbb and found punbb.

I was going to redesign the site so it would be driven from the forum but have a main homepage with a calendar and news link that was automatically pulled from the forum.  Well…I was very pleased to find phpfrontpage which is a modded punbb (link can be found in punbb forum) that is exactly what I was planning on coding…so now I’m very happy because it would have taken me a few months to do it all…and now it’s all there.

I used the punbb converter and imported my database from Havoc and then I ran the punbb1.2tophpfrontpage (file name is something like that).  Now it’s all there and a guy off punres.org is helping me by writing a converter for the attachment mod to get the images that were uploaded with phpbb attach mod.

Update 6/29/2006: Site’s been up @ http://www.havocoffroad.com for several months now.  The group over there didn’t really like the changes because they were so drastic and they had to adjust to new links and locate different things. They’ve gotten used to the new design now though…and I believe they are enjoying it, but of course there are always places to improve.  I was able to convert all the attachments from phpbb to punbb using a script that frank H. from punbb gave me.  It took a lot of changes but without his original script I would never have gotten it.

old version: http://v1.havocoffroad.com
new version: http://www.havocoffroad.com
test version: http://test.havocoffroad.com

Tags: ,