Created
August 19, 2014 14:07
-
-
Save Tahvok/b57586c3b6a557ce11e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set("log_errors", 1); | |
ini_set("error_log", "php.log"); | |
error_reporting(E_ALL); | |
$postdata = file_get_contents("php://input"); | |
try{ | |
if ( $postdata ){ | |
if( $hookArray = json_decode( $postdata ) ){ | |
$splitRef= preg_split("/[\/]+/", $hookArray->ref); | |
if( ( $branch = escapeshellarg(array_pop( $splitRef )) ) != "heads" ){ | |
ob_start(); | |
var_dump($postdata); | |
var_dump($branch); | |
$result = ob_get_clean(); | |
file_put_contents('header_content.txt', $result); | |
exec("sudo -u puppet /usr/local/bin/r10k deploy environment $branch -p 2> /var/www/html/shell.log &"); | |
} | |
else { | |
throw new Exception("branch variable is not set or equals to 'heads'"); | |
} | |
} | |
else | |
{ | |
throw new Exception("An error was encountered while attempting to json_decode the \$postdata"); | |
} | |
} | |
else{ | |
throw new Exception("HTTP_RAW_POST_DATA is not set or 'ref' is not a valid array element"); | |
} | |
} catch (Exception $e) { | |
error_log( sprintf( "%s >> %s", date('Y-m-d H:i:s'), $e ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment