You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
2.8 KiB
101 lines
2.8 KiB
<?php
|
|
|
|
ini_set('display_errors', 1);
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
$cwd = getcwd();
|
|
|
|
$pk = "@ghsP4JAuhCUxEGpk2y;mP"; // XOR for sha256sum, CHANGE ME!!
|
|
|
|
if (!isset($argv[1])) {
|
|
echo 'Please give Script to run, example: neatoDeploy apache' . PHP_EOL;
|
|
echo "Note: deploy_ is added to the beginning of the filename and .php is added to the end!" . PHP_EOL;
|
|
echo "Also, the deployment file must be in the same path if local file." . PHP_EOL;
|
|
echo "Insecure: you may pass a http web site text file: IE http://mysite.com/apache.txt" . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
define('CONFIG_FILE', basename($argv[1]) );
|
|
|
|
require "neato_common.php";
|
|
|
|
if (! isset($os['id'])) {
|
|
echo 'Unknown OS';
|
|
exit(1);
|
|
}
|
|
|
|
if ($os_like == 'debian') {
|
|
putenv("DEBIAN_FRONTEND=noninteractive");
|
|
}
|
|
|
|
require 'OS/neato_' . ucfirst($os['id']) . '.php';
|
|
|
|
$auto = (in_array('-y', $argv)) ? true : false;
|
|
$mark = (in_array('-marksafe', $argv)) ? true : false;
|
|
$file = $argv[1];
|
|
|
|
if (is_string_found($argv[1], 'http://') || is_string_found($argv[1], 'https://')) {
|
|
if ( isset($argv[2]) && $argv[2] !== "-y" ) {
|
|
$file = $argv[2];
|
|
} else {
|
|
$pos = strrpos($argv[1], '/');
|
|
$file = substr($argv[1], $pos + 1);
|
|
$file = str_replace(".txt", "", $file);
|
|
}
|
|
\utils\curl::save($argv[1], "deploy_{$file}.php");
|
|
}
|
|
|
|
function save_sha($shasum) {
|
|
$xor = xor_encrypt($shasum, $GLOBALS['pk']);
|
|
file_put_contents($GLOBALS['cwd'] . '/deploy_' . $GLOBALS['file'].'.sum', $xor);
|
|
}
|
|
|
|
function do_harm_checker($shasum) {
|
|
require 'neato_danger_checker.php';
|
|
if ( is_file_dangerious($GLOBALS['cwd'] . '/deploy_' . $GLOBALS['file'].'.php') ) {
|
|
if (! $GLOBALS['auto']) {
|
|
$answer = readline("Do you wish to execute this Script, anyways!! ? ");
|
|
if ( strtolower( trim($answer) ) === "yes" ) {
|
|
echo "Okay...!" . PHP_EOL;
|
|
} else {
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Keep as last lines */
|
|
if (file_exists($cwd . '/deploy_' . $file.'.php')) {
|
|
$check_for_harm = true;
|
|
$shasum = shasum($cwd . '/deploy_' . $file.'.php');
|
|
if ($shasum === false) {
|
|
echo "Unable to SHA sum script!";
|
|
exit(1);
|
|
}
|
|
|
|
if (file_exists($cwd . '/deploy_' . $file.'.sum')) {
|
|
$sum = read_file($cwd . '/deploy_' . $file.'.sum');
|
|
if ($shasum === xor_encrypt($sum, $pk)) {
|
|
$check_for_harm = false;
|
|
} else {
|
|
echo "Danger: SUM of Script has been modified!";
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
if ($mark) {
|
|
save_sha($shasum);
|
|
}
|
|
|
|
if ($check_for_harm) {
|
|
do_harm_checker($shasum);
|
|
}
|
|
|
|
require($cwd . '/deploy_' . $file.'.php');
|
|
} else {
|
|
echo 'PHP Script deploy_'. $file . '.php does not exist!!' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
echo PHP_EOL; |