All pastes #110581 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-08-01 19:41 UTC
rendered paste body
#!/usr/bin/perl
################################################################################
########################LICENSE#################################################
################################################################################
#Auto PHP Checkout Script
#Copyright (C) 2006  Christopher Hotchkiss chotchki@mail.usf.edu
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#################################################################################
# You can also view the GPL Online at http://www.gnu.org/licenses/gpl.txt
##################################################################################

##################################################################################
######################INSTALLATION################################################
##################################################################################
#Please put this script into the hooks/ directory of your svn repository and
#make it executable by running "chmod +x post-commit" on it
#
#If you want the email summary to be sent make sure you install the Mail::Sendmail
#CPAN module
##################################################################################

use strict;
use warnings;
use POSIX qw(setsid);
use Mail::Sendmail;

##################################################################################
######################CONFIGURATION###############################################
##################################################################################
#Change the settings below for your environment
##################################################################################
#The checkout location for the code
my $webdir = "/var/www/test";
#Person to recieve a summary email
my $emailaddr = "someone\@example.com"
#Location of the subversion repository (must use subverison syntax)
my $repoaddr = "file:///var/lib/svn/mmarket/trunk"
##################################################################################

##################################################################################
##########################PROGRAM CODE############################################
##################################################################################
#Daemonize so that svn doesn't timeout during a large checkout
chdir('/') or die "Can't chdir to /: $!";
umask 0;
open(STDIN, '/dev/null')   or die "Can't read /dev/null: $!";
open(STDOUT, '>/dev/null') or die "Can't write to /dev/null: $!";
open(STDERR, '>/dev/null') or die "Can't write to /dev/null: $!";
defined(my $pid = fork)   or die "Can't fork: $!";
exit if $pid;
setsid                    or die "Can't start a new session: $!";
#Everything after this is a daemonized program

#Start building the summary email
my $email = "Here is the output for the latest svn checkout \n\n\n";

#Clear out the temp directories so that svn does complain
$email .= `rm -vrf $webdir`;
$email .= "\n\n\n";

#Export the subversion code to the checkout directory
$email .= `svn export $repoaddr $webdir`;
$email .= "\n\n\n";
##################################################################################

##################################################################################
##########################OPTIONAL STEPS##########################################
##################################################################################
#This next part is where you put any code that needs to be run before the program
#is considered to be fully deployed. I am including my steps as an example, yours
#will probably be very different, you have been warned!!!!
##################################################################################

#Rebuild the php cache autoload
#chdir($webdir);
#$email .= `$webdir/symfony.sh cc frontend config`;
#$email .= "\n\n\n";

#Load the database
#chdir("$webdir/batch");
#$email .= `php load_data.php`;
#$email .= "\n\n\n";

#Reload apache if php accelerators are installed (requires extra sudo setup)
#`sudo /etc/init.d/apache2 start`;

#Run the javascript build files
#chdir("$webdir/build");
#$email .= `phing -f ajax.xml ajax`;
#$email .= "\n\n\n";
##################################################################################

##################################################################################
##########################EMAIL OUTPUT############################################
##################################################################################
#Send the command output
my %mail = ( 
	To => $emailaddr,
	From => 'root',
	Message => $email
	);
sendmail(%mail)or die $Mail::Sendmail::error;
print "OK. Log says:\n", $Mail::Sendmail::log;
##################################################################################