asible create added
This commit is contained in:
@@ -25,6 +25,28 @@ class Database extends Config
|
|||||||
* @var array<string, mixed>
|
* @var array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public array $default = [
|
public array $default = [
|
||||||
|
'DSN' => '',
|
||||||
|
'hostname' => '10.20.30.60',
|
||||||
|
'username' => 'merms_panel',
|
||||||
|
'password' => 'merms_panel',
|
||||||
|
'database' => 'merms_panel',
|
||||||
|
'schema' => 'public',
|
||||||
|
'DBDriver' => 'Postgre',
|
||||||
|
'DBPrefix' => '',
|
||||||
|
'pConnect' => false,
|
||||||
|
'DBDebug' => true,
|
||||||
|
'charset' => 'utf8',
|
||||||
|
'swapPre' => '',
|
||||||
|
'failover' => [],
|
||||||
|
'port' => 5432,
|
||||||
|
'dateFormat' => [
|
||||||
|
'date' => 'Y-m-d',
|
||||||
|
'datetime' => 'Y-m-d H:i:s',
|
||||||
|
'time' => 'H:i:s',
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
public array $default_old = [
|
||||||
'DSN' => '',
|
'DSN' => '',
|
||||||
'hostname' => 'localhost',
|
'hostname' => 'localhost',
|
||||||
'username' => '',
|
'username' => '',
|
||||||
|
|||||||
@@ -6,3 +6,5 @@ use CodeIgniter\Router\RouteCollection;
|
|||||||
* @var RouteCollection $routes
|
* @var RouteCollection $routes
|
||||||
*/
|
*/
|
||||||
$routes->get('/', 'Home::index');
|
$routes->get('/', 'Home::index');
|
||||||
|
|
||||||
|
$routes->get('/provision/update', 'Home::provision');
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ abstract class BaseController extends Controller
|
|||||||
*/
|
*/
|
||||||
protected $helpers = [];
|
protected $helpers = [];
|
||||||
|
|
||||||
|
protected $db;
|
||||||
/**
|
/**
|
||||||
* Be sure to declare properties for any property fetch you initialized.
|
* Be sure to declare properties for any property fetch you initialized.
|
||||||
* The creation of dynamic property is deprecated in PHP 8.2.
|
* The creation of dynamic property is deprecated in PHP 8.2.
|
||||||
@@ -52,7 +53,7 @@ abstract class BaseController extends Controller
|
|||||||
parent::initController($request, $response, $logger);
|
parent::initController($request, $response, $logger);
|
||||||
|
|
||||||
// Preload any models, libraries, etc, here.
|
// Preload any models, libraries, etc, here.
|
||||||
|
$this->db = \Config\Database::connect();
|
||||||
// E.g.: $this->session = service('session');
|
// E.g.: $this->session = service('session');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,35 @@ class Home extends BaseController
|
|||||||
{
|
{
|
||||||
return view('welcome_message');
|
return view('welcome_message');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function provision(): string
|
||||||
|
{
|
||||||
|
$public_path = FCPATH;
|
||||||
|
$ansible_folder = str_replace("public/", "ANSIBLE", $public_path);
|
||||||
|
$mysql = "SELECT id, internal_url FROM members_products";
|
||||||
|
$query = $this->db->query($mysql);
|
||||||
|
// $num = $query->num_rows();
|
||||||
|
$provision_list= $query->getResult();
|
||||||
|
//$provision_list =[];
|
||||||
|
foreach ($provision_list as $pr){
|
||||||
|
|
||||||
|
$prov_name = str_replace(".", "_", $pr->internal_url).".yml";
|
||||||
|
|
||||||
|
$myfile = fopen( $ansible_folder ."/".$prov_name, "w") or die("Unable to open file!");
|
||||||
|
$txt = "John Doe\n";
|
||||||
|
fwrite($myfile, $txt);
|
||||||
|
$txt = "Jane Doe\n";
|
||||||
|
fwrite($myfile, $txt);
|
||||||
|
fclose($myfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
// echo (__dir__);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return view('welcome_message');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user