Robert 2 years ago
parent 8ee3f9d607
commit cb9f9299d7
  1. 4
      app/neato_common.php
  2. 4
      app/neato_fns.php
  3. 8
      app/utils/npm.php
  4. 8
      config_files/deploy_mysql_ex1.php
  5. 14
      config_files/deploy_mysql_ex2.php
  6. 12
      config_files/deploy_test1.php

@ -91,9 +91,9 @@ function ln($source, $new_link) {
return $exit_code;
}
function make_dir($new_folder) {
function make_dir($new_folder, $perms=0775) {
if (!is_dir($new_folder)) {
$exit_code = mkdir($new_folder, 0775, true);
$exit_code = mkdir($new_folder, $perms, true);
check_for_error($exit_code, "Unable to mkdir: {$new_folder}");
return $exit_code;
} else {

@ -48,9 +48,9 @@ function get_perms($kind): int {
// return $kind;
// }
switch ($kind) {
case 'keydir': $perm = 700;
case 'keydir': $perm = 0700;
break;
case 'dir': $perm = 775;
case 'dir': $perm = 0775;
break;
case 'web':
case 'normal':

@ -5,21 +5,21 @@ namespace utils;
class npm {
public static function install($program) {
exec(\neato::get_user_bin . 'npm install -g ' . safe_cmd($program), $output, $exit_code);
exec(\neato::get_user_local_bin . 'npm install -g ' . safe_cmd($program), $output, $exit_code);
display($output);
check_for_error($exit_code, "Unable to run npm install command: {$program}");
return $exit_code;
}
public static function uninstall($program) {
exec(\neato::get_user_bin . 'npm uninstall ' . safe_cmd($program), $output, $exit_code);
exec(\neato::get_user_local_bin . 'npm uninstall ' . safe_cmd($program), $output, $exit_code);
display($output);
check_for_error($exit_code, "Unable to run npm uninstall command: {$program}");
return $exit_code;
}
public static function is_package_installed_globally($program, $display = false) {
exec(\neato::get_user_bin . 'npm list -g ' . safe_cmd($program), $output, $exit_code);
exec(\neato::get_user_local_bin . 'npm list -g ' . safe_cmd($program), $output, $exit_code);
if ($display === true) {
check_for_error($exit_code, "npm package not installed: {$program}");
}
@ -27,7 +27,7 @@ class npm {
}
public static function update($program) {
exec(\neato::get_user_bin . 'npm update -g ' . safe_cmd($program), $output, $exit_code);
exec(\neato::get_user_local_bin . 'npm update -g ' . safe_cmd($program), $output, $exit_code);
display($output);
check_for_error($exit_code, "Unable to run npm update command: {$program}");
return $exit_code;

@ -4,12 +4,10 @@ Configure::set('logfile', true); // Save to log folder
Configure::set('syslog', false);
Configure::set('passwords', ['length' => rand(16, 26)]);
$root_password = make_password(Configure::get('passwords', 'length'));
Configure::set('pre_actions', [
'make_dir' => [$cwd . '/my_vaults'=>'', '/etc/neato_secrets'=>''],
'chmod_file_or_dir' =>
[ $cwd . '/my_vaults' => 'secret', '/etc/neato_secrets' => 'secret' ],
[ $cwd . '/my_vaults' => 'keydir', '/etc/neato_secrets' => 'keydir' ],
]);
//do_command('service', 'mysql', 'stop');
@ -20,9 +18,13 @@ file_loop(Configure::get('pre_actions'));
$my_key = Enc::make_key_file("/etc/neato_secrets/mysql_data");
if (!file_exists($cwd . "/my_vaults/my_secrets")) {
$root_password = make_password(Configure::get('passwords', 'length'));
$obj = new stdClass();
$obj->root = $root_password;
Enc::encode_file($cwd . "/my_vaults/my_secrets", $obj, $my_key);
}
//$my_key = read_file("/etc/neato_secrets/mysql_data");
//$o = Enc::decode_file($cwd . "/my_vaults/my_secrets", $my_key);

@ -0,0 +1,14 @@
<?php
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_data");
$o = Enc::decode_file($cwd . "/my_vaults/my_secrets", $my_key);
echo $o->root;
//do_command('service', 'mysql', 'start');

@ -5,15 +5,19 @@ Configure::set('syslog', false);
//do_command('apache::ht_password', 'my.htpasswd', 'johnny', 'shhhh');
$status = do_command('php::query_module', 'gd', '8.0', 'apache2');
$status = do_command('php::query_module', 'gd', '8.2', 'apache2');
echo ($status == 0) ? 'PHP found module gd' : 'gd not found as module for PHP';
//$n = do_command('npm::is_package_installed_globally', 'gulp-cli');
//echo ($n == 0) ? 'Found npm package Gulp-cli' : 'npm package gulp-cli not found';
echo ".\r\n";
$n = do_command('npm::is_package_installed_globally', 'gulp-cli');
echo ($n == 0) ? 'Found npm package Gulp-cli' : 'npm package gulp-cli not found';
echo ".\r\n";
print_r(do_command('ufw::status'));
$ok = use_me('wget');
if ($ok !== false) {
do_command('wget::download', 'test.html', 'http://127.0.0.1/index.php');
//do_command('wget::download', 'test.html', 'http://127.0.0.1/index.php');
}

Loading…
Cancel
Save