Robert 2 years ago
parent ece03017fa
commit 2e4f4f9588
  1. 0
      app/neato_auto_loader.php
  2. 10
      app/neato_common.php
  3. 2
      app/neato_configure.php
  4. 2
      app/neato_enc.php
  5. 8
      app/neato_fns.php
  6. 4
      app/neato_logger.php
  7. 0
      app/neato_registry.php
  8. 6
      app/utils/mysql.php
  9. 12
      config_files/deploy_example.php
  10. 18
      config_files/deploy_mysql_ex1.php
  11. 8
      config_files/deploy_mysql_ex2.php
  12. 10
      config_files/deploy_podman.php
  13. 8
      config_files/deploy_security_audit.php
  14. 6
      config_files/deploy_test1.php
  15. 16
      make-installer.sh

@ -2,16 +2,16 @@
set_time_limit(0);
require 'registry.php';
require 'auto_loader.php';
require 'neato_registry.php';
require 'neato_auto_loader.php';
require 'neato_init.php';
include 'neato_colors.php';
require 'neato_Configure.php';
require 'neato_Logger.php';
require 'neato_configure.php';
require 'neato_logger.php';
require 'neato_fns.php';
require 'neato_enc.php';
Configure::set('logger_time_zone', 'America/Detroit');
configure::set('logger_time_zone', 'America/Detroit');
registry::set('loader', new \Psr4AutoloaderClass);
registry::get('loader')->register();

@ -1,6 +1,6 @@
<?php
final class Configure {
final class configure {
private static $config = array();
protected function __construct() { }

@ -1,6 +1,6 @@
<?php
class Enc {
class enc {
public static function safe_encrypt(string $message, string $my_key = "") {
$nonce = "";

@ -15,18 +15,18 @@ function display($data) {
if (empty($str)) {
return false;
}
if (Configure::get('display')) {
if (configure::get('display')) {
echo $str . PHP_EOL;
}
if (Configure::get('syslog')) {
if (configure::get('syslog')) {
$access = date("Y/m/d H:i:s");
syslog(LOG_INFO, $access . " " . $str);
}
if (Configure::get('logfile')) {
if (configure::get('logfile')) {
$config_file = (defined('CONFIG_FILE')) ? '_' . CONFIG_FILE : '';
$logger = new Logger('neatoInstaller' . $config_file);
$logger = new logger('neatoInstaller' . $config_file);
$logger->write($str);
}
}

@ -2,7 +2,7 @@
define('PROJECT_LOGS_DIR', $cwd. '/log');
class Logger {
class logger {
private $handle;
@ -85,7 +85,7 @@ class Logger {
if ( $this->handle === false || ! is_resource($this->handle) ) {
return false;
}
$tz = Configure::get('logger_time_zone');
$tz = configure::get('logger_time_zone');
if ($tz !== false && !empty($tz)) {
$tz_obj = new \DateTimeZone($tz);
$dt = new \DateTime();

@ -25,7 +25,7 @@ class mysql {
$dsn = "{$what} -u {$user} -p{$password}";
exec(\neato::get_user_bin . 'mysqldump '. safe_cmd_quotes($dsn) . ' | gzip > $(date +\%Y_\%m_\%d-\%T)'. safe_cmd($file) . '.sql.gz', $output, $exit_code);
display($output);
check_for_error($exit_code, "Unable to Import MySQL file: {$file}");
check_for_error($exit_code, "Unable to Export MySQL file: {$file}");
return $exit_code;
}
@ -36,8 +36,8 @@ class mysql {
return $exit_code;
}
public static function remove_old($path = '') {
exec(\neato::get_user_bin . 'find ' . $path . ' -name "*.gz" -mtime +10 -delete');
public static function remove_old($path = '', int $days_old = 10) {
exec(\neato::get_user_bin . 'find ' . $path . ' -name "*.gz" -mtime +'.$days_old.' -delete');
}
}

@ -1,12 +1,12 @@
<?php
Configure::set('display', true); // Show Output
Configure::set('logfile', true); // Save to log folder
Configure::set('syslog', false);
Configure::set('passwords', ['length' => rand(16, 26)]);
configure::set('display', true); // Show Output
configure::set('logfile', true); // Save to log folder
configure::set('syslog', false);
configure::set('passwords', ['length' => rand(16, 26)]);
$templates_dir = $cwd . '/templates/' . $os['name'] . '/';
Configure::set('preinstall', [
configure::set('preinstall', [
'cp' => [ 'neato.php' => 'cool.junk', 'cool.junk' => 'more.junk', '/home/bob/Documents/Servers/ha.conf' => 'test.ini' ],
'mv' => [ 'more.junk' => 'mmm.junk' ],
'rm' => [ 'cool.junk' ],
@ -17,7 +17,7 @@ force_normal();
//run_once(); // only allow, this script, to run once!
$root_password = make_password(Configure::get('passwords', 'length'));
$root_password = make_password(configure::get('passwords', 'length'));
//do_command('service', 'mysql', 'stop');

@ -1,10 +1,10 @@
<?php
Configure::set('display', true); // Show Output
Configure::set('logfile', false); // Save to log folder
Configure::set('syslog', false);
Configure::set('passwords', ['length' => rand(16, 26)]);
configure::set('display', true); // Show Output
configure::set('logfile', false); // Save to log folder
configure::set('syslog', false);
configure::set('passwords', ['length' => rand(16, 26)]);
Configure::set('pre_actions', [
configure::set('pre_actions', [
'make_dir' => [$cwd . '/my_vaults'=>'', '/etc/neato_secrets'=>''],
'chmod_file_or_dir' =>
[ $cwd . '/my_vaults' => 'keydir', '/etc/neato_secrets' => 'keydir' ],
@ -14,15 +14,15 @@ force_root();
//do_command('service', 'mysql', 'stop');
file_loop(Configure::get('pre_actions'));
file_loop(configure::get('pre_actions'));
$my_key = Enc::make_key_file("/etc/neato_secrets/mysql_key");
$my_key = enc::make_key_file("/etc/neato_secrets/mysql_key");
if (!file_exists($cwd . "/my_vaults/mysql_secrets")) {
$root_password = make_password(Configure::get('passwords', 'length'));
$root_password = make_password(configure::get('passwords', 'length'));
$obj = new stdClass();
$obj->root = $root_password;
Enc::encode_file($cwd . "/my_vaults/mysql_secrets", $obj, $my_key);
enc::encode_file($cwd . "/my_vaults/mysql_secrets", $obj, $my_key);
}

@ -1,14 +1,14 @@
<?php
Configure::set('display', true); // Show Output
Configure::set('logfile', true); // Save to log folder
Configure::set('syslog', false);
configure::set('display', true); // Show Output
configure::set('logfile', true); // Save to log folder
configure::set('syslog', false);
//do_command('service', 'mysql', 'stop');
force_root();
$my_key = read_file("/etc/neato_secrets/mysql_key");
$o = Enc::decode_file($cwd . "/my_vaults/mysql_secrets", $my_key);
$o = enc::decode_file($cwd . "/my_vaults/mysql_secrets", $my_key);
echo $o->root;
//do_command('service', 'mysql', 'start');

@ -1,9 +1,9 @@
<?php
Configure::set('display', true); // Show Output
Configure::set('logfile', false); // Save to log folder
Configure::set('syslog', false);
configure::set('display', true); // Show Output
configure::set('logfile', false); // Save to log folder
configure::set('syslog', false);
Configure::set('pre_actions', [
configure::set('pre_actions', [
'make_dir' => ['/etc/containers'=>''],
'chmod_file_or_dir' =>
['/etc/containers' => 'dir'],
@ -11,7 +11,7 @@ Configure::set('pre_actions', [
force_root();
file_loop(Configure::get('pre_actions'));
file_loop(configure::get('pre_actions'));
$is_podman_installed = do_command('is_installed', "podman");
if ($is_podman_installed['installed'] === false) {

@ -1,12 +1,12 @@
<?php
Configure::set('display', true);
Configure::set('logfile', true);
configure::set('display', true);
configure::set('logfile', true);
$options = cgetopt(["updates"]);
$updates = $options['updates'] ?? "no";
Configure::set('remove_users', [
configure::set('remove_users', [
'shutdown', 'halt', 'games', 'operator',
'ftp', 'news', 'gopher',
]);
@ -14,7 +14,7 @@ Configure::set('remove_users', [
force_root();
display(getTermColors("Deleteing unused user accounts", ['color'=>'blue']));
$remove_users = Configure::get('remove_users');
$remove_users = configure::get('remove_users');
foreach($remove_users as $del_user) {
do_command('userdel', $del_user);
}

@ -1,7 +1,7 @@
<?php
Configure::set('display', true); // Show Output
Configure::set('logfile', false); // Save to log folder
Configure::set('syslog', false);
configure::set('display', true); // Show Output
configure::set('logfile', false); // Save to log folder
configure::set('syslog', false);
//do_command('apache::ht_password', 'my.htpasswd', 'johnny', 'shhhh');

@ -2,20 +2,20 @@
pushd build
/usr/bin/php -c neato_php_cli_phar.ini -f compile-phar.php
chmod +x install_neato.sh
/usr/bin/chmod +x install_neato.sh
TAR_FILE=neato_deploy.tar.gz
tar -czvf $TAR_FILE install_neato.sh make-sums.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../config_files/deploy_*.php
/usr/bin/tar -czvf $TAR_FILE install_neato.sh make-sums.sh neatoDeploy.phar neato_deploy_php_cli.ini neato_deploy.sh ../config_files/deploy_*.php
EXIT_COMMAND="./install_neato.sh"
SELF_EXTRACTABLE="$TAR_FILE.self"
echo '#!/bin/bash' > $SELF_EXTRACTABLE
echo 'dd bs=1 skip=`head -3 $0 | wc -c` if=$0 | gunzip -c | tar -x' >> $SELF_EXTRACTABLE
echo "$EXIT_COMMAND; exit" >> $SELF_EXTRACTABLE
/usr/bin/echo '#!/bin/bash' > $SELF_EXTRACTABLE
/usr/bin/echo 'dd bs=1 skip=`head -3 $0 | wc -c` if=$0 | gunzip -c | tar -x' >> $SELF_EXTRACTABLE
/usr/bin/echo "$EXIT_COMMAND; exit" >> $SELF_EXTRACTABLE
cat $TAR_FILE >> $SELF_EXTRACTABLE
chmod a+x $SELF_EXTRACTABLE
mv $SELF_EXTRACTABLE ..
/usr/bin/cat $TAR_FILE >> $SELF_EXTRACTABLE
/usr/bin/chmod a+x $SELF_EXTRACTABLE
/usr/bin/mv $SELF_EXTRACTABLE ..
popd
Loading…
Cancel
Save