-
Notifications
You must be signed in to change notification settings - Fork 1
/
Virtufile
110 lines (92 loc) · 5.12 KB
/
Virtufile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
Namespace Model ;
class Virtufile extends VirtufileBase {
public $config ;
public function __construct() {
$this->setConfig();
}
private function setConfig() {
$variables = array() ;
require (__DIR__.DIRECTORY_SEPARATOR.'vars'.DIRECTORY_SEPARATOR.'vm.php') ;
$this->setDefaultConfig();
$this->config["vm"]["name"] = 'pharaoh_'.$variables['friendly_app_slug'] ;
$this->config["vm"]["gui_mode"] = "headless" ;
$this->config["vm"]["cpus"] = "2" ;
$bu = 'https://repositories.internal.pharaohtools.com/index.php?control=BinaryServer&action=serve&item=iso_php_virtualize_boxes_-_ubuntu_16.04_server' ;
$this->config["vm"]["box_url"] = $bu ;
$this->config["vm"]["box"] = "ubuntu-18.04.4-server-amd64" ;
$random_port_suffix = $variables['random_port_suffix'] ;
$this->config["vm"]["memory"] = "512" ;
$this->config["vm"]["graceful_halt_timeout"] = 15 ;
$this->config["vm"]["ssh_halt_timeout"] = 2 ;
$this->config["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestssh,tcp,,22{$random_port_suffix},,22";
$this->config["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestweb,tcp,,80{$random_port_suffix},,80";
$this->config["ssh"]["driver"] = "native" ;
$this->config["ssh"]["user"] = "ptv" ;
$this->config["ssh"]["password"] = "ptv" ;
$this->config["ssh"]["target"] = "127.0.0.1" ;
$this->config["ssh"]["port"] = "22{$random_port_suffix}" ;
$this->config["ssh"]["retries"] = "1000" ;
$guest_path = DS.'opt'.DS.$variables['full_slug'].DS.$variables['full_slug'] ;
# Shared folder - This should map to the workstation environment vhost path parent...
$this->config["vm"]["shared_folders"][] =
array(
"name" => "host_".$variables['full_slug'],
"host_path" => getcwd().DS,
"guest_path" => $guest_path,
"symlinks" => "enable"
) ;
# Provisioning
$this->config["vm"]["defaults"] = ['mountshares', 'ptc'] ;
$i_path = dirname(__FILE__).DS ;
$this->config["vm"]["provision"][] = $this->config["vm"]["provision_up_light"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "host",
"script" => $i_path.'build'.DS.'ptc'.DS.'add-hostfile-entry.dsl.php',
"params" => array("vars" => $i_path.'vars'.DS.'vm.php'), ] ;
$this->config["vm"]["provision_destroy_post"][] =
[ "provisioner" => "PharaohTools", "tool" => "ptconfigure", "target" => "host",
"script" => $i_path.'build'.DS.'ptc'.DS.'remove-hostfile-entry.dsl.php',
"params" => array("vars" => $i_path.'vars'.DS.'vm.php') ] ;
$dsl_params = array('start-dir' => "{$guest_path}",
'vars' => "{$guest_path}vars/default.php,{$guest_path}vars/vm.php",
'step-times' => 'true',
'step-numbers' => 'true') ;
$this->config["vm"]["provision"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "guest",
"script" => "{$guest_path}/build/ptc/development.dsl.php",
"params" => $dsl_params ] ;
// $this->config["vm"]["provision"][] =
// [ "provisioner" => "PharaohTools",
// "tool" => "ptconfigure",
// "target" => "guest",
// "script" => "{$guest_path}/build/ptc/xdebug-webgrind.dsl.php",
// "params" => $dsl_params ] ;
$this->config["ptv"]['endpoints'] = [
['type' => 'ssh', 'connection_string' => "ssh [email protected] -o PreferredAuthentications=password -p 22{$random_port_suffix}", 'description' => "SSH Connection"],
['type' => 'http', 'url' => "http://build.{$variables['domain']}:80{$random_port_suffix}/", 'description' => "Build Server"],
['type' => 'http', 'url' => "http://source.{$variables['domain']}:80{$random_port_suffix}/", 'description' => "Web Client Application"],
['type' => 'http', 'url' => "http://webgrind.{$variables['domain']}:80{$random_port_suffix}/", 'description' => "Webgrind"]
] ;
$description = (isset($variables['description'])) ? "\n\n{$variables['description']}\n\n" : '' ;
$this->config["vm"]["post_up_message"] = "Your Virtualize Box has been brought up. $description.\n" ;
$i=1 ;
$text = '' ;
foreach ($this->config["ptv"]['endpoints'] as $endpoint) {
$text .= "Endpoint {$i}: \n" ;
$text .= " Type: {$endpoint['type']} \n" ;
$text .= " Description: {$endpoint['description']} \n" ;
if ($endpoint['type'] == 'http') {
$text .= " URL: {$endpoint['url']} \n" ;
} else if ($endpoint['type'] == 'ssh') {
$text .= " Connection String: {$endpoint['connection_string']}: \n" ;
}
$text .= "\n" ;
$i++ ;
}
$this->config["vm"]["post_up_message"] .= $text ;
}
}