Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Checkout & deploy from SVN to local path, in PHP (GPLv2)
$svn_address = "https://domain/";
$svn_user = "foo";
$svn_user = "foopass";
$web_path = "/var/www/foo.com/public_html/";
$temp_path = "/data/tmp/";
$backup_path = $path . "/data/backup/";
// Checkout SVN
$svn_command = "svn export " . $svn_address . " " . $temp_path "/ --username=" . $svn_user . " --password=";
echo $svn_command . "<br />";
$svn_output = system( $svn_command . $svn_user . " 2>&1" );
echo $svn_output;
echo "Checkout SVN complete<br /><br />";
// Create backup in semi-unique folder
$backup_command = "mv " . $web_path . " " . $backup_path . "/" . time();
echo $backup_command . "<br />";
echo system( $backup_command . " 2>&1" );
echo "Create backup complete<br /><br />";
// Deploy checkout to web server
$move_command = "mv " . $temp_path . " " . $web_path;
echo $move_command . "<br />";
echo system( $move_command . " 2>&1");
echo "Deploy checkout to web server complete<br /><br />";
// Apply permissions
$result = chmod( $web_path. 'uploads/', 0774 );
if ( $result == 1 ) {
echo "chmod " . $web_path. "uploads/, 0774 (octal val)<br />";
echo "Apply permissions complete<br /><br />";
} else {
echo "Apply permissions Error: " . $web_path. "uploads/, 0774 (octal val)<br />";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment