From 2e4f4f95888c4e727d28af39710aa4738c82a50e Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 13 Dec 2023 20:26:41 -0500 Subject: [PATCH] lc --- app/{auto_loader.php => neato_auto_loader.php} | 0 app/neato_common.php | 10 +++++----- ...neato_Configure.php => neato_configure.php} | 2 +- app/neato_enc.php | 2 +- app/neato_fns.php | 8 ++++---- app/{neato_Logger.php => neato_logger.php} | 4 ++-- app/{registry.php => neato_registry.php} | 0 app/utils/mysql.php | 6 +++--- config_files/deploy_example.php | 12 ++++++------ config_files/deploy_mysql_ex1.php | 18 +++++++++--------- config_files/deploy_mysql_ex2.php | 8 ++++---- config_files/deploy_podman.php | 10 +++++----- config_files/deploy_security_audit.php | 8 ++++---- config_files/deploy_test1.php | 6 +++--- make-installer.sh | 16 ++++++++-------- 15 files changed, 55 insertions(+), 55 deletions(-) rename app/{auto_loader.php => neato_auto_loader.php} (100%) rename app/{neato_Configure.php => neato_configure.php} (99%) rename app/{neato_Logger.php => neato_logger.php} (97%) rename app/{registry.php => neato_registry.php} (100%) diff --git a/app/auto_loader.php b/app/neato_auto_loader.php similarity index 100% rename from app/auto_loader.php rename to app/neato_auto_loader.php diff --git a/app/neato_common.php b/app/neato_common.php index 66d82b6..00a60b6 100644 --- a/app/neato_common.php +++ b/app/neato_common.php @@ -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(); diff --git a/app/neato_Configure.php b/app/neato_configure.php similarity index 99% rename from app/neato_Configure.php rename to app/neato_configure.php index 4e3a89a..e24e3f3 100644 --- a/app/neato_Configure.php +++ b/app/neato_configure.php @@ -1,6 +1,6 @@ write($str); } } diff --git a/app/neato_Logger.php b/app/neato_logger.php similarity index 97% rename from app/neato_Logger.php rename to app/neato_logger.php index d3983f2..218e6a7 100644 --- a/app/neato_Logger.php +++ b/app/neato_logger.php @@ -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(); diff --git a/app/registry.php b/app/neato_registry.php similarity index 100% rename from app/registry.php rename to app/neato_registry.php diff --git a/app/utils/mysql.php b/app/utils/mysql.php index b2e1e56..573afea 100644 --- a/app/utils/mysql.php +++ b/app/utils/mysql.php @@ -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'); } } \ No newline at end of file diff --git a/config_files/deploy_example.php b/config_files/deploy_example.php index ea08290..cc0f833 100644 --- a/config_files/deploy_example.php +++ b/config_files/deploy_example.php @@ -1,12 +1,12 @@ 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'); diff --git a/config_files/deploy_mysql_ex1.php b/config_files/deploy_mysql_ex1.php index ad4ef62..ac226a6 100644 --- a/config_files/deploy_mysql_ex1.php +++ b/config_files/deploy_mysql_ex1.php @@ -1,10 +1,10 @@ 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); } diff --git a/config_files/deploy_mysql_ex2.php b/config_files/deploy_mysql_ex2.php index b7c5a64..e3a811d 100644 --- a/config_files/deploy_mysql_ex2.php +++ b/config_files/deploy_mysql_ex2.php @@ -1,14 +1,14 @@ root; //do_command('service', 'mysql', 'start'); diff --git a/config_files/deploy_podman.php b/config_files/deploy_podman.php index bae7c5e..a7ffc12 100644 --- a/config_files/deploy_podman.php +++ b/config_files/deploy_podman.php @@ -1,9 +1,9 @@ ['/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) { diff --git a/config_files/deploy_security_audit.php b/config_files/deploy_security_audit.php index 23195d3..5732cba 100644 --- a/config_files/deploy_security_audit.php +++ b/config_files/deploy_security_audit.php @@ -1,12 +1,12 @@ 'blue'])); -$remove_users = Configure::get('remove_users'); +$remove_users = configure::get('remove_users'); foreach($remove_users as $del_user) { do_command('userdel', $del_user); } diff --git a/config_files/deploy_test1.php b/config_files/deploy_test1.php index 459367b..baab6ed 100644 --- a/config_files/deploy_test1.php +++ b/config_files/deploy_test1.php @@ -1,7 +1,7 @@ $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 \ No newline at end of file